src/HOL/Tools/ATP/atp_systems.ML
author blanchet
Fri May 06 13:34:59 2011 +0200 (2011-05-06)
changeset 42709 e7af132d48fe
parent 42708 b6a18a14cc5c
child 42710 84fcce345b5d
permissions -rw-r--r--
allow each prover to specify its own formula kind for symbols occurring in the conjecture
blanchet@38047
     1
(*  Title:      HOL/Tools/ATP/atp_systems.ML
wenzelm@28592
     2
    Author:     Fabian Immler, TU Muenchen
blanchet@36371
     3
    Author:     Jasmin Blanchette, TU Muenchen
wenzelm@28592
     4
blanchet@36376
     5
Setup for supported ATPs.
wenzelm@28592
     6
*)
wenzelm@28592
     7
blanchet@36376
     8
signature ATP_SYSTEMS =
wenzelm@28592
     9
sig
blanchet@42577
    10
  type format = ATP_Problem.format
blanchet@42577
    11
  type formula_kind = ATP_Problem.formula_kind
blanchet@39491
    12
  type failure = ATP_Proof.failure
blanchet@38023
    13
blanchet@40059
    14
  type atp_config =
blanchet@42578
    15
    {exec : string * string,
blanchet@42578
    16
     required_execs : (string * string) list,
blanchet@42646
    17
     arguments :
blanchet@42646
    18
       Proof.context -> int -> Time.time -> (unit -> (string * real) list)
blanchet@42646
    19
       -> string,
blanchet@42578
    20
     proof_delims : (string * string) list,
blanchet@42578
    21
     known_failures : (failure * string) list,
blanchet@42709
    22
     conj_sym_kind : formula_kind,
blanchet@42709
    23
     prem_kind : formula_kind,
blanchet@42578
    24
     formats : format list,
blanchet@42646
    25
     best_slices : Proof.context -> (real * (bool * int)) list,
blanchet@42613
    26
     best_type_systems : string list}
blanchet@38023
    27
blanchet@42646
    28
  val e_weight_method : string Config.T
blanchet@42646
    29
  val e_default_fun_weight : real Config.T
blanchet@42646
    30
  val e_fun_weight_base : real Config.T
blanchet@42646
    31
  val e_fun_weight_span : real Config.T
blanchet@42646
    32
  val e_default_sym_offs_weight : real Config.T
blanchet@42646
    33
  val e_sym_offs_weight_base : real Config.T
blanchet@42646
    34
  val e_sym_offs_weight_span : real Config.T
blanchet@40059
    35
  val eN : string
blanchet@40059
    36
  val spassN : string
blanchet@40059
    37
  val vampireN : string
blanchet@42535
    38
  val tofof_eN : string
blanchet@40059
    39
  val sine_eN : string
blanchet@40059
    40
  val snarkN : string
blanchet@41738
    41
  val z3_atpN : string
blanchet@40060
    42
  val remote_prefix : string
blanchet@41738
    43
  val remote_atp :
blanchet@41738
    44
    string -> string -> string list -> (string * string) list
blanchet@42709
    45
    -> (failure * string) list -> formula_kind -> formula_kind -> format list
blanchet@42646
    46
    -> (Proof.context -> int) -> string list -> string * atp_config
blanchet@40059
    47
  val add_atp : string * atp_config -> theory -> theory
blanchet@40059
    48
  val get_atp : theory -> string -> atp_config
blanchet@41727
    49
  val supported_atps : theory -> string list
blanchet@40059
    50
  val is_atp_installed : theory -> string -> bool
blanchet@35867
    51
  val refresh_systems_on_tptp : unit -> unit
blanchet@35867
    52
  val setup : theory -> theory
wenzelm@28592
    53
end;
wenzelm@28592
    54
blanchet@36376
    55
structure ATP_Systems : ATP_SYSTEMS =
wenzelm@28592
    56
struct
wenzelm@28596
    57
blanchet@42577
    58
open ATP_Problem
blanchet@39491
    59
open ATP_Proof
boehmes@32864
    60
blanchet@40059
    61
(* ATP configuration *)
boehmes@32864
    62
blanchet@40059
    63
