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