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