185 let |
185 let |
186 val j0 = hd (hd conjecture_shape) |
186 val j0 = hd (hd conjecture_shape) |
187 val seq = extract_clause_sequence output |
187 val seq = extract_clause_sequence output |
188 val name_map = extract_clause_formula_relation output |
188 val name_map = extract_clause_formula_relation output |
189 fun renumber_conjecture j = |
189 fun renumber_conjecture j = |
190 conjecture_prefix ^ Int.toString (j - j0) |
190 conjecture_prefix ^ string_of_int (j - j0) |
191 |> AList.find (fn (s, ss) => member (op =) ss s) name_map |
191 |> AList.find (fn (s, ss) => member (op =) ss s) name_map |
192 |> map (fn s => find_index (curry (op =) s) seq + 1) |
192 |> map (fn s => find_index (curry (op =) s) seq + 1) |
193 fun name_for_number j = |
193 fun name_for_number j = |
194 let |
194 let |
195 val axioms = |
195 val axioms = |
208 |
208 |
209 (* generic TPTP-based provers *) |
209 (* generic TPTP-based provers *) |
210 |
210 |
211 fun prover_fun atp_name |
211 fun prover_fun atp_name |
212 {exec, required_execs, arguments, has_incomplete_mode, proof_delims, |
212 {exec, required_execs, arguments, has_incomplete_mode, proof_delims, |
213 known_failures, default_max_relevant_per_iter, default_theory_relevant, |
213 known_failures, default_max_relevant, default_theory_relevant, |
214 explicit_forall, use_conjecture_for_hypotheses} |
214 explicit_forall, use_conjecture_for_hypotheses} |
215 ({debug, verbose, overlord, full_types, explicit_apply, |
215 ({debug, verbose, overlord, full_types, explicit_apply, |
216 relevance_threshold, relevance_decay, |
216 relevance_threshold, relevance_decay, max_relevant, theory_relevant, |
217 max_relevant_per_iter, theory_relevant, isar_proof, |
217 isar_proof, isar_shrink_factor, timeout, ...} : params) |
218 isar_shrink_factor, timeout, ...} : params) |
|
219 minimize_command |
218 minimize_command |
220 ({subgoal, goal, relevance_override, axioms} : problem) = |
219 ({subgoal, goal, relevance_override, axioms} : problem) = |
221 let |
220 let |
222 val (ctxt, (_, th)) = goal; |
221 val (ctxt, (_, th)) = goal; |
223 val thy = ProofContext.theory_of ctxt |
222 val thy = ProofContext.theory_of ctxt |
224 val (params, hyp_ts, concl_t) = strip_subgoal th subgoal |
223 val (params, hyp_ts, concl_t) = strip_subgoal th subgoal |
225 |
224 |
226 fun print s = (priority s; if debug then tracing s else ()) |
225 val print = priority |
227 fun print_v f = () |> verbose ? print o f |
226 fun print_v f = () |> verbose ? print o f |
228 fun print_d f = () |> debug ? print o f |
227 fun print_d f = () |> debug ? print o f |
229 |
228 |
230 val the_axioms = |
229 val the_axioms = |
231 case axioms of |
230 case axioms of |
232 SOME axioms => axioms |
231 SOME axioms => axioms |
233 | NONE => |
232 | NONE => |
234 (relevant_facts full_types relevance_threshold relevance_decay |
233 (relevant_facts full_types relevance_threshold relevance_decay |
235 (the_default default_max_relevant_per_iter |
234 (the_default default_max_relevant max_relevant) |
236 max_relevant_per_iter) |
|
237 (the_default default_theory_relevant theory_relevant) |
235 (the_default default_theory_relevant theory_relevant) |
238 relevance_override goal hyp_ts concl_t |
236 relevance_override goal hyp_ts concl_t |
239 |> tap ((fn n => print_v (fn () => |
237 |> tap ((fn n => print_v (fn () => |
240 "Selected " ^ string_of_int n ^ " fact" ^ plural_s n ^ |
238 "Selected " ^ string_of_int n ^ " fact" ^ plural_s n ^ |
241 " for " ^ quote atp_name ^ ".")) o length)) |
239 " for " ^ quote atp_name ^ ".")) o length)) |
255 else if File.exists (Path.explode the_dest_dir) |
253 else if File.exists (Path.explode the_dest_dir) |
256 then Path.append (Path.explode the_dest_dir) probfile |
254 then Path.append (Path.explode the_dest_dir) probfile |
257 else error ("No such directory: " ^ the_dest_dir ^ ".") |
255 else error ("No such directory: " ^ the_dest_dir ^ ".") |
258 end; |
256 end; |
259 |
257 |
|
258 val measure_run_time = verbose orelse Config.get ctxt measure_runtime |
260 val command = Path.explode (getenv (fst exec) ^ "/" ^ snd exec) |
259 val command = Path.explode (getenv (fst exec) ^ "/" ^ snd exec) |
261 (* write out problem file and call prover *) |
260 (* write out problem file and call prover *) |
262 fun command_line complete timeout probfile = |
261 fun command_line complete timeout probfile = |
263 let |
262 let |
264 val core = File.shell_path command ^ " " ^ arguments complete timeout ^ |
263 val core = File.shell_path command ^ " " ^ arguments complete timeout ^ |
265 " " ^ File.shell_path probfile |
264 " " ^ File.shell_path probfile |
266 in |
265 in |
267 (if Config.get ctxt measure_runtime then |
266 (if measure_run_time then "TIMEFORMAT='%3U'; { time " ^ core ^ " ; }" |
268 "TIMEFORMAT='%3U'; { time " ^ core ^ " ; }" |
267 else "exec " ^ core) ^ " 2>&1" |
269 else |
|
270 "exec " ^ core) ^ " 2>&1" |
|
271 end |
268 end |
272 fun split_time s = |
269 fun split_time s = |
273 let |
270 let |
274 val split = String.tokens (fn c => str c = "\n"); |
271 val split = String.tokens (fn c => str c = "\n"); |
275 val (output, t) = s |> split |> split_last |> apfst cat_lines; |
272 val (output, t) = s |> split |> split_last |> apfst cat_lines; |
294 bash_output command |
291 bash_output command |
295 |>> (if overlord then |
292 |>> (if overlord then |
296 prefix ("% " ^ command ^ "\n% " ^ timestamp () ^ "\n") |
293 prefix ("% " ^ command ^ "\n% " ^ timestamp () ^ "\n") |
297 else |
294 else |
298 I) |
295 I) |
299 |>> (if Config.get ctxt measure_runtime then split_time |
296 |>> (if measure_run_time then split_time else rpair 0) |
300 else rpair 0) |
|
301 val (proof, outcome) = |
297 val (proof, outcome) = |
302 extract_proof_and_outcome complete res_code proof_delims |
298 extract_proof_and_outcome complete res_code proof_delims |
303 known_failures output |
299 known_failures output |
304 in (output, msecs, proof, outcome) end |
300 in (output, msecs, proof, outcome) end |
305 val _ = print_d (fn () => "Preparing problem for " ^ |
301 val _ = print_d (fn () => "Preparing problem for " ^ |
352 case outcome of |
348 case outcome of |
353 NONE => |
349 NONE => |
354 proof_text isar_proof |
350 proof_text isar_proof |
355 (pool, debug, isar_shrink_factor, ctxt, conjecture_shape) |
351 (pool, debug, isar_shrink_factor, ctxt, conjecture_shape) |
356 (full_types, minimize_command, proof, axiom_names, th, subgoal) |
352 (full_types, minimize_command, proof, axiom_names, th, subgoal) |
|
353 |>> (fn message => |
|
354 message ^ (if verbose then |
|
355 "\nATP CPU time: " ^ string_of_int msecs ^ " ms." |
|
356 else |
|
357 "")) |
357 | SOME failure => (string_for_failure failure, []) |
358 | SOME failure => (string_for_failure failure, []) |
358 in |
359 in |
359 {outcome = outcome, message = message, pool = pool, |
360 {outcome = outcome, message = message, pool = pool, |
360 used_thm_names = used_thm_names, atp_run_time_in_msecs = msecs, |
361 used_thm_names = used_thm_names, atp_run_time_in_msecs = msecs, |
361 output = output, proof = proof, axiom_names = axiom_names, |
362 output = output, proof = proof, axiom_names = axiom_names, |