src/HOL/Tools/ATP/atp_systems.ML
author blanchet
Mon Jun 16 19:41:01 2014 +0200 (2014-06-16)
changeset 57265 cab38f7a3adb
parent 57264 13db1d078743
child 57269 1df6f747f164
permissions -rw-r--r--
use right delimiters for Waldmeister proofs
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@47038
    10
  type term_order = ATP_Problem.term_order
blanchet@45301
    11
  type atp_format = ATP_Problem.atp_format
blanchet@53586
    12
  type atp_formula_role = ATP_Problem.atp_formula_role
blanchet@53586
    13
  type atp_failure = ATP_Proof.atp_failure
blanchet@38023
    14
blanchet@51011
    15
  type slice_spec = (int * string) * atp_format * string * string * bool
blanchet@40059
    16
  type atp_config =
blanchet@52754
    17
    {exec : unit -> string list * string list,
blanchet@42646
    18
     arguments :
blanchet@50927
    19
       Proof.context -> bool -> string -> Time.time -> string
blanchet@47038
    20
       -> term_order * (unit -> (string * int) list)
blanchet@47038
    21
          * (unit -> (string * real) list) -> string,
blanchet@42578
    22
     proof_delims : (string * string) list,
blanchet@53586
    23
     known_failures : (atp_failure * string) list,
blanchet@53586
    24
     prem_role : atp_formula_role,
blanchet@48716
    25
     best_slices : Proof.context -> (real * (slice_spec * string)) list,
blanchet@47962
    26
     best_max_mono_iters : int,
blanchet@47962
    27
     best_max_new_mono_instances : int}
blanchet@38023
    28
blanchet@47962
    29
  val default_max_mono_iters : int
blanchet@47962
    30
  val default_max_new_mono_instances : int
blanchet@44099
    31
  val force_sos : bool Config.T
blanchet@47032
    32
  val term_order : string Config.T
blanchet@43566
    33
  val e_smartN : string
blanchet@43566
    34
  val e_autoN : string
blanchet@43566
    35
  val e_fun_weightN : string
blanchet@43566
    36
  val e_sym_offset_weightN : string
blanchet@47032
    37
  val e_selection_heuristic : string Config.T
blanchet@42646
    38
  val e_default_fun_weight : real Config.T
blanchet@42646
    39
  val e_fun_weight_base : real Config.T
blanchet@42646
    40
  val e_fun_weight_span : real Config.T
blanchet@42646
    41
  val e_default_sym_offs_weight : real Config.T
blanchet@42646
    42
  val e_sym_offs_weight_base : real Config.T
blanchet@42646
    43
  val e_sym_offs_weight_span : real Config.T
blanchet@50950
    44
  val spass_H1SOS : string
blanchet@50950
    45
  val spass_H2 : string
blanchet@50950
    46
  val spass_H2LR0LT0 : string
blanchet@50950
    47
  val spass_H2NuVS0 : string
blanchet@50950
    48
  val spass_H2NuVS0Red2 : string
blanchet@50950
    49
  val spass_H2SOS : string
blanchet@50950
    50
  val spass_extra_options : string Config.T
blanchet@41738
    51
  val remote_atp :
blanchet@41738
    52
    string -> string -> string list -> (string * string) list
blanchet@53586
    53
    -> (atp_failure * string) list -> atp_formula_role
blanchet@47606
    54
    -> (Proof.context -> slice_spec * string) -> string * (unit -> atp_config)
blanchet@47606
    55
  val add_atp : string * (unit -> atp_config) -> theory -> theory
blanchet@47606
    56
  val get_atp : theory -> string -> (unit -> atp_config)
blanchet@41727
    57
  val supported_atps : theory -> string list
blanchet@40059
    58
  val is_atp_installed : theory -> string -> bool
blanchet@35867
    59
  val refresh_systems_on_tptp : unit -> unit
blanchet@47055
    60
  val effective_term_order : Proof.context -> string -> term_order
wenzelm@28592
    61
end;
wenzelm@28592
    62
blanchet@36376
    63
structure ATP_Systems : ATP_SYSTEMS =
wenzelm@28592
    64
struct
wenzelm@28596
    65
blanchet@42577
    66
open ATP_Problem
blanchet@39491
    67
open ATP_Proof
blanchet@46320
    68
open ATP_Problem_Generate
boehmes@32864
    69
blanchet@52073
    70
blanchet@40059
    71
(* ATP configuration *)
boehmes@32864
    72
blanchet@47962
    73
val default_max_mono_iters = 3 (* FUDGE *)
blanchet@53515
    74
val default_max_new_mono_instances = 100 (* FUDGE *)
blanchet@47962
    75
blanchet@51011
    76
type slice_spec = (int * string) * atp_format * string * string * bool
blanchet@46409
    77
blanchet@40059
    78
type atp_config =
blanchet@52754
    79
  {exec : unit -> string list * string list,
blanchet@42646
    80
   arguments :
blanchet@50927
    81
     Proof.context -> bool -> string -> Time.time -> string
blanchet@47038
    82
     -> term_order * (unit -> (string * int) list)
blanchet@47038
    83
        * (unit -> (string * real) list) -> string,
blanchet@42578
    84
   proof_delims : (string * string) list,
blanchet@53586
    85
   known_failures : (atp_failure * string) list,
blanchet@53586
    86
   prem_role : atp_formula_role,
blanchet@48716
    87
   best_slices : Proof.context -> (real * (slice_spec * string)) list,
blanchet@47962
    88
   best_max_mono_iters : int,
blanchet@47962
    89
   best_max_new_mono_instances : int}
wenzelm@28596
    90
blanchet@42723
    91
(* "best_slices" must be found empirically, taking a wholistic approach since
blanchet@51011
    92
   the ATPs are run in parallel. Each slice has the format
blanchet@51011
    93
blanchet@51011
    94
     (time_frac, ((max_facts, fact_filter), format, type_enc,
blanchet@51011
    95
                  lam_trans, uncurried_aliases), extra)
blanchet@51011
    96
blanchet@51011
    97
   where
blanchet@51011
    98
blanchet@51011
    99
     time_frac = faction of the time available given to the slice (which should
blanchet@51011
   100
       add up to 1.0)
blanchet@51011
   101
blanchet@51011
   102
     extra = extra information to the prover (e.g., SOS or no SOS).
blanchet@42723
   103
blanchet@42723
   104
   The last slice should be the most "normal" one, because it will get all the
blanchet@43569
   105
   time available if the other slices fail early and also because it is used if
blanchet@43569
   106
   slicing is disabled (e.g., by the minimizer). *)
blanchet@42710
   107
blanchet@51011
   108
val mepoN = "mepo"
blanchet@51011
   109
val mashN = "mash"
blanchet@51011
   110
val meshN = "mesh"
blanchet@51011
   111
blanchet@52073
   112
val tstp_proof_delims =
blanchet@52073
   113
  [("% SZS output start CNFRefutation", "% SZS output end CNFRefutation"),
blanchet@52073
   114
   ("% SZS output start Refutation", "% SZS output end Refutation"),
blanchet@52073
   115
   ("% SZS output start Proof", "% SZS output end Proof")]
blanchet@52073
   116
blanchet@38061
   117
