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