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