type atp_config =
blanchet@42578
    64
  {exec : string * string,
blanchet@42578
    65
   required_execs : (string * string) list,
blanchet@42646
    66
   arguments :
blanchet@42646
    67
     Proof.context -> int -> Time.time -> (unit -> (string * real) list)
blanchet@42646
    68
     -> string,
blanchet@42578
    69
   proof_delims : (string * string) list,
blanchet@42578
    70
   known_failures : (failure * string) list,
blanchet@42709
    71
   conj_sym_kind : formula_kind,
blanchet@42709
    72
   prem_kind : formula_kind,
blanchet@42578
    73
   formats : format list,
blanchet@42646
    74
   best_slices : Proof.context -> (real * (bool * int)) list,
blanchet@42613
    75
   best_type_systems : string list}
wenzelm@28596
    76
blanchet@38061
    77
val known_perl_failures =
blanchet@38094
    78
  [(CantConnect, "HTTP error"),
blanchet@38094
    79
   (NoPerl, "env: perl"),
blanchet@38065
    80
   (NoLibwwwPerl, "Can't locate HTTP")]
wenzelm@28596
    81
blanchet@40059
    82
(* named ATPs *)
blanchet@40059
    83
blanchet@40059
    84
val eN = "e"
blanchet@40059
    85
val spassN = "spass"
blanchet@40059
    86
val vampireN = "vampire"
blanchet@41740
    87
val z3_atpN = "z3_atp"
blanchet@42535
    88
val tofof_eN = "tofof_e"
blanchet@40059
    89
val sine_eN = "sine_e"
blanchet@40059
    90
val snarkN = "snark"
blanchet@40060
    91
val remote_prefix = "remote_"
blanchet@38001
    92
blanchet@38023
    93
structure Data = Theory_Data
blanchet@38023
    94
(
blanchet@40059
    95
  type T = (atp_config * stamp) Symtab.table
blanchet@38023
    96
  val empty = Symtab.empty
blanchet@38023
    97
  val extend = I
blanchet@38023
    98
  fun merge data : T = Symtab.merge (eq_snd op =) data
blanchet@38023
    99
    handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@38023
   100
)
blanchet@38017
   101
blanchet@38737
   102
fun to_secs bonus time = (Time.toMilliseconds time + bonus + 999) div 1000
blanchet@36142
   103
blanchet@39491
   104
blanchet@40059
   105
(* E *)
wenzelm@28596
   106
blanchet@40344
   107
(* Give E an extra second to reconstruct the proof. Older versions even get two
blanchet@40344
   108
   seconds, because the "eproof" script wrongly subtracted an entire second to
blanchet@40344
   109
   account for the overhead of the script itself, which is in fact much
blanchet@40344
   110
   lower. *)
blanchet@38737
   111
fun e_bonus () =
blanchet@41334
   112
  if string_ord (getenv "E_VERSION", "1.1") = LESS then 2000 else 1000
blanchet@38737
   113
blanchet@36369
   114
val tstp_proof_delims =
blanchet@36369
   115
  ("# SZS output start CNFRefutation.", "# SZS output end CNFRefutation")
blanchet@36369
   116
blanchet@42646
   117
val e_slicesN = "slices"
blanchet@42646
   118
val e_autoN = "auto"
blanchet@42646
   119
val e_fun_weightN = "fun_weight"
blanchet@42646
   120
val e_sym_offset_weightN = "sym_offset_weight"
blanchet@41725
   121
blanchet@42646
   122
val e_weight_method =
blanchet@42646
   123
  Attrib.setup_config_string @{binding atp_e_weight_method} (K e_slicesN)
blanchet@41770
   124
(* FUDGE *)
blanchet@42646
   125
val e_default_fun_weight =
blanchet@42646
   126
  Attrib.setup_config_real @{binding atp_e_default_fun_weight} (K 20.0)
blanchet@42646
   127
val e_fun_weight_base =
blanchet@42646
   128
  Attrib.setup_config_real @{binding atp_e_fun_weight_base} (K 0.0)
blanchet@42646
   129
val e_fun_weight_span =
blanchet@42646
   130
  Attrib.setup_config_real @{binding atp_e_fun_weight_span} (K 40.0)
blanchet@42646
   131
val e_default_sym_offs_weight =
blanchet@42646
   132
  Attrib.setup_config_real @{binding atp_e_default_sym_offs_weight} (K 1.0)
blanchet@42646
   133
val e_sym_offs_weight_base =
blanchet@42646
   134
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_base} (K ~20.0)
blanchet@42646
   135
