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