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