val e_sym_offs_weight_span =
blanchet@42646
   136
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_span} (K 60.0)
blanchet@41725
   137
blanchet@42443
   138
fun e_weight_method_case method fw sow =
blanchet@42646
   139
  if method = e_fun_weightN then fw
blanchet@42646
   140
  else if method = e_sym_offset_weightN then sow
blanchet@42646
   141
  else raise Fail ("unexpected" ^ quote method)
blanchet@41725
   142
blanchet@42646
   143
fun scaled_e_weight ctxt method w =
blanchet@42646
   144
  w * Config.get ctxt
blanchet@42646
   145
          (e_weight_method_case method e_fun_weight_span e_sym_offs_weight_span)
blanchet@42646
   146
  + Config.get ctxt
blanchet@42646
   147
        (e_weight_method_case method e_fun_weight_base e_sym_offs_weight_base)
blanchet@41725
   148
  |> Real.ceil |> signed_string_of_int
blanchet@41313
   149
blanchet@42646
   150
fun e_weight_arguments ctxt method weights =
blanchet@42646
   151
  if method = e_autoN then
blanchet@41725
   152
    "-xAutoDev"
blanchet@41725
   153
  else
blanchet@41314
   154
    "--split-clauses=4 --split-reuse-defs --simul-paramod --forward-context-sr \
blanchet@41314
   155
    \--destructive-er-aggressive --destructive-er --presat-simplify \
blanchet@41314
   156
    \--prefer-initial-clauses -tKBO6 -winvfreqrank -c1 -Ginvfreqconjmax -F1 \
blanchet@41314
   157
    \--delete-bad-limit=150000000 -WSelectMaxLComplexAvoidPosPred \
blanchet@42443
   158
    \-H'(4*" ^ e_weight_method_case method "FunWeight" "SymOffsetWeight" ^
blanchet@41725
   159
    "(SimulateSOS, " ^
blanchet@42646
   160
    (e_weight_method_case method e_default_fun_weight e_default_sym_offs_weight
blanchet@42646
   161
     |> Config.get ctxt |> Real.ceil |> signed_string_of_int) ^
blanchet@41314
   162
    ",20,1.5,1.5,1" ^
blanchet@42646
   163
    (weights ()
blanchet@42646
   164
     |> map (fn (s, w) => "," ^ s ^ ":" ^ scaled_e_weight ctxt method w)
blanchet@42646
   165
     |> implode) ^
blanchet@41314
   166
    "),3*ConjectureGeneralSymbolWeight(PreferNonGoals,200,100,200,50,50,1,100,\
blanchet@41314
   167
    \1.5,1.5,1),1*Clauseweight(PreferProcessed,1,1,1),1*\
blanchet@41314
   168
    \FIFOWeight(PreferProcessed))'"
blanchet@41313
   169
blanchet@42443
   170
fun is_old_e_version () = (string_ord (getenv "E_VERSION", "1.2w") = LESS)
blanchet@42443
   171
blanchet@42646
   172
fun effective_e_weight_method ctxt =
blanchet@42646
   173
  if is_old_e_version () then e_autoN else Config.get ctxt e_weight_method
blanchet@42443
   174
blanchet@42443
   175
(* The order here must correspond to the order in "e_config" below. *)
blanchet@42646
   176
fun method_for_slice ctxt slice =
blanchet@42646
   177
  let val method = effective_e_weight_method ctxt in
blanchet@42646
   178
    if method = e_slicesN then
blanchet@42646
   179
      case slice of
blanchet@42646
   180
        0 => e_sym_offset_weightN
blanchet@42646
   181
      | 1 => e_autoN
blanchet@42646
   182
      | 2 => e_fun_weightN
blanchet@42646
   183
      | _ => raise Fail "no such slice"
blanchet@42646
   184
    else
blanchet@42646
   185
      method
blanchet@42646
   186
  end
blanchet@42443
   187
blanchet@40059
   188