val known_perl_failures =
blanchet@38094
   118
  [(CantConnect, "HTTP error"),
blanchet@38094
   119
   (NoPerl, "env: perl"),
blanchet@38065
   120
   (NoLibwwwPerl, "Can't locate HTTP")]
wenzelm@28596
   121
blanchet@45203
   122
fun known_szs_failures wrap =
blanchet@45203
   123
  [(Unprovable, wrap "CounterSatisfiable"),
blanchet@45203
   124
   (Unprovable, wrap "Satisfiable"),
blanchet@45203
   125
   (GaveUp, wrap "GaveUp"),
blanchet@45203
   126
   (GaveUp, wrap "Unknown"),
blanchet@45203
   127
   (GaveUp, wrap "Incomplete"),
blanchet@45203
   128
   (ProofMissing, wrap "Theorem"),
blanchet@45203
   129
   (ProofMissing, wrap "Unsatisfiable"),
blanchet@45203
   130
   (TimedOut, wrap "Timeout"),
blanchet@45203
   131
   (Inappropriate, wrap "Inappropriate"),
blanchet@45203
   132
   (OutOfResources, wrap "ResourceOut"),
blanchet@45203
   133
   (OutOfResources, wrap "MemoryOut"),
blanchet@45203
   134
   (Interrupted, wrap "Forced"),
blanchet@45203
   135
   (Interrupted, wrap "User")]
blanchet@45203
   136
blanchet@45203
   137
val known_szs_status_failures = known_szs_failures (prefix "SZS status ")
blanchet@45203
   138
val known_says_failures = known_szs_failures (prefix " says ")
blanchet@45203
   139
blanchet@38023
   140
structure Data = Theory_Data
blanchet@38023
   141
(
blanchet@47606
   142
  type T = ((unit -> atp_config) * stamp) Symtab.table
blanchet@38023
   143
  val empty = Symtab.empty
blanchet@38023
   144
  val extend = I
blanchet@46407
   145
  fun merge data : T =
blanchet@46407
   146
    Symtab.merge (eq_snd (op =)) data
blanchet@38023
   147
    handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@38023
   148
)
blanchet@38017
   149
blanchet@43981
   150
fun to_secs min time = Int.max (min, (Time.toMilliseconds time + 999) div 1000)
blanchet@36142
   151
blanchet@43473
   152
val sosN = "sos"
blanchet@43473
   153
val no_sosN = "no_sos"
blanchet@43473
   154
blanchet@44099
   155
val force_sos = Attrib.setup_config_bool @{binding atp_force_sos} (K false)
blanchet@44099
   156
blanchet@47032
   157
val smartN = "smart"
blanchet@47073
   158
(* val kboN = "kbo" *)
blanchet@47032
   159
val lpoN = "lpo"
blanchet@47034
   160
val xweightsN = "_weights"
blanchet@47034
   161
val xprecN = "_prec"
blanchet@47034
   162
val xsimpN = "_simp" (* SPASS-specific *)
blanchet@47032
   163
blanchet@47038
   164
(* Possible values for "atp_term_order":
blanchet@47049
   165
   "smart", "(kbo|lpo)(_weights)?(_prec|_simp)?" *)
blanchet@47032
   166
val term_order =
blanchet@47032
   167
  Attrib.setup_config_string @{binding atp_term_order} (K smartN)
blanchet@47032
   168
blanchet@52073
   169
blanchet@52073
   170
(* agsyHOL *)
blanchet@52073
   171
blanchet@54197
   172
val agsyhol_thf0 = THF (Monomorphic, THF_Without_Choice)
blanchet@52073
   173
blanchet@52073
   174
val agsyhol_config : atp_config =
blanchet@52754
   175
  {exec = K (["AGSYHOL_HOME"], ["agsyHOL"]),
blanchet@52073
   176
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@52073
   177
       "--proof --time-out " ^ string_of_int (to_secs 1 timeout) ^ " " ^
blanchet@52073
   178
       file_name,
blanchet@52073
   179
   proof_delims = tstp_proof_delims,
blanchet@52073
   180
   known_failures = known_szs_status_failures,
blanchet@52073
   181
   prem_role = Hypothesis,
blanchet@52073
   182
   best_slices =
blanchet@52073
   183
     (* FUDGE *)
blanchet@52073
   184
     K [(1.0, (((60, ""), agsyhol_thf0, "mono_native_higher", keep_lamsN, false), ""))],
blanchet@52073
   185
   best_max_mono_iters = default_max_mono_iters - 1 (* FUDGE *),
blanchet@53515
   186
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@52073
   187
blanchet@52073
   188
val agsyhol = (agsyholN, fn () => agsyhol_config)
blanchet@52073
   189
blanchet@52073
   190
blanchet@46643
   191
(* Alt-Ergo *)
blanchet@46643
   192
blanchet@52995
   193
val alt_ergo_tff1 = TFF Polymorphic
blanchet@46643
   194
blanchet@46643
   195
val alt_ergo_config : atp_config =
blanchet@52754
   196
  {exec = K (["WHY3_HOME"], ["why3"]),
blanchet@50927
   197
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@56379
   198
       "--format tptp --prover 'Alt-Ergo,0.95.2,' --timelimit " ^
blanchet@50927
   199
       string_of_int (to_secs 1 timeout) ^ " " ^ file_name,
blanchet@46643
   200
   proof_delims = [],
blanchet@46643
   201
   known_failures =
blanchet@46643
   202
     [(ProofMissing, ": Valid"),
blanchet@46643
   203
      (TimedOut, ": Timeout"),
blanchet@46643
   204
      (GaveUp, ": Unknown")],
blanchet@47976
   205
   prem_role = Hypothesis,
blanchet@46643
   206
   best_slices = fn _ =>
blanchet@46643
   207
     (* FUDGE *)
blanchet@51011
   208
     [(1.0, (((100, ""), alt_ergo_tff1, "poly_native", liftingN, false), ""))],
blanchet@47962
   209
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   210
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@46643
   211
blanchet@47646
   212
val alt_ergo = (alt_ergoN, fn () => alt_ergo_config)
blanchet@46643
   213
blanchet@46643
   214
blanchet@40059
   215
(* E *)
wenzelm@28596
   216
blanchet@51873
   217
fun is_e_at_least_1_3 () = string_ord (getenv "E_VERSION", "1.3") <> LESS
blanchet@51873
   218
fun is_e_at_least_1_6 () = string_ord (getenv "E_VERSION", "1.6") <> LESS
blanchet@52754
   219
fun is_e_at_least_1_8 () = string_ord (getenv "E_VERSION", "1.8") <> LESS
blanchet@44420
   220
blanchet@43473
   221
val e_smartN = "smart"
blanchet@42646
   222
val e_autoN = "auto"
blanchet@42646
   223
val e_fun_weightN = "fun_weight"
blanchet@42646
   224
val e_sym_offset_weightN = "sym_offset_weight"
blanchet@41725
   225
blanchet@47032
   226
val e_selection_heuristic =
blanchet@47032
   227
  Attrib.setup_config_string @{binding atp_e_selection_heuristic} (K e_smartN)
blanchet@41770
   228
(* FUDGE *)
blanchet@42646
   229
val e_default_fun_weight =
blanchet@42646
   230
  Attrib.setup_config_real @{binding atp_e_default_fun_weight} (K 20.0)
blanchet@42646
   231
val e_fun_weight_base =
blanchet@42646
   232
  Attrib.setup_config_real @{binding atp_e_fun_weight_base} (K 0.0)
blanchet@42646
   233
val e_fun_weight_span =
blanchet@42646
   234
  Attrib.setup_config_real @{binding atp_e_fun_weight_span} (K 40.0)
blanchet@42646
   235
val e_default_sym_offs_weight =
blanchet@42646
   236
  Attrib.setup_config_real @{binding atp_e_default_sym_offs_weight} (K 1.0)
blanchet@42646
   237
val e_sym_offs_weight_base =
blanchet@42646
   238
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_base} (K ~20.0)
blanchet@42646
   239
val e_sym_offs_weight_span =
blanchet@42646
   240
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_span} (K 60.0)
blanchet@41725
   241
