src/HOL/Tools/ATP_Manager/atp_wrapper.ML
author blanchet
Fri, 19 Mar 2010 13:02:18 +0100
changeset 35865 2f8fb5242799
parent 35826 1590abc3d42a
child 35867 16279c4c7a33
permissions -rw-r--r--
more Sledgehammer refactoring
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     2
    Author:     Fabian Immler, TU Muenchen
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     3
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     4
Wrapper functions for external ATPs.
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     5
*)
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     6
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     7
signature ATP_WRAPPER =
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
     8
sig
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
     9
  (*hooks for problem files*)
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    10
  val destdir: string Config.T
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    11
  val problem_prefix: string Config.T
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
    12
  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
    13
  val setup: theory -> theory
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    14
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    15
  (*prover configuration, problem format, and prover result*)
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    16
  type prover_config =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    17
   {command: Path.T,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    18
    arguments: int -> string,
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    19
    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
    20
    max_new_clauses: int,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    21
    insert_theory_const: bool,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    22
    emit_structured_proof: bool}
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
    23
  type problem =
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    24
   {with_full_types: bool,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    25
    subgoal: int,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    26
    goal: Proof.context * (thm list * thm),
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    27
    axiom_clauses: (thm * (string * int)) list option,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    28
    filtered_clauses: (thm * (string * int)) list option}
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
    29
  val problem_of_goal: bool -> int -> Proof.context * (thm list * thm) -> problem
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    30
  type prover_result =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    31
   {success: bool,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    32
    message: string,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    33
    theorem_names: string list,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    34
    runtime: int,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    35
    proof: string,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    36
    internal_thm_names: string Vector.vector,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    37
    filtered_clauses: (thm * (string * int)) list}
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
    38
  type prover = int -> problem -> prover_result
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    39
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    40
  (*common provers*)
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    41
  val vampire: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    42
  val vampire_full: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    43
  val eprover: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    44
  val eprover_full: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    45
  val spass: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    46
  val spass_no_tc: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    47
  val remote_vampire: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    48
  val remote_eprover: string * prover
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    49
  val remote_spass: string * prover
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
    50
  val refresh_systems: unit -> unit
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
    51
end;
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
    52
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    53
structure ATP_Wrapper : ATP_WRAPPER =
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
    54
struct
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    55
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    56
open Sledgehammer_HOL_Clause
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    57
open Sledgehammer_Fact_Filter
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    58
open Sledgehammer_Proof_Reconstruct
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35570
diff changeset
    59
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    60
(** generic ATP wrapper **)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    61
32944
ecc0705174c2 clarified File.platform_path vs. File.shell_path;
wenzelm
parents: 32942
diff changeset
    62