val e_config : atp_config =
blanchet@38092
   189
  {exec = ("E_HOME", "eproof"),
blanchet@38092
   190
   required_execs = [],
blanchet@42646
   191
   arguments = fn ctxt => fn slice => fn timeout => fn weights =>
blanchet@42443
   192
     "--tstp-in --tstp-out -l5 " ^
blanchet@42646
   193
     e_weight_arguments ctxt (method_for_slice ctxt slice) weights ^
blanchet@42443
   194
     " -tAutoDev --silent --cpu-limit=" ^
blanchet@42443
   195
     string_of_int (to_secs (e_bonus ()) timeout),
blanchet@36369
   196
   proof_delims = [tstp_proof_delims],
blanchet@36265
   197
   known_failures =
blanchet@37995
   198
     [(Unprovable, "SZS status: CounterSatisfiable"),
blanchet@37995
   199
      (Unprovable, "SZS status CounterSatisfiable"),
blanchet@36370
   200
      (TimedOut, "Failure: Resource limit exceeded (time)"),
blanchet@36370
   201
      (TimedOut, "time limit exceeded"),
blanchet@36370
   202
      (OutOfResources,
blanchet@36370
   203
       "# Cannot determine problem status within resource limit"),
blanchet@36370
   204
      (OutOfResources, "SZS status: ResourceOut"),
blanchet@36370
   205
      (OutOfResources, "SZS status ResourceOut")],
blanchet@42709
   206
   conj_sym_kind = Conjecture, (* FIXME: try out Hypothesis *)
blanchet@42709
   207
   prem_kind = Conjecture,
blanchet@42578
   208
   formats = [Fof],
blanchet@42646
   209
   best_slices = fn ctxt =>
blanchet@42646
   210
     if effective_e_weight_method ctxt = e_slicesN then
blanchet@42646
   211
       [(0.33333, (true, 100 (* FUDGE *))) (* sym_offset_weight *),
blanchet@42646
   212
        (0.33333, (true, 1000 (* FUDGE *))) (* auto *),
blanchet@42646
   213
        (0.33334, (true, 200 (* FUDGE *))) (* fun_weight *)]
blanchet@42578
   214
     else
blanchet@42578
   215
       [(1.0, (true, 250 (* FUDGE *)))],
blanchet@42708
   216
   (* Actual order, according to Judgment Day: "mangled_preds!",
blanchet@42708
   217
      "mangled_tags!", "mangled_tags?", "mangled_preds?". But E "mangled_preds?"
blanchet@42708
   218
      works well in combination with Vampire "mangled_tags!". *)
blanchet@42708
   219
   best_type_systems = ["mangled_preds?"]}
blanchet@38454
   220
blanchet@40059
   221
val e = (eN, e_config)
wenzelm@28596
   222
wenzelm@28596
   223
blanchet@39491
   224
(* SPASS *)
blanchet@39491
   225
blanchet@36219
   226
(* The "-VarWeight=3" option helps the higher-order problems, probably by
blanchet@36219
   227
   counteracting the presence of "hAPP". *)
blanchet@40059
   228