blanchet@47038
   242
fun e_selection_heuristic_case heuristic fw sow =
blanchet@47038
   243
  if heuristic = e_fun_weightN then fw
blanchet@47038
   244
  else if heuristic = e_sym_offset_weightN then sow
blanchet@47038
   245
  else raise Fail ("unexpected " ^ quote heuristic)
blanchet@41725
   246
blanchet@47038
   247
fun scaled_e_selection_weight ctxt heuristic w =
blanchet@47038
   248
  w * Config.get ctxt (e_selection_heuristic_case heuristic
blanchet@47029
   249
                           e_fun_weight_span e_sym_offs_weight_span)
blanchet@47038
   250
  + Config.get ctxt (e_selection_heuristic_case heuristic
blanchet@47029
   251
                         e_fun_weight_base e_sym_offs_weight_base)
blanchet@41725
   252
  |> Real.ceil |> signed_string_of_int
blanchet@41313
   253
blanchet@47038
   254
fun e_selection_weight_arguments ctxt heuristic sel_weights =
blanchet@51631
   255
  if heuristic = e_fun_weightN orelse heuristic = e_sym_offset_weightN then
blanchet@43622
   256
    (* supplied by Stephan Schulz *)
blanchet@41314
   257
    "--split-clauses=4 --split-reuse-defs --simul-paramod --forward-context-sr \
blanchet@41314
   258
    \--destructive-er-aggressive --destructive-er --presat-simplify \
blanchet@47505
   259
    \--prefer-initial-clauses -winvfreqrank -c1 -Ginvfreqconjmax -F1 \
blanchet@47505
   260
    \--delete-bad-limit=150000000 -WSelectMaxLComplexAvoidPosPred -H'(4*" ^
blanchet@47038
   261
    e_selection_heuristic_case heuristic "FunWeight" "SymOffsetWeight" ^
blanchet@48376
   262
    "(SimulateSOS," ^
blanchet@47038
   263
    (e_selection_heuristic_case heuristic
blanchet@47029
   264
         e_default_fun_weight e_default_sym_offs_weight
blanchet@42646
   265
     |> Config.get ctxt |> Real.ceil |> signed_string_of_int) ^
blanchet@41314
   266
    ",20,1.5,1.5,1" ^
blanchet@47030
   267
    (sel_weights ()
blanchet@47029
   268
     |> map (fn (s, w) => "," ^ s ^ ":" ^
blanchet@47038
   269
                          scaled_e_selection_weight ctxt heuristic w)
blanchet@42646
   270
     |> implode) ^
blanchet@41314
   271
    "),3*ConjectureGeneralSymbolWeight(PreferNonGoals,200,100,200,50,50,1,100,\
blanchet@41314
   272
    \1.5,1.5,1),1*Clauseweight(PreferProcessed,1,1,1),1*\
blanchet@41314
   273
    \FIFOWeight(PreferProcessed))'"
blanchet@51631
   274
  else
blanchet@51631
   275
    "-xAuto"
blanchet@41313
   276
blanchet@47038
   277
val e_ord_weights =
blanchet@47038
   278
  map (fn (s, w) => s ^ ":" ^ string_of_int w) #> space_implode ","
blanchet@47038
   279
fun e_ord_precedence [_] = ""
blanchet@47038
   280
  | e_ord_precedence info = info |> map fst |> space_implode "<"
blanchet@47038
   281
blanchet@47039
   282
fun e_term_order_info_arguments false false _ = ""
blanchet@47039
   283
  | e_term_order_info_arguments gen_weights gen_prec ord_info =
blanchet@47038
   284
    let val ord_info = ord_info () in
blanchet@47038
   285
      (if gen_weights then "--order-weights='" ^ e_ord_weights ord_info ^ "' "
blanchet@47038
   286
       else "") ^
blanchet@47038
   287
      (if gen_prec then "--precedence='" ^ e_ord_precedence ord_info ^ "' "
blanchet@47038
   288
       else "")
blanchet@47038
   289
    end
blanchet@47038
   290
blanchet@47032
   291
fun effective_e_selection_heuristic ctxt =
blanchet@48653
   292
  if is_e_at_least_1_3 () then Config.get ctxt e_selection_heuristic
blanchet@48232
   293
  else e_autoN
blanchet@42443
   294
blanchet@48653
   295
fun e_kbo () = if is_e_at_least_1_3 () then "KBO6" else "KBO"
blanchet@47505
   296
blanchet@40059
   297
