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