val spass_config : atp_config =
blanchet@38092
   229
  {exec = ("ISABELLE_ATP", "scripts/spass"),
blanchet@39002
   230
   required_execs = [("SPASS_HOME", "SPASS"), ("SPASS_HOME", "tptp2dfg")],
blanchet@42646
   231
   arguments = fn _ => fn slice => fn timeout => fn _ =>
blanchet@37962
   232
     ("-Auto -PGiven=0 -PProblem=0 -Splits=0 -FullRed=0 -DocProof \
blanchet@38737
   233
      \-VarWeight=3 -TimeLimit=" ^ string_of_int (to_secs 0 timeout))
blanchet@42443
   234
     |> slice = 0 ? prefix "-SOS=1 ",
blanchet@36369
   235
   proof_delims = [("Here is a proof", "Formulae used in the proof")],
blanchet@36289
   236
   known_failures =
blanchet@38061
   237
     known_perl_failures @
blanchet@37413
   238
     [(IncompleteUnprovable, "SPASS beiseite: Completion found"),
blanchet@36370
   239
      (TimedOut, "SPASS beiseite: Ran out of time"),
blanchet@36965
   240
      (OutOfResources, "SPASS beiseite: Maximal number of loops exceeded"),
blanchet@37413
   241
      (MalformedInput, "Undefined symbol"),
blanchet@37414
   242
      (MalformedInput, "Free Variable"),
blanchet@39263
   243
      (SpassTooOld, "tptp2dfg"),
blanchet@39263
   244
      (InternalError, "Please report this error")],
blanchet@42709
   245
   conj_sym_kind = Axiom, (* FIXME: try out Hypothesis *)
blanchet@42709
   246
   prem_kind = Conjecture,
blanchet@42578
   247
   formats = [Fof],
blanchet@42578
   248
   best_slices =
blanchet@42578
   249
     K [(0.66667, (false, 150 (* FUDGE *))) (* with SOS *),
blanchet@42578
   250
        (0.33333, (true, 150 (* FUDGE *))) (* without SOS *)],
blanchet@42692
   251
   best_type_systems =
blanchet@42708
   252
     ["args", "mangled_preds!", "mangled_tags!", "mangled_tags?"]}
blanchet@38454
   253
blanchet@40059
   254
val spass = (spassN, spass_config)
wenzelm@28596
   255
blanchet@38454
   256
blanchet@37509
   257
(* Vampire *)
blanchet@37509
   258
blanchet@40059
   259
val vampire_config : atp_config =
blanchet@38092
   260
  {exec = ("VAMPIRE_HOME", "vampire"),
blanchet@38092
   261
   required_execs = [],
blanchet@42646
   262
   arguments = fn _ => fn slice => fn timeout => fn _ =>
blanchet@41203
   263
     (* This would work too but it's less tested: "--proof tptp " ^ *)
blanchet@41203
   264
     "--mode casc -t " ^ string_of_int (to_secs 0 timeout) ^
blanchet@41203
   265
     " --thanks \"Andrei and Krystof\" --input_file"
blanchet@42443
   266
     |> slice = 0 ? prefix "--sos on ",
blanchet@37509
   267
   proof_delims =
blanchet@37509
   268
     [("=========== Refutation ==========",
blanchet@37509
   269
       "======= End of refutation ======="),
blanchet@38033
   270
      ("% SZS output start Refutation", "% SZS output end Refutation"),
blanchet@38033
   271
      ("% SZS output start Proof", "% SZS output end Proof")],
blanchet@37509
   272
   known_failures =
blanchet@37509
   273
     [(Unprovable, "UNPROVABLE"),
blanchet@37509
   274
      (IncompleteUnprovable, "CANNOT PROVE"),
blanchet@42449
   275
      (IncompleteUnprovable, "SZS status GaveUp"),
blanchet@42332
   276
      (ProofMissing, "[predicate definition introduction]"),
blanchet@42332
   277
      (ProofMissing, "predicate_definition_introduction,[]"), (* TSTP *)
blanchet@38092
   278
      (TimedOut, "SZS status Timeout"),
blanchet@37509
   279
      (Unprovable, "Satisfiability detected"),
blanchet@38647
   280
      (Unprovable, "Termination reason: Satisfiable"),
blanchet@39263
   281
      (VampireTooOld, "not a valid option"),
blanchet@39263
   282
      (Interrupted, "Aborted by signal SIGINT")],
blanchet@42709
   283
   conj_sym_kind = Conjecture, (* FIXME: try out Hypothesis *)
blanchet@42709
   284
   prem_kind = Conjecture,
blanchet@42578
   285
   formats = [Fof],
blanchet@42578
   286
   best_slices =
blanchet@42578
   287
     K [(0.66667, (false, 450 (* FUDGE *))) (* with SOS *),
blanchet@42578
   288
        (0.33333, (true, 450 (* FUDGE *))) (* without SOS *)],
blanchet@42692
   289
   best_type_systems =
blanchet@42708
   290
     ["mangled_tags!", "mangled_preds!", "mangled_preds?"]}
blanchet@38454
   291
blanchet@40059
   292
val vampire = (vampireN, vampire_config)
blanchet@37509
   293
blanchet@38454
   294
blanchet@41740
   295
(* Z3 with TPTP syntax *)
blanchet@41740
   296
blanchet@41740
   297
val z3_atp_config : atp_config =
blanchet@41740
   298
  {exec = ("Z3_HOME", "z3"),
blanchet@41740
   299
   required_execs = [],
blanchet@42646
   300
   arguments = fn _ => fn _ => fn timeout => fn _ =>
blanchet@41766
   301
     "MBQI=true -p -t:" ^ string_of_int (to_secs 0 timeout),
blanchet@41740
   302
   proof_delims = [],
blanchet@41740
   303
   known_failures =
blanchet@41742
   304
     [(Unprovable, "\nsat"),
blanchet@41742
   305
      (IncompleteUnprovable, "\nunknown"),
blanchet@42443
   306
      (IncompleteUnprovable, "SZS status Satisfiable"),
blanchet@42443
   307
      (ProofMissing, "\nunsat"),
blanchet@42443
   308
      (ProofMissing, "SZS status Unsatisfiable")],
blanchet@42709
   309
   conj_sym_kind = Hypothesis,
blanchet@42709
   310
   prem_kind = Hypothesis,
blanchet@42578
   311
   formats = [Fof],
blanchet@42578
   312
   best_slices = K [(1.0, (false, 250 (* FUDGE *)))],
blanchet@42692
   313
   best_type_systems = [] (* FIXME *)}
blanchet@41740
   314
blanchet@41740
   315
val z3_atp = (z3_atpN, z3_atp_config)
blanchet@41740
   316
blanchet@41740
   317
blanchet@40059
   318
(* Remote ATP invocation via SystemOnTPTP *)
wenzelm@28596
   319
blanchet@38061
   320
val systems = Synchronized.var "atp_systems" ([] : string list)
immler@31835
   321
immler@31835
   322
fun get_systems () =
blanchet@38061
   323
  case bash_output "\"$ISABELLE_ATP/scripts/remote_atp\" -w 2>&1" of
blanchet@39491
   324
    (output, 0) => split_lines output
blanchet@39491
   325
  | (output, _) =>
blanchet@39491
   326
    error (case extract_known_failure known_perl_failures output of
blanchet@41744
   327
             SOME failure => string_for_failure failure
blanchet@39491
   328
           | NONE => perhaps (try (unsuffix "\n")) output ^ ".")
immler@31835
   329
blanchet@42537
   330
fun find_system name [] systems =
blanchet@42537
   331
    find_first (String.isPrefix (name ^ "---")) systems
blanchet@38690
   332
  | find_system name (version :: versions) systems =
blanchet@38690
   333
    case find_first (String.isPrefix (name ^ "---" ^ version)) systems of
blanchet@38690
   334
      NONE => find_system name versions systems
blanchet@38690
   335
    | res => res
blanchet@38690
   336
blanchet@38690
   337
fun get_system name versions =
blanchet@38589
   338
  Synchronized.change_result systems
blanchet@38589
   339
      (fn systems => (if null systems then get_systems () else systems)
blanchet@38690
   340
                     |> `(find_system name versions))
boehmes@32864
   341
blanchet@38690
   342
fun the_system name versions =
blanchet@38690
   343
  case get_system name versions of
blanchet@39010
   344
    SOME sys => sys
blanchet@41269
   345
  | NONE => error ("System " ^ quote name ^
blanchet@41269
   346
                   " is not available at SystemOnTPTP.")
immler@31835
   347
blanchet@41148
   348
val max_remote_secs = 240 (* give Geoff Sutcliffe's servers a break *)
blanchet@41148
   349
blanchet@38690
   350
fun remote_config system_name system_versions proof_delims known_failures
blanchet@42709
   351
                  conj_sym_kind prem_kind formats best_max_relevant
blanchet@42709
   352
                  best_type_systems : atp_config =
blanchet@38092
   353
  {exec = ("ISABELLE_ATP", "scripts/remote_atp"),
blanchet@38092
   354
   required_execs = [],
blanchet@42646
   355
   arguments = fn _ => fn _ => fn timeout => fn _ =>
blanchet@41148
   356
     " -t " ^ string_of_int (Int.min (max_remote_secs, (to_secs 0 timeout)))
blanchet@41148
   357
     ^ " -s " ^ the_system system_name system_versions,
blanchet@36369
   358
   proof_delims = insert (op =) tstp_proof_delims proof_delims,
blanchet@38061
   359
   known_failures =
blanchet@38061
   360
     known_failures @ known_perl_failures @
blanchet@42571
   361
     [(IncompleteUnprovable, "says Unknown"),
blanchet@42584
   362
      (IncompleteUnprovable, "says GaveUp"),
blanchet@42571
   363
      (TimedOut, "says Timeout")],
blanchet@42709
   364
   conj_sym_kind = conj_sym_kind,
blanchet@42709
   365
   prem_kind = prem_kind,
blanchet@42578
   366
   formats = formats,
blanchet@42646
   367
   best_slices = fn ctxt => [(1.0, (false, best_max_relevant ctxt))],
blanchet@42578
   368
   best_type_systems = best_type_systems}
wenzelm@28596
   369
blanchet@42443
   370
fun int_average f xs = fold (Integer.add o f) xs 0 div length xs
blanchet@42443
   371
blanchet@38690
   372
fun remotify_config system_name system_versions
blanchet@42709
   373
        ({proof_delims, known_failures, conj_sym_kind, prem_kind, formats,
blanchet@42709
   374
          best_slices, best_type_systems, ...} : atp_config) : atp_config =
blanchet@38690
   375
  remote_config system_name system_versions proof_delims known_failures
blanchet@42709
   376
                conj_sym_kind prem_kind formats
blanchet@42709
   377
                (int_average (snd o snd) o best_slices) best_type_systems
blanchet@38023
   378
blanchet@40059
   379
fun remote_atp name system_name system_versions proof_delims known_failures
blanchet@42709
   380
        conj_sym_kind prem_kind formats best_max_relevant best_type_systems =
blanchet@40060
   381
  (remote_prefix ^ name,
blanchet@38690
   382
   remote_config system_name system_versions proof_delims known_failures
blanchet@42709
   383
                 conj_sym_kind prem_kind formats best_max_relevant
blanchet@42709
   384
                 best_type_systems)
blanchet@40059
   385
fun remotify_atp (name, config) system_name system_versions =
blanchet@40060
   386
  (remote_prefix ^ name, remotify_config system_name system_versions config)
wenzelm@28592
   387
blanchet@40059
   388
val remote_e = remotify_atp e "EP" ["1.0", "1.1", "1.2"]
blanchet@40059
   389
val remote_vampire = remotify_atp vampire "Vampire" ["0.6", "9.0", "1.0"]
blanchet@42537
   390
val remote_z3_atp = remotify_atp z3_atp "Z3" ["2.18"]
blanchet@42535
   391
val remote_tofof_e =
blanchet@42559
   392
  remote_atp tofof_eN "ToFoF" ["0.1"] [] (#known_failures e_config)
blanchet@42709
   393
             Axiom Conjecture [Tff] (K 200 (* FUDGE *)) ["simple"]
blanchet@41740
   394
val remote_sine_e =
blanchet@42709
   395
  remote_atp sine_eN "SInE" ["0.4"] [] [] Axiom Conjecture [Fof]
blanchet@42709
   396
             (K 500 (* FUDGE *)) ["args", "preds", "tags"]
blanchet@41740
   397
val remote_snark =
blanchet@42537
   398
  remote_atp snarkN "SNARK" ["20080805r024"]
blanchet@42709
   399
             [("refutation.", "end_refutation.")] [] Hypothesis Conjecture
blanchet@42709
   400
             [Tff, Fof] (K 250 (* FUDGE *)) ["simple"]
blanchet@38454
   401
blanchet@38454
   402
(* Setup *)
blanchet@38454
   403
blanchet@40059
   404
fun add_atp (name, config) thy =
blanchet@40059
   405
  Data.map (Symtab.update_new (name, (config, stamp ()))) thy
blanchet@40059
   406
  handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@40059
   407
blanchet@40059
   408
fun get_atp thy name =
blanchet@40059
   409
  the (Symtab.lookup (Data.get thy) name) |> fst
blanchet@40059
   410
  handle Option.Option => error ("Unknown ATP: " ^ name ^ ".")
blanchet@40059
   411
blanchet@41727
   412
val supported_atps = Symtab.keys o Data.get
blanchet@36371
   413
blanchet@40059
   414
fun is_atp_installed thy name =
blanchet@40059
   415
  let val {exec, required_execs, ...} = get_atp thy name in
blanchet@40059
   416
    forall (curry (op <>) "" o getenv o fst) (exec :: required_execs)
blanchet@40059
   417
  end
blanchet@36371
   418
blanchet@40059
   419
fun refresh_systems_on_tptp () =
blanchet@40059
   420
  Synchronized.change systems (fn _ => get_systems ())
blanchet@40059
   421
blanchet@41740
   422
val atps = [e, spass, vampire, z3_atp, remote_e, remote_vampire, remote_z3_atp,
blanchet@42535
   423
            remote_tofof_e, remote_sine_e, remote_snark]
blanchet@40059
   424
val setup = fold add_atp atps
blanchet@35867
   425
wenzelm@28592
   426
end;