val e_config : atp_config =
blanchet@52754
   298
  {exec = (fn () => (["E_HOME"],
blanchet@57008
   299
     if is_e_at_least_1_8 () then ["eprover"] else ["eproof_ram", "eproof"])),
blanchet@57008
   300
   arguments = fn ctxt => fn full_proof => fn heuristic => fn timeout => fn file_name =>
blanchet@57008
   301
     fn ({is_lpo, gen_weights, gen_prec, ...}, ord_info, sel_weights) =>
blanchet@57008
   302
       (if is_e_at_least_1_8 () then "--auto-schedule " else "") ^
blanchet@52754
   303
       "--tstp-in --tstp-out --silent " ^
blanchet@48651
   304
       e_selection_weight_arguments ctxt heuristic sel_weights ^ " " ^
blanchet@48651
   305
       e_term_order_info_arguments gen_weights gen_prec ord_info ^ " " ^
blanchet@48651
   306
       "--term-ordering=" ^ (if is_lpo then "LPO4" else e_kbo ()) ^ " " ^
blanchet@48651
   307
       "--cpu-limit=" ^ string_of_int (to_secs 2 timeout) ^
blanchet@52754
   308
       (if is_e_at_least_1_8 () then
blanchet@52754
   309
          " --proof-object=1"
blanchet@52754
   310
        else
blanchet@52754
   311
          " --output-level=5" ^
blanchet@57008
   312
          (if is_e_at_least_1_6 () then " --pcl-shell-level=" ^ (if full_proof then "0" else "2")
blanchet@57008
   313
           else "")) ^
blanchet@52754
   314
       " " ^ file_name,
blanchet@52073
   315
   proof_delims =
blanchet@52073
   316
     [("# SZS output start CNFRefutation", "# SZS output end CNFRefutation")] @
blanchet@52073
   317
     tstp_proof_delims,
blanchet@36265
   318
   known_failures =
blanchet@45203
   319
     [(TimedOut, "Failure: Resource limit exceeded (time)"),
blanchet@47972
   320
      (TimedOut, "time limit exceeded")] @
blanchet@47972
   321
     known_szs_status_failures,
blanchet@47976
   322
   prem_role = Conjecture,
blanchet@42646
   323
   best_slices = fn ctxt =>
blanchet@47038
   324
     let val heuristic = effective_e_selection_heuristic ctxt in
blanchet@43474
   325
       (* FUDGE *)
blanchet@47038
   326
       if heuristic = e_smartN then
blanchet@51017
   327
         [(0.15, (((128, meshN), FOF, "mono_tags??", combsN, false), e_fun_weightN)),
blanchet@51017
   328
          (0.15, (((128, mashN), FOF, "mono_guards??", combsN, false), e_sym_offset_weightN)),
blanchet@51017
   329
          (0.15, (((91, mepoN), FOF, "mono_tags??", combsN, false), e_autoN)),
blanchet@51017
   330
          (0.15, (((1000, meshN), FOF, "poly_guards??", combsN, false), e_sym_offset_weightN)),
blanchet@51214
   331
          (0.15, (((256, mepoN), FOF, "mono_tags??", liftingN, false), e_fun_weightN)),
blanchet@51214
   332
          (0.25, (((64, mashN), FOF, "mono_guards??", combsN, false), e_fun_weightN))]
blanchet@43473
   333
       else
blanchet@51011
   334
         [(1.0, (((500, ""), FOF, "mono_tags??", combsN, false), heuristic))]
blanchet@47962
   335
     end,
blanchet@47962
   336
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   337
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@38454
   338
blanchet@47646
   339
val e = (eN, fn () => e_config)
wenzelm@28596
   340
wenzelm@28596
   341
blanchet@48651
   342
(* E-MaLeS *)
blanchet@48651
   343
blanchet@48651
   344
val e_males_config : atp_config =
blanchet@52754
   345
  {exec = K (["E_MALES_HOME"], ["emales.py"]),
blanchet@50927
   346
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@50927
   347
       "-t " ^ string_of_int (to_secs 1 timeout) ^ " -p " ^ file_name,
blanchet@48651
   348
   proof_delims = tstp_proof_delims,
blanchet@48651
   349
   known_failures = #known_failures e_config,
blanchet@48651
   350
   prem_role = Conjecture,
blanchet@48651
   351
   best_slices =
blanchet@48651
   352
     (* FUDGE *)
blanchet@51018
   353
     K [(0.25, (((500, meshN), FOF, "mono_guards??", combs_or_liftingN, false), "")),
blanchet@51018
   354
        (0.25, (((150, meshN), FOF, "poly_tags??", combs_or_liftingN, false), "")),
blanchet@51018
   355
        (0.25, (((50, meshN), FOF, "mono_tags??", combs_or_liftingN, false), "")),
blanchet@51018
   356
        (0.25, (((1000, meshN), FOF, "poly_guards??", combsN, false), ""))],
blanchet@48651
   357
   best_max_mono_iters = default_max_mono_iters,
blanchet@48651
   358
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@48651
   359
blanchet@48651
   360
val e_males = (e_malesN, fn () => e_males_config)
blanchet@48651
   361
blanchet@48651
   362
blanchet@50927
   363
(* E-Par *)
blanchet@50927
   364
blanchet@50927
   365
val e_par_config : atp_config =
blanchet@52754
   366
  {exec = K (["E_HOME"], ["runepar.pl"]),
blanchet@50927
   367
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@50927
   368
       string_of_int (to_secs 1 timeout) ^ " 1 " (* SInE *) ^ file_name ^
blanchet@50927
   369
       " 2" (* proofs *),
blanchet@50927
   370
   proof_delims = tstp_proof_delims,
blanchet@50927
   371
   known_failures = #known_failures e_config,
blanchet@50927
   372
   prem_role = Conjecture,
blanchet@50927
   373
   best_slices = #best_slices e_males_config,
blanchet@50927
   374
   best_max_mono_iters = default_max_mono_iters,
blanchet@50927
   375
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@50927
   376
blanchet@50927
   377
val e_par = (e_parN, fn () => e_par_config)
blanchet@50927
   378
blanchet@50927
   379
blanchet@48700
   380
(* iProver *)
blanchet@48700
   381
blanchet@48700
   382
val iprover_config : atp_config =
blanchet@52754
   383
  {exec = K (["IPROVER_HOME"], ["iprover"]),
blanchet@50927
   384
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@48720
   385
       "--clausifier \"$IPROVER_HOME\"/vclausify_rel --time_out_real " ^
blanchet@50927
   386
       string_of_real (Time.toReal timeout) ^ " " ^ file_name,
blanchet@48700
   387
   proof_delims = tstp_proof_delims,
blanchet@48700
   388
   known_failures =
blanchet@48700
   389
     [(ProofIncomplete, "% SZS output start CNFRefutation")] @
blanchet@48700
   390
     known_szs_status_failures,
blanchet@48700
   391
   prem_role = Hypothesis,
blanchet@48700
   392
   best_slices =
blanchet@48700
   393
     (* FUDGE *)
blanchet@51011
   394
     K [(1.0, (((150, ""), FOF, "mono_guards??", liftingN, false), ""))],
blanchet@48700
   395
   best_max_mono_iters = default_max_mono_iters,
blanchet@48700
   396
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@48700
   397
blanchet@48700
   398
val iprover = (iproverN, fn () => iprover_config)
blanchet@48700
   399
blanchet@48700
   400
blanchet@48700
   401
(* iProver-Eq *)
blanchet@48700
   402
blanchet@48700
   403
val iprover_eq_config : atp_config =
blanchet@52754
   404
  {exec = K (["IPROVER_EQ_HOME"], ["iprover-eq"]),
blanchet@48700
   405
   arguments = #arguments iprover_config,
blanchet@48700
   406
   proof_delims = #proof_delims iprover_config,
blanchet@48700
   407
   known_failures = #known_failures iprover_config,
blanchet@48700
   408
   prem_role = #prem_role iprover_config,
blanchet@48700
   409
   best_slices = #best_slices iprover_config,
blanchet@48700
   410
   best_max_mono_iters = #best_max_mono_iters iprover_config,
blanchet@48700
   411
   best_max_new_mono_instances = #best_max_new_mono_instances iprover_config}
blanchet@48700
   412
blanchet@48700
   413
val iprover_eq = (iprover_eqN, fn () => iprover_eq_config)
blanchet@48700
   414
blanchet@48700
   415
blanchet@44099
   416
(* LEO-II *)
blanchet@44099
   417
blanchet@48004
   418
(* LEO-II supports definitions, but it performs significantly better on our
blanchet@48004
   419
   benchmarks when they are not used. *)
blanchet@54197
   420
val leo2_thf0 = THF (Monomorphic, THF_Without_Choice)
blanchet@44754
   421
blanchet@44099
   422
val leo2_config : atp_config =
blanchet@52754
   423
  {exec = K (["LEO2_HOME"], ["leo.opt", "leo"]),
blanchet@50927
   424
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@48651
   425
       "--foatp e --atp e=\"$E_HOME\"/eprover \
blanchet@48651
   426
       \--atp epclextract=\"$E_HOME\"/epclextract \
blanchet@50927
   427
       \--proofoutput 1 --timeout " ^ string_of_int (to_secs 1 timeout) ^ " " ^
blanchet@50927
   428
       file_name,
blanchet@44099
   429
   proof_delims = tstp_proof_delims,
blanchet@45207
   430
   known_failures =
blanchet@47974
   431
     [(TimedOut, "CPU time limit exceeded, terminating"),
blanchet@47972
   432
      (GaveUp, "No.of.Axioms")] @
blanchet@47972
   433
     known_szs_status_failures,
blanchet@47976
   434
   prem_role = Hypothesis,
blanchet@47914
   435
   best_slices =
blanchet@44099
   436
     (* FUDGE *)
blanchet@51011
   437
     K [(1.0, (((40, ""), leo2_thf0, "mono_native_higher", keep_lamsN, false), ""))],
blanchet@47962
   438
   best_max_mono_iters = default_max_mono_iters - 1 (* FUDGE *),
blanchet@53515
   439
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@39491
   440
blanchet@47646
   441
val leo2 = (leo2N, fn () => leo2_config)
blanchet@44099
   442
blanchet@44099
   443
blanchet@44099
   444
(* Satallax *)
blanchet@44099
   445
blanchet@52097
   446
(* Choice is disabled until there is proper reconstruction for it. *)
blanchet@54197
   447
val satallax_thf0 = THF (Monomorphic, THF_Without_Choice)
blanchet@44754
   448
blanchet@44099
   449
val satallax_config : atp_config =
blanchet@52754
   450
  {exec = K (["SATALLAX_HOME"], ["satallax.opt", "satallax"]),
blanchet@50927
   451
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@50927
   452
       "-p hocore -t " ^ string_of_int (to_secs 1 timeout) ^ " " ^ file_name,
blanchet@45162
   453
   proof_delims =
blanchet@45162
   454
     [("% Higher-Order Unsat Core BEGIN", "% Higher-Order Unsat Core END")],
blanchet@45203
   455
   known_failures = known_szs_status_failures,
blanchet@47981
   456
   prem_role = Hypothesis,
blanchet@44416
   457
   best_slices =
blanchet@44754
   458
     (* FUDGE *)
blanchet@51011
   459
     K [(1.0, (((60, ""), satallax_thf0, "mono_native_higher", keep_lamsN, false), ""))],
blanchet@47962
   460
   best_max_mono_iters = default_max_mono_iters - 1 (* FUDGE *),
blanchet@53515
   461
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@44099
   462
blanchet@47646
   463
val satallax = (satallaxN, fn () => satallax_config)
blanchet@44099
   464
blanchet@44099
   465
blanchet@44099
   466
(* SPASS *)
blanchet@42725
   467
blanchet@48005
   468
val spass_H1SOS = "-Heuristic=1 -SOS"
blanchet@50333
   469
val spass_H2 = "-Heuristic=2"
blanchet@48005
   470
val spass_H2LR0LT0 = "-Heuristic=2 -LR=0 -LT=0"
blanchet@48005
   471
val spass_H2NuVS0 = "-Heuristic=2 -RNuV=1 -Sorts=0"
blanchet@48005
   472
val spass_H2NuVS0Red2 = "-Heuristic=2 -RNuV=1 -Sorts=0 -RFRew=2 -RBRew=2 -RTaut=2"
blanchet@50333
   473
val spass_H2SOS = "-Heuristic=2 -SOS"
blanchet@47055
   474
blanchet@50950
   475
val spass_extra_options =
blanchet@50950
   476
  Attrib.setup_config_string @{binding atp_spass_extra_options} (K "")
blanchet@50950
   477
blanchet@48005
   478
(* FIXME: Make "SPASS_NEW_HOME" legacy. *)
blanchet@48005
   479
val spass_config : atp_config =
blanchet@52754
   480
  {exec = K (["SPASS_NEW_HOME", "SPASS_HOME"], ["SPASS"]),
blanchet@52151
   481
   arguments = fn _ => fn full_proofs => fn extra_options => fn timeout =>
blanchet@52151
   482
       fn file_name => fn _ =>
blanchet@52151
   483
       "-Isabelle=1 " ^ (if full_proofs then "-Splits=0 " else "") ^
blanchet@52151
   484
       "-TimeLimit=" ^ string_of_int (to_secs 1 timeout) ^ " " ^ file_name
blanchet@52151
   485
       |> extra_options <> "" ? prefix (extra_options ^ " "),
blanchet@36369
   486
   proof_delims = [("Here is a proof", "Formulae used in the proof")],
blanchet@36289
   487
   known_failures =
blanchet@53225
   488
     [(GaveUp, "SPASS beiseite: Completion found"),
blanchet@36370
   489
      (TimedOut, "SPASS beiseite: Ran out of time"),
blanchet@36965
   490
      (OutOfResources, "SPASS beiseite: Maximal number of loops exceeded"),
blanchet@37413
   491
      (MalformedInput, "Undefined symbol"),
blanchet@37414
   492
      (MalformedInput, "Free Variable"),
blanchet@44391
   493
      (Unprovable, "No formulae and clauses found in input file"),
blanchet@47972
   494
      (InternalError, "Please report this error")] @
blanchet@47972
   495
      known_perl_failures,
blanchet@47976
   496
   prem_role = Conjecture,
blanchet@50950
   497
   best_slices = fn ctxt =>
blanchet@42723
   498
     (* FUDGE *)
blanchet@51016
   499
     [(0.1667, (((150, meshN), DFG Monomorphic, "mono_native", combsN, true), "")),
blanchet@51016
   500
      (0.1667, (((500, meshN), DFG Monomorphic, "mono_native", liftingN, true), spass_H2SOS)),
blanchet@51016
   501
      (0.1666, (((50, meshN), DFG Monomorphic,  "mono_native", liftingN, true), spass_H2LR0LT0)),
blanchet@51016
   502
      (0.1000, (((250, meshN), DFG Monomorphic, "mono_native", combsN, true), spass_H2NuVS0)),
blanchet@51016
   503
      (0.1000, (((1000, mepoN), DFG Monomorphic, "mono_native", liftingN, true), spass_H1SOS)),
blanchet@51016
   504
      (0.1000, (((150, meshN), DFG Monomorphic, "poly_guards??", liftingN, false), spass_H2NuVS0Red2)),
blanchet@51016
   505
      (0.1000, (((300, meshN), DFG Monomorphic, "mono_native", combsN, true), spass_H2SOS)),
blanchet@51016
   506
      (0.1000, (((100, meshN), DFG Monomorphic, "mono_native", combs_and_liftingN, true), spass_H2))]
blanchet@50950
   507
     |> (case Config.get ctxt spass_extra_options of
blanchet@50950
   508
           "" => I
blanchet@50950
   509
         | opts => map (apsnd (apsnd (K opts)))),
blanchet@47962
   510
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   511
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@38454
   512
blanchet@48005
   513
val spass = (spassN, fn () => spass_config)
blanchet@38454
   514
blanchet@52073
   515
blanchet@37509
   516
(* Vampire *)
blanchet@37509
   517
blanchet@56380
   518
(* Vampire 1.8 has TFF0 support, but the support was buggy until revision
blanchet@48007
   519
   1435 (or shortly before). *)
blanchet@51873
   520
fun is_vampire_at_least_1_8 () = string_ord (getenv "VAMPIRE_VERSION", "1.8") <> LESS
blanchet@51873
   521
fun is_vampire_beyond_1_8 () = string_ord (getenv "VAMPIRE_VERSION", "1.8") = GREATER
blanchet@44420
   522
blanchet@52995
   523
val vampire_tff0 = TFF Monomorphic
blanchet@44589
   524
blanchet@40059
   525
val vampire_config : atp_config =
blanchet@52754
   526
  {exec = K (["VAMPIRE_HOME"], ["vampire"]),
blanchet@51872
   527
   arguments = fn _ => fn full_proof => fn sos => fn timeout => fn file_name =>
blanchet@51872
   528
       fn _ =>
blanchet@48651
   529
       "--mode casc -t " ^ string_of_int (to_secs 1 timeout) ^
blanchet@48653
   530
       " --proof tptp --output_axiom_names on" ^
blanchet@48653
   531
       (if is_vampire_at_least_1_8 () then
blanchet@51196
   532
          (* Cf. p. 20 of http://www.complang.tuwien.ac.at/lkovacs/Cade23_Tutorial_Slides/Session2_Slides.pdf *)
blanchet@51872
   533
          (if full_proof then
blanchet@56848
   534
             " --forced_options splitting=off:equality_proxy=off:general_splitting=off\
blanchet@51872
   535
             \:inequality_splitting=0:naming=0"
blanchet@51872
   536
           else
blanchet@51872
   537
             "")
blanchet@48653
   538
        else
blanchet@48653
   539
          "") ^
blanchet@50927
   540
       " --thanks \"Andrei and Krystof\" --input_file " ^ file_name
blanchet@48651
   541
       |> sos = sosN ? prefix "--sos on ",
blanchet@37509
   542
   proof_delims =
blanchet@37509
   543
     [("=========== Refutation ==========",
blanchet@52073
   544
       "======= End of refutation =======")] @
blanchet@52073
   545
     tstp_proof_delims,
blanchet@37509
   546
   known_failures =
blanchet@43050
   547
     [(GaveUp, "UNPROVABLE"),
blanchet@43050
   548
      (GaveUp, "CANNOT PROVE"),
blanchet@37509
   549
      (Unprovable, "Satisfiability detected"),
blanchet@38647
   550
      (Unprovable, "Termination reason: Satisfiable"),
blanchet@47972
   551
      (Interrupted, "Aborted by signal SIGINT")] @
blanchet@47972
   552
     known_szs_status_failures,
blanchet@47976
   553
   prem_role = Conjecture,
blanchet@42725
   554
   best_slices = fn ctxt =>
blanchet@42723
   555
     (* FUDGE *)
blanchet@48653
   556
     (if is_vampire_beyond_1_8 () then
blanchet@51016
   557
        [(0.333, (((500, meshN), vampire_tff0, "mono_guards??", combs_or_liftingN, false), sosN)),
blanchet@51016
   558
         (0.333, (((150, meshN), vampire_tff0, "poly_tags??", combs_or_liftingN, false), sosN)),
blanchet@51017
   559
         (0.334, (((50, meshN), vampire_tff0, "mono_native", combs_or_liftingN, false), no_sosN))]
blanchet@47055
   560
      else
blanchet@51016
   561
        [(0.333, (((150, meshN), FOF, "poly_guards??", combs_or_liftingN, false), sosN)),
blanchet@51011
   562
         (0.333, (((500, meshN), FOF, "mono_tags??", combs_or_liftingN, false), sosN)),
blanchet@51016
   563
         (0.334, (((50, meshN), FOF, "mono_guards??", combs_or_liftingN, false), no_sosN))])
blanchet@44099
   564
     |> (if Config.get ctxt force_sos then hd #> apfst (K 1.0) #> single
blanchet@47962
   565
         else I),
blanchet@47962
   566
   best_max_mono_iters = default_max_mono_iters,
blanchet@53515
   567
   best_max_new_mono_instances = 2 * default_max_new_mono_instances (* FUDGE *)}
blanchet@38454
   568
blanchet@47646
   569
val vampire = (vampireN, fn () => vampire_config)
blanchet@37509
   570
blanchet@48803
   571
(* Z3 with TPTP syntax (half experimental, half legacy) *)
blanchet@41740
   572
blanchet@52995
   573
val z3_tff0 = TFF Monomorphic
blanchet@44589
   574
blanchet@44423
   575
val z3_tptp_config : atp_config =
blanchet@56378
   576
  {exec = K (["Z3_TPTP_HOME"], ["z3_tptp"]),
blanchet@50927
   577
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@57261
   578
     "-proof -t:" ^ string_of_int (to_secs 1 timeout) ^ " -file:" ^ file_name,
blanchet@56397
   579
   proof_delims = [("SZS status Theorem", "")],
blanchet@45203
   580
   known_failures = known_szs_status_failures,
blanchet@47976
   581
   prem_role = Hypothesis,
blanchet@42723
   582
   best_slices =
blanchet@44423
   583
     (* FUDGE *)
blanchet@51011
   584
     K [(0.5, (((250, meshN), z3_tff0, "mono_native", combsN, false), "")),
blanchet@51011
   585
        (0.25, (((125, mepoN), z3_tff0, "mono_native", combsN, false), "")),
blanchet@51011
   586
        (0.125, (((62, mashN), z3_tff0, "mono_native", combsN, false), "")),
blanchet@51011
   587
        (0.125, (((31, meshN), z3_tff0, "mono_native", combsN, false), ""))],
blanchet@47962
   588
   best_max_mono_iters = default_max_mono_iters,
blanchet@53515
   589
   best_max_new_mono_instances = 2 * default_max_new_mono_instances (* FUDGE *)}
blanchet@41740
   590
blanchet@47646
   591
val z3_tptp = (z3_tptpN, fn () => z3_tptp_config)
blanchet@41740
   592
blanchet@44590
   593
fleury@57154
   594
(* Zipperposition*)
fleury@57154
   595
fleury@57154
   596
val zipperposition_tff1 = TFF Polymorphic
fleury@57154
   597
fleury@57154
   598
val zipperposition_config : atp_config =
fleury@57154
   599
  {exec = K (["ZIPPERPOSITION_HOME"], ["zipperposition"]),
fleury@57154
   600
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
fleury@57154
   601
       "-print none -proof tstp -print-types -timeout " ^
fleury@57154
   602
       string_of_int (to_secs 1 timeout) ^ " " ^ file_name,
fleury@57154
   603
   proof_delims = tstp_proof_delims,
fleury@57154
   604
   known_failures = known_szs_status_failures,
fleury@57154
   605
   prem_role = Hypothesis,
fleury@57154
   606
   best_slices = fn _ =>
fleury@57154
   607
     (* FUDGE *)
fleury@57154
   608
     [(1.0, (((100, ""), alt_ergo_tff1, "poly_native", liftingN, false), ""))],
fleury@57154
   609
   best_max_mono_iters = default_max_mono_iters,
fleury@57154
   610
   best_max_new_mono_instances = default_max_new_mono_instances}
fleury@57154
   611
fleury@57154
   612
val zipperposition = (zipperpositionN, fn () => zipperposition_config)
fleury@57154
   613
fleury@57154
   614
blanchet@48131
   615
(* Not really a prover: Experimental Polymorphic THF and DFG output *)
blanchet@44590
   616
blanchet@51919
   617
fun dummy_config prem_role format type_enc uncurried_aliases : atp_config =
blanchet@52754
   618
  {exec = K (["ISABELLE_ATP"], ["scripts/dummy_atp"]),
blanchet@50927
   619
   arguments = K (K (K (K (K (K ""))))),
blanchet@44590
   620
   proof_delims = [],
blanchet@45203
   621
   known_failures = known_szs_status_failures,
blanchet@51467
   622
   prem_role = prem_role,
blanchet@45521
   623
   best_slices =
blanchet@51011
   624
     K [(1.0, (((200, ""), format, type_enc,
blanchet@48716
   625
                if is_format_higher_order format then keep_lamsN
blanchet@51919
   626
                else combsN, uncurried_aliases), ""))],
blanchet@47962
   627
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   628
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@44590
   629
blanchet@54197
   630
val dummy_thf_format = THF (Polymorphic, THF_With_Choice)
blanchet@54788
   631
val dummy_thf_config = dummy_config Hypothesis dummy_thf_format "poly_native_higher" false
blanchet@47646
   632
val dummy_thf = (dummy_thfN, fn () => dummy_thf_config)
blanchet@44754
   633
blanchet@54788
   634
val spass_pirate_format = DFG Polymorphic
blanchet@54802
   635
val remote_spass_pirate_config : atp_config =
blanchet@54788
   636
  {exec = K (["ISABELLE_ATP"], ["scripts/remote_spass_pirate"]),
blanchet@54788
   637
   arguments = fn _ => fn _ => fn _ => fn timeout => fn file_name => fn _ =>
blanchet@54788
   638
     string_of_int (to_secs 1 timeout) ^ " " ^ file_name,
blanchet@54788
   639
   proof_delims = [("Involved clauses:", "Involved clauses:")],
blanchet@54788
   640
   known_failures = known_szs_status_failures,
blanchet@54788
   641
   prem_role = #prem_role spass_config,
blanchet@54788
   642
   best_slices = K [(1.0, (((200, ""), spass_pirate_format, "tc_native", combsN, true), ""))],
blanchet@54788
   643
   best_max_mono_iters = default_max_mono_iters,
blanchet@54788
   644
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@54788
   645
val remote_spass_pirate = (remote_prefix ^ spass_pirateN, fn () => remote_spass_pirate_config)
blanchet@41740
   646
blanchet@52073
   647
blanchet@40059
   648
(* Remote ATP invocation via SystemOnTPTP *)
wenzelm@28596
   649
blanchet@49984
   650
val remote_systems = Synchronized.var "atp_remote_systems" ([] : string list)
immler@31835
   651
blanchet@49984
   652
fun get_remote_systems () =
blanchet@49987
   653
  TimeLimit.timeLimit (seconds 10.0)
blanchet@49987
   654
    (fn () =>
blanchet@49987
   655
        case Isabelle_System.bash_output
blanchet@49987
   656
            "\"$ISABELLE_ATP/scripts/remote_atp\" -w 2>&1" of
blanchet@49987
   657
          (output, 0) => split_lines output
blanchet@49987
   658
        | (output, _) =>
blanchet@53586
   659
          (warning (case extract_known_atp_failure known_perl_failures output of
blanchet@53586
   660
                      SOME failure => string_of_atp_failure failure
blanchet@49987
   661
                    | NONE => trim_line output ^ "."); [])) ()
blanchet@49991
   662
  handle TimeLimit.TimeOut => []
immler@31835
   663
blanchet@49984
   664
fun find_remote_system name [] systems =
blanchet@42537
   665
    find_first (String.isPrefix (name ^ "---")) systems
blanchet@49984
   666
  | find_remote_system name (version :: versions) systems =
blanchet@38690
   667
    case find_first (String.isPrefix (name ^ "---" ^ version)) systems of
blanchet@49984
   668
      NONE => find_remote_system name versions systems
blanchet@38690
   669
    | res => res
blanchet@38690
   670
blanchet@49984
   671
fun get_remote_system name versions =
blanchet@49984
   672
  Synchronized.change_result remote_systems
blanchet@49984
   673
      (fn systems => (if null systems then get_remote_systems () else systems)
blanchet@49984
   674
                     |> `(`(find_remote_system name versions)))
boehmes@32864
   675
blanchet@49984
   676
fun the_remote_system name versions =
blanchet@54788
   677
  (case get_remote_system name versions of
blanchet@42955
   678
    (SOME sys, _) => sys
blanchet@54788
   679
  | (NONE, []) => error "SystemOnTPTP is not available."
blanchet@42955
   680
  | (NONE, syss) =>
blanchet@54788
   681
    (case syss |> filter_out (String.isPrefix "%") |> filter_out (curry (op =) "") of
blanchet@54788
   682
      [] => error "SystemOnTPTP is currently not available."
blanchet@49990
   683
    | [msg] => error ("SystemOnTPTP is currently not available: " ^ msg ^ ".")
blanchet@46480
   684
    | syss =>
blanchet@54788
   685
      error ("System " ^ quote name ^ " is not available at SystemOnTPTP.\n(Available systems: " ^
blanchet@54788
   686
        commas_quote syss ^ ".)")))
immler@31835
   687
blanchet@41148
   688
val max_remote_secs = 240 (* give Geoff Sutcliffe's servers a break *)
blanchet@41148
   689
blanchet@38690
   690
fun remote_config system_name system_versions proof_delims known_failures
blanchet@47976
   691
                  prem_role best_slice : atp_config =
blanchet@52754
   692
  {exec = K (["ISABELLE_ATP"], ["scripts/remote_atp"]),
blanchet@54788
   693
   arguments = fn _ => fn _ => fn command => fn timeout => fn file_name => fn _ =>
blanchet@54788
   694
     (if command <> "" then "-c " ^ quote command ^ " " else "") ^
blanchet@54788
   695
     "-s " ^ the_remote_system system_name system_versions ^ " " ^
blanchet@54788
   696
     "-t " ^ string_of_int (Int.min (max_remote_secs, to_secs 1 timeout)) ^
blanchet@54788
   697
     " " ^ file_name,
blanchet@42962
   698
   proof_delims = union (op =) tstp_proof_delims proof_delims,
blanchet@45203
   699
   known_failures = known_failures @ known_perl_failures @ known_says_failures,
blanchet@47976
   700
   prem_role = prem_role,
blanchet@48716
   701
   best_slices = fn ctxt => [(1.0, best_slice ctxt)],
blanchet@47962
   702
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   703
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@42443
   704
blanchet@43500
   705
fun remotify_config system_name system_versions best_slice
blanchet@47976
   706
        ({proof_delims, known_failures, prem_role, ...} : atp_config)
blanchet@47912
   707
        : atp_config =
blanchet@38690
   708
  remote_config system_name system_versions proof_delims known_failures
blanchet@47976
   709
                prem_role best_slice
blanchet@38023
   710
blanchet@40059
   711
fun remote_atp name system_name system_versions proof_delims known_failures
blanchet@47976
   712
               prem_role best_slice =
blanchet@40060
   713
  (remote_prefix ^ name,
blanchet@47912
   714
   fn () => remote_config system_name system_versions proof_delims
blanchet@47976
   715
                          known_failures prem_role best_slice)
blanchet@43500
   716
fun remotify_atp (name, config) system_name system_versions best_slice =
blanchet@43500
   717
  (remote_prefix ^ name,
blanchet@47606
   718
   remotify_config system_name system_versions best_slice o config)
wenzelm@28592
   719
blanchet@57264
   720
fun gen_remote_waldmeister name =
blanchet@57265
   721
  remote_atp name "Waldmeister" ["710"] tstp_proof_delims
blanchet@57265
   722
    ([(OutOfResources, "Too many function symbols"),
blanchet@57265
   723
      (Inappropriate, "****  Unexpected end of file."),
blanchet@57265
   724
      (Crashed, "Unrecoverable Segmentation Fault")]
blanchet@57265
   725
     @ known_szs_status_failures)
blanchet@57264
   726
    Hypothesis
blanchet@57264
   727
    (K (((50, ""), CNF_UEQ, "raw_mono_tags??", combsN, false), "") (* FUDGE *))
blanchet@57264
   728
blanchet@52995
   729
val explicit_tff0 = TFF Monomorphic
blanchet@44589
   730
blanchet@52094
   731
val remote_agsyhol =
blanchet@52094
   732
  remotify_atp agsyhol "agsyHOL" ["1.0", "1"]
blanchet@52094
   733
      (K (((60, ""), agsyhol_thf0, "mono_native_higher", keep_lamsN, false), "") (* FUDGE *))
blanchet@43500
   734
val remote_e =
blanchet@52094
   735
  remotify_atp e "EP" ["1.7", "1.6", "1.5", "1"]
blanchet@51011
   736
      (K (((750, ""), FOF, "mono_tags??", combsN, false), "") (* FUDGE *))
blanchet@48700
   737
val remote_iprover =
blanchet@52094
   738
  remotify_atp iprover "iProver" ["0.99"]
blanchet@51011
   739
      (K (((150, ""), FOF, "mono_guards??", liftingN, false), "") (* FUDGE *))
blanchet@48700
   740
val remote_iprover_eq =
blanchet@52094
   741
  remotify_atp iprover_eq "iProver-Eq" ["0.8"]
blanchet@51011
   742
      (K (((150, ""), FOF, "mono_guards??", liftingN, false), "") (* FUDGE *))
blanchet@44099
   743
val remote_leo2 =
blanchet@52094
   744
  remotify_atp leo2 "LEO-II" ["1.5.0", "1.4", "1.3", "1.2", "1"]
blanchet@52094
   745
      (K (((40, ""), leo2_thf0, "mono_native_higher", liftingN, false), "") (* FUDGE *))
blanchet@44099
   746
val remote_satallax =
blanchet@52094
   747
  remotify_atp satallax "Satallax" ["2.7", "2.3", "2"]
blanchet@52094
   748
      (K (((60, ""), satallax_thf0, "mono_native_higher", keep_lamsN, false), "") (* FUDGE *))
blanchet@43500
   749
val remote_vampire =
blanchet@52995
   750
  remotify_atp vampire "Vampire" ["3.0", "2.6", "2.5", "1.8"]
blanchet@51011
   751
      (K (((250, ""), vampire_tff0, "mono_native", combs_or_liftingN, false), "") (* FUDGE *))
blanchet@44092
   752
val remote_e_sine =
blanchet@47912
   753
  remote_atp e_sineN "SInE" ["0.4"] [] (#known_failures e_config) Conjecture
blanchet@51011
   754
      (K (((500, ""), FOF, "mono_guards??", combsN, false), "") (* FUDGE *))
blanchet@41740
   755
val remote_snark =
blanchet@52094
   756
  remote_atp snarkN "SNARK" ["20120808r022", "20080805r029", "20080805r024"]
blanchet@47912
   757
      [("refutation.", "end_refutation.")] [] Hypothesis
blanchet@51011
   758
      (K (((100, ""), explicit_tff0, "mono_native", liftingN, false), "") (* FUDGE *))
blanchet@44092
   759
val remote_e_tofof =
blanchet@47912
   760
  remote_atp e_tofofN "ToFoF" ["0.1"] [] (#known_failures e_config) Hypothesis
blanchet@51011
   761
      (K (((150, ""), explicit_tff0, "mono_native", liftingN, false), "") (* FUDGE *))
blanchet@57264
   762
val remote_waldmeister = gen_remote_waldmeister waldmeisterN
blanchet@57264
   763
val remote_waldmeister_new = gen_remote_waldmeister waldmeister_newN
blanchet@38454
   764
blanchet@52073
   765
blanchet@38454
   766
(* Setup *)
blanchet@38454
   767
blanchet@40059
   768
fun add_atp (name, config) thy =
blanchet@40059
   769
  Data.map (Symtab.update_new (name, (config, stamp ()))) thy
blanchet@40059
   770
  handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@40059
   771
blanchet@40059
   772
fun get_atp thy name =
blanchet@54788
   773
  fst (the (Symtab.lookup (Data.get thy) name))
blanchet@40059
   774
  handle Option.Option => error ("Unknown ATP: " ^ name ^ ".")
blanchet@40059
   775
blanchet@41727
   776
val supported_atps = Symtab.keys o Data.get
blanchet@36371
   777
blanchet@40059
   778
fun is_atp_installed thy name =
blanchet@48376
   779
  let val {exec, ...} = get_atp thy name () in
blanchet@52754
   780
    exists (fn var => getenv var <> "") (fst (exec ()))
blanchet@40059
   781
  end
blanchet@36371
   782
blanchet@40059
   783
fun refresh_systems_on_tptp () =
blanchet@49984
   784
  Synchronized.change remote_systems (fn _ => get_remote_systems ())
blanchet@40059
   785
blanchet@47055
   786
fun effective_term_order ctxt atp =
blanchet@47055
   787
  let val ord = Config.get ctxt term_order in
blanchet@47055
   788
    if ord = smartN then
blanchet@54788
   789
      {is_lpo = false, gen_weights = (atp = spassN), gen_prec = (atp = spassN),
blanchet@54788
   790
       gen_simp = String.isSuffix spass_pirateN atp}
blanchet@47055
   791
    else
blanchet@47055
   792
      let val is_lpo = String.isSubstring lpoN ord in
blanchet@54788
   793
        {is_lpo = is_lpo, gen_weights = not is_lpo andalso String.isSubstring xweightsN ord,
blanchet@54788
   794
         gen_prec = String.isSubstring xprecN ord, gen_simp = String.isSubstring xsimpN ord}
blanchet@47055
   795
      end
blanchet@47055
   796
  end
blanchet@47055
   797
blanchet@52073
   798
val atps =
blanchet@54788
   799
  [agsyhol, alt_ergo, e, e_males, e_par, iprover, iprover_eq, leo2, satallax, spass, vampire,
fleury@57255
   800
   z3_tptp, zipperposition, dummy_thf, remote_agsyhol, remote_e, remote_e_sine, remote_e_tofof,
fleury@57154
   801
   remote_iprover, remote_iprover_eq, remote_leo2, remote_satallax, remote_vampire, remote_snark,
blanchet@57264
   802
   remote_spass_pirate, remote_waldmeister, remote_waldmeister_new]
blanchet@47055
   803
blanchet@57262
   804
val _ = Theory.setup (fold add_atp atps)
blanchet@35867
   805
wenzelm@28592
   806
end;