(* external problem files *)
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    63
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    64
val (destdir, destdir_setup) = Attrib.config_string "atp_destdir" "";
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    65
  (*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
    66
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    67
val (problem_prefix, problem_prefix_setup) =
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    68
  Attrib.config_string "atp_problem_prefix" "prob";
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    69
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
    70
val (measure_runtime, measure_runtime_setup) =
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
    71
  Attrib.config_bool "atp_measure_runtime" false;
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
    72
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
    73
val setup = destdir_setup #> problem_prefix_setup #> measure_runtime_setup;
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    74
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    75
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    76
(* prover configuration, problem format, and prover result *)
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    77
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    78
type prover_config =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    79
 {command: Path.T,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    80
  arguments: int -> string,
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
    81
  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
    82
  max_new_clauses: int,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    83
  insert_theory_const: bool,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    84
  emit_structured_proof: bool};
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
    85
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
    86
type problem =
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    87
 {with_full_types: bool,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    88
  subgoal: int,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    89
  goal: Proof.context * (thm list * thm),
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    90
  axiom_clauses: (thm * (string * int)) list option,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    91
  filtered_clauses: (thm * (string * int)) list option};
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    92
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
    93
fun problem_of_goal with_full_types subgoal goal : problem =
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    94
 {with_full_types = with_full_types,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    95
  subgoal = subgoal,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    96
  goal = goal,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    97
  axiom_clauses = NONE,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
    98
  filtered_clauses = NONE};
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
    99
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   100
type prover_result =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   101
 {success: bool,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   102
  message: string,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   103
  theorem_names: string list,  (*relevant theorems*)
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   104
  runtime: int,  (*user time of the ATP, in milliseconds*)
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   105
  proof: string,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   106
  internal_thm_names: string Vector.vector,
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   107
  filtered_clauses: (thm * (string * int)) list};
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   108
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
   109
type prover = int -> problem -> prover_result;
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   110
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   111
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   112
(* basic template *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   113
32458
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
   114
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
   115
  Exn.capture f path
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
   116
  |> tap (fn _ => cleanup path)
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
   117
  |> Exn.release
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   118
  |> tap (after path);
32458
de6834b20e9e sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents: 32451
diff changeset
   119
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   120
fun find_failure strs proof =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   121
  case filter (fn s => String.isSubstring s proof) strs of
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   122
    [] => if is_proof_well_formed proof then NONE
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   123
          else SOME "Ill-formed ATP output"
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   124
  | (failure :: _) => SOME failure
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   125
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   126
fun external_prover relevance_filter prepare write cmd args failure_strs
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   127
        produce_answer name ({with_full_types, subgoal, goal, axiom_clauses,
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   128
                              filtered_clauses}: problem) =
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   129
  let
31750
f28b7365fabf restructured external_prover
immler@in.tum.de
parents: 31411
diff changeset
   130
    (* get clauses and prepare them for writing *)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   131
    val (ctxt, (chain_ths, th)) = goal;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   132
    val thy = ProofContext.theory_of ctxt;
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   133
    val chain_ths = map (Thm.put_name_hint chained_hint) chain_ths;
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35570
diff changeset
   134
    val goal_cls = #1 (Sledgehammer_Fact_Preprocessor.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
   135
    val the_filtered_clauses =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   136
      (case filtered_clauses of
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   137
        NONE => relevance_filter goal goal_cls
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   138
      | SOME fcls => fcls);
31409
d8537ba165b5 split preparing clauses and writing problemfile;
immler@in.tum.de
parents: 31368
diff changeset
   139
    val the_axiom_clauses =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   140
      (case axiom_clauses of
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   141
        NONE => the_filtered_clauses
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   142
      | SOME axcls => axcls);
32257
bad5a99c16d8 neg_conjecture_clauses, neg_clausify_tac: proper context, eliminated METAHYPS;
wenzelm
parents: 32091
diff changeset
   143
    val (thm_names, clauses) =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   144
      prepare goal_cls chain_ths the_axiom_clauses the_filtered_clauses thy;
31750
f28b7365fabf restructured external_prover
immler@in.tum.de
parents: 31411
diff changeset
   145
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   146
    (* path to unique problem file *)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   147
    val destdir' = Config.get ctxt destdir;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   148
    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
   149
    fun prob_pathname nr =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   150
      let val probfile =
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   151
        Path.basic (problem_prefix' ^ serial_string () ^ "_" ^ string_of_int nr)
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   152
      in
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   153
        if destdir' = "" then File.tmp_path probfile
35570
0e30eef52d85 basic simplification of external_prover signature;
wenzelm
parents: 35010
diff changeset
   154
        else if File.exists (Path.explode destdir')
0e30eef52d85 basic simplification of external_prover signature;
wenzelm
parents: 35010
diff changeset
   155
        then Path.append  (Path.explode destdir') probfile
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   156
        else error ("No such directory: " ^ destdir')
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   157
      end;
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   158
31750
f28b7365fabf restructured external_prover
immler@in.tum.de
parents: 31411
diff changeset
   159
    (* write out problem file and call prover *)
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   160
    fun cmd_line probfile =
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   161
      if Config.get ctxt measure_runtime
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   162
      then (* Warning: suppresses error messages of ATPs *)
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   163
        "TIMEFORMAT='%3U'; { time " ^ space_implode " " [File.shell_path cmd,
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   164
        args, File.shell_path probfile] ^ " 2> /dev/null" ^ " ; } 2>&1"
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   165
      else
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   166
        space_implode " " ["exec", File.shell_path cmd, args,
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   167
        File.shell_path probfile];
32510
1b56f8b1e5cc added runtime information to sledgehammer
boehmes
parents: 32458
diff changeset
   168
    fun split_time s =
1b56f8b1e5cc added runtime information to sledgehammer
boehmes
parents: 32458
diff changeset
   169
      let
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   170
        val split = String.tokens (fn c => str c = "\n");
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   171
        val (proof, t) = s |> split |> split_last |> apfst cat_lines;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   172
        fun as_num f = f >> (fst o read_int);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   173
        val num = as_num (Scan.many1 Symbol.is_ascii_digit);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   174
        val digit = Scan.one Symbol.is_ascii_digit;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   175
        val num3 = as_num (digit ::: digit ::: (digit >> single));
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   176
        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
   177
        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
   178
      in (proof, as_time t) end;
33247
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   179
    fun split_time' s =
ed1681284f62 measure runtime of ATPs only if requested
boehmes
parents: 33082
diff changeset
   180
      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
   181
    fun run_on probfile =
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   182
      if File.exists cmd then
35570
0e30eef52d85 basic simplification of external_prover signature;
wenzelm
parents: 35010
diff changeset
   183
        write with_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
   184
        |> pair (apfst split_time' (bash_output (cmd_line probfile)))
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   185
      else error ("Bad executable: " ^ Path.implode cmd);
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   186
31751
fda2cf4fef58 export proof when exporting problemfile
immler@in.tum.de
parents: 31750
diff changeset
   187
    (* if problemfile has not been exported, delete problemfile; otherwise export proof, too *)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   188
    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
   189
    fun export probfile (((proof, _), _), _) =
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   190
      if destdir' = "" then ()
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   191
      else File.write (Path.explode (Path.implode probfile ^ "_proof")) proof;
32257
bad5a99c16d8 neg_conjecture_clauses, neg_clausify_tac: proper context, eliminated METAHYPS;
wenzelm
parents: 32091
diff changeset
   192
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   193
    val (((proof, time), rc), conj_pos) =
35570
0e30eef52d85 basic simplification of external_prover signature;
wenzelm
parents: 35010
diff changeset
   194
      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
   195
29590
479a2fce65e6 modified remote script;
immler@in.tum.de
parents: 29587
diff changeset
   196
    (* check for success and print out some information on failure *)
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   197
    val failure = find_failure failure_strs proof;
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   198
    val success = rc = 0 andalso is_none failure;
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   199
    val (message, real_thm_names) =
32451
8f0dc876fb1b propagate theorem names, in addition to generated return message
boehmes
parents: 32327
diff changeset
   200
      if is_some failure then ("External prover failed.", [])
8f0dc876fb1b propagate theorem names, in addition to generated return message
boehmes
parents: 32327
diff changeset
   201
      else if rc <> 0 then ("External prover failed: " ^ proof, [])
8f0dc876fb1b propagate theorem names, in addition to generated return message
boehmes
parents: 32327
diff changeset
   202
      else apfst (fn s => "Try this command: " ^ s)
35570
0e30eef52d85 basic simplification of external_prover signature;
wenzelm
parents: 35010
diff changeset
   203
        (produce_answer name (proof, thm_names, conj_pos, ctxt, th, subgoal));
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   204
  in
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   205
    {success = success, message = message,
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   206
      theorem_names = real_thm_names, runtime = time, proof = proof,
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   207
      internal_thm_names = thm_names, filtered_clauses = the_filtered_clauses}
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   208
  end;
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   209
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   210
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   211
(* generic TPTP-based provers *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   212
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   213
fun generic_tptp_prover
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   214
        (name, {command, arguments, failure_strs, max_new_clauses,
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   215
                insert_theory_const, emit_structured_proof}) timeout =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   216
  external_prover (get_relevant_facts max_new_clauses insert_theory_const)
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   217
      (prepare_clauses false) write_tptp_file command (arguments timeout)
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   218
      failure_strs
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   219
      (if emit_structured_proof then structured_isar_proof
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   220
       else metis_lemma_list false) name;
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   221
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   222
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
   223
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   224
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   225
(** common provers **)
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   226
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   227
(* Vampire *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   228
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   229
(*NB: Vampire does not work without explicit timelimit*)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   230
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   231
val vampire_failure_strs =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   232
  ["Satisfiability detected", "Refutation not found", "CANNOT PROVE"];
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   233
val vampire_max_new_clauses = 60;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   234
val vampire_insert_theory_const = false;
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   235
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   236
fun vampire_prover_config full : prover_config =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   237
 {command = Path.explode "$VAMPIRE_HOME/vampire",
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   238
  arguments = (fn timeout => "--output_syntax tptp --mode casc" ^
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   239
    " -t " ^ string_of_int timeout),
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   240
  failure_strs = vampire_failure_strs,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   241
  max_new_clauses = vampire_max_new_clauses,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   242
  insert_theory_const = vampire_insert_theory_const,
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   243
  emit_structured_proof = full};
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   244
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   245
val vampire = tptp_prover ("vampire", vampire_prover_config false);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   246
val vampire_full = tptp_prover ("vampire_full", vampire_prover_config true);
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   247
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   248
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   249
(* E prover *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   250
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   251
val eprover_failure_strs =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   252
  ["SZS status: Satisfiable", "SZS status Satisfiable",
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   253
   "SZS status: ResourceOut", "SZS status ResourceOut",
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   254
   "# Cannot determine problem status"];
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   255
val eprover_max_new_clauses = 100;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   256
val eprover_insert_theory_const = false;
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   257
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   258
fun eprover_config full : prover_config =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   259
 {command = Path.explode "$E_HOME/eproof",
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   260
  arguments = (fn timeout => "--tstp-in --tstp-out -l5 -xAutoDev -tAutoDev" ^
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   261
    " --silent --cpu-limit=" ^ string_of_int timeout),
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   262
  failure_strs = eprover_failure_strs,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   263
  max_new_clauses = eprover_max_new_clauses,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   264
  insert_theory_const = eprover_insert_theory_const,
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   265
  emit_structured_proof = full};
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   266
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   267
val eprover = tptp_prover ("e", eprover_config false);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   268
val eprover_full = tptp_prover ("e_full", eprover_config true);
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   269
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   270
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   271
(* SPASS *)
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   272
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   273
val spass_failure_strs =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   274
  ["SPASS beiseite: Completion found.", "SPASS beiseite: Ran out of time.",
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   275
   "SPASS beiseite: Maximal number of loops exceeded."];
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   276
val spass_max_new_clauses = 40;
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   277
val spass_insert_theory_const = true;
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   278
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   279
fun spass_config insert_theory_const: prover_config =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   280
 {command = Path.explode "$SPASS_HOME/SPASS",
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   281
  arguments = (fn timeout => "-Auto -SOS=1 -PGiven=0 -PProblem=0 -Splits=0" ^
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   282
    " -FullRed=0 -DocProof -TimeLimit=" ^ string_of_int timeout),
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   283
  failure_strs = spass_failure_strs,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   284
  max_new_clauses = spass_max_new_clauses,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   285
  insert_theory_const = insert_theory_const,
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   286
  emit_structured_proof = false};
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   287
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   288
fun generic_dfg_prover
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   289
        (name, ({command, arguments, failure_strs, max_new_clauses,
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   290
                 insert_theory_const, ...} : prover_config)) timeout =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   291
  external_prover
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   292
    (get_relevant_facts max_new_clauses insert_theory_const)
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   293
    (prepare_clauses true)
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   294
    write_dfg_file
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   295
    command
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   296
    (arguments timeout)
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   297
    failure_strs
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   298
    (metis_lemma_list true)
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   299
    name;
32869
159309603edc recovered support for Spass: re-enabled writing problems in DFG format
boehmes
parents: 32864
diff changeset
   300
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   301
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
   302
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   303
val spass = dfg_prover ("spass", spass_config spass_insert_theory_const);
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   304
val spass_no_tc = dfg_prover ("spass_no_tc", spass_config false);
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   305
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   306
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   307
(* remote prover invocation via SystemOnTPTP *)
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   308
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   309
val systems = Synchronized.var "atp_wrapper_systems" ([]: string list);
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   310
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   311
fun get_systems () =
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   312
  let
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
   313
    val (answer, rc) = bash_output ("\"$ISABELLE_ATP_MANAGER/SystemOnTPTP\" -w")
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   314
  in
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35570
diff changeset
   315
    if rc <> 0 then error ("Failed to get available systems at SystemOnTPTP:\n" ^ answer)
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   316
    else split_lines answer
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   317
  end;
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   318
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   319
fun refresh_systems () = Synchronized.change systems (fn _ => get_systems ());
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   320
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   321
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
   322
  (if null systems then get_systems () else systems)
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   323
  |> `(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
   324
32948
e95a4be101a8 natural argument order for prover;
wenzelm
parents: 32944
diff changeset
   325
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
   326
  (case get_system prefix of
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35570
diff changeset
   327
    NONE => error ("System " ^ quote prefix ^ " not available at SystemOnTPTP")
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   328
  | SOME sys => sys);
31835
b686d4df54c2 check for current versions on server
immler@in.tum.de
parents: 31832
diff changeset
   329
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   330
val remote_failure_strs = ["Remote-script could not extract proof"];
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   331
32941
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   332
fun remote_prover_config prover_prefix args max_new insert_tc: prover_config =
72d48e333b77 eliminated extraneous wrapping of public records;
wenzelm
parents: 32936
diff changeset
   333
 {command = Path.explode "$ISABELLE_ATP_MANAGER/SystemOnTPTP",
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   334
  arguments = (fn timeout =>
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   335
    args ^ " -t " ^ string_of_int timeout ^ " -s " ^ the_system prover_prefix),
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35826
diff changeset
   336
  failure_strs = remote_failure_strs,
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   337
  max_new_clauses = max_new,
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   338
  insert_theory_const = insert_tc,
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   339
  emit_structured_proof = false};
28596
fcd463a6b6de tuned interfaces -- plain prover function, without thread;
wenzelm
parents: 28592
diff changeset
   340
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   341
val remote_vampire = tptp_prover ("remote_vampire", remote_prover_config
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   342
  "Vampire---9" "" vampire_max_new_clauses vampire_insert_theory_const);
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   343
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   344
val remote_eprover = tptp_prover ("remote_e", remote_prover_config
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   345
  "EP---" "" eprover_max_new_clauses eprover_insert_theory_const);
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   346
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32740
diff changeset
   347
val remote_spass = tptp_prover ("remote_spass", remote_prover_config
32942
b6711ec9de26 misc tuning and recovery of Isabelle coding style;
wenzelm
parents: 32941
diff changeset
   348
  "SPASS---" "-x" spass_max_new_clauses spass_insert_theory_const);
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   349
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents:
diff changeset
   350
end;