src/HOL/Tools/ATP/atp_systems.ML
author blanchet
Wed Oct 31 11:23:21 2012 +0100 (2012-10-31)
changeset 49991 e0761153fbd1
parent 49990 42209bfa1548
child 50333 20c69b00e73c
permissions -rw-r--r--
less verbose -- the warning will reach the users anyway by other means
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@47976
    12
  type formula_role = ATP_Problem.formula_role
blanchet@39491
    13
  type failure = ATP_Proof.failure
blanchet@38023
    14
blanchet@46409
    15
  type slice_spec = int * atp_format * string * string * bool
blanchet@40059
    16
  type atp_config =
blanchet@48376
    17
    {exec : string list * string list,
blanchet@42646
    18
     arguments :
blanchet@43473
    19
       Proof.context -> bool -> string -> Time.time
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@42578
    23
     known_failures : (failure * string) list,
blanchet@47976
    24
     prem_role : 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@46643
    44
  val alt_ergoN : string
blanchet@46643
    45
  val dummy_thfN : string
blanchet@40059
    46
  val eN : string
blanchet@48651
    47
  val e_malesN : string
blanchet@44590
    48
  val e_sineN : string
blanchet@44590
    49
  val e_tofofN : string
blanchet@45338
    50
  val iproverN : string
blanchet@45338
    51
  val iprover_eqN : string
blanchet@44590
    52
  val leo2N : string
blanchet@44590
    53
  val satallaxN : string
blanchet@44590
    54
  val snarkN : string
blanchet@40059
    55
  val spassN : string
blanchet@48131
    56
  val spass_polyN : string
blanchet@40059
    57
  val vampireN : string
blanchet@42938
    58
  val waldmeisterN : string
blanchet@44423
    59
  val z3_tptpN : string
blanchet@40060
    60
  val remote_prefix : string
blanchet@41738
    61
  val remote_atp :
blanchet@41738
    62
    string -> string -> string list -> (string * string) list
blanchet@47976
    63
    -> (failure * string) list -> formula_role
blanchet@47606
    64
    -> (Proof.context -> slice_spec * string) -> string * (unit -> atp_config)
blanchet@47606
    65
  val add_atp : string * (unit -> atp_config) -> theory -> theory
blanchet@47606
    66
  val get_atp : theory -> string -> (unit -> atp_config)
blanchet@41727
    67
  val supported_atps : theory -> string list
blanchet@40059
    68
  val is_atp_installed : theory -> string -> bool
blanchet@35867
    69
  val refresh_systems_on_tptp : unit -> unit
blanchet@47055
    70
  val effective_term_order : Proof.context -> string -> term_order
blanchet@35867
    71
  val setup : theory -> theory
wenzelm@28592
    72
end;
wenzelm@28592
    73
blanchet@36376
    74
structure ATP_Systems : ATP_SYSTEMS =
wenzelm@28592
    75
struct
wenzelm@28596
    76
blanchet@42577
    77
open ATP_Problem
blanchet@39491
    78
open ATP_Proof
blanchet@46320
    79
open ATP_Problem_Generate
boehmes@32864
    80
blanchet@40059
    81
(* ATP configuration *)
boehmes@32864
    82
blanchet@47962
    83
val default_max_mono_iters = 3 (* FUDGE *)
blanchet@47962
    84
val default_max_new_mono_instances = 200 (* FUDGE *)
blanchet@47962
    85
blanchet@46409
    86
type slice_spec = int * atp_format * string * string * bool
blanchet@46409
    87
blanchet@40059
    88
type atp_config =
blanchet@48376
    89
  {exec : string list * string list,
blanchet@42646
    90
   arguments :
blanchet@43473
    91
     Proof.context -> bool -> string -> Time.time
blanchet@47038
    92
     -> term_order * (unit -> (string * int) list)
blanchet@47038
    93
        * (unit -> (string * real) list) -> string,
blanchet@42578
    94
   proof_delims : (string * string) list,
blanchet@42578
    95
   known_failures : (failure * string) list,
blanchet@47976
    96
   prem_role : formula_role,
blanchet@48716
    97
   best_slices : Proof.context -> (real * (slice_spec * string)) list,
blanchet@47962
    98
   best_max_mono_iters : int,
blanchet@47962
    99
   best_max_new_mono_instances : int}
wenzelm@28596
   100
blanchet@42723
   101
(* "best_slices" must be found empirically, taking a wholistic approach since
blanchet@46407
   102
   the ATPs are run in parallel. The "real" component gives the faction of the
blanchet@48716
   103
   time available given to the slice and should add up to 1.0. The "int"
blanchet@48716
   104
   component indicates the preferred number of facts to pass; the first
blanchet@48716
   105
   "string", the preferred type system (which should be sound or quasi-sound);
blanchet@48716
   106
   the second "string", the preferred lambda translation scheme; the "bool",
blanchet@48716
   107
   whether uncurried aliased should be generated; the third "string", extra
blanchet@48716
   108
   information to the prover (e.g., SOS or no SOS).
blanchet@42723
   109
blanchet@42723
   110
   The last slice should be the most "normal" one, because it will get all the
blanchet@43569
   111
   time available if the other slices fail early and also because it is used if
blanchet@43569
   112
   slicing is disabled (e.g., by the minimizer). *)
blanchet@42710
   113
blanchet@38061
   114
val known_perl_failures =
blanchet@38094
   115
  [(CantConnect, "HTTP error"),
blanchet@38094
   116
   (NoPerl, "env: perl"),
blanchet@38065
   117
   (NoLibwwwPerl, "Can't locate HTTP")]
wenzelm@28596
   118
blanchet@45203
   119
fun known_szs_failures wrap =
blanchet@45203
   120
  [(Unprovable, wrap "CounterSatisfiable"),
blanchet@45203
   121
   (Unprovable, wrap "Satisfiable"),
blanchet@45203
   122
   (GaveUp, wrap "GaveUp"),
blanchet@45203
   123
   (GaveUp, wrap "Unknown"),
blanchet@45203
   124
   (GaveUp, wrap "Incomplete"),
blanchet@45203
   125
   (ProofMissing, wrap "Theorem"),
blanchet@45203
   126
   (ProofMissing, wrap "Unsatisfiable"),
blanchet@45203
   127
   (TimedOut, wrap "Timeout"),
blanchet@45203
   128
   (Inappropriate, wrap "Inappropriate"),
blanchet@45203
   129
   (OutOfResources, wrap "ResourceOut"),
blanchet@45203
   130
   (OutOfResources, wrap "MemoryOut"),
blanchet@45203
   131
   (Interrupted, wrap "Forced"),
blanchet@45203
   132
   (Interrupted, wrap "User")]
blanchet@45203
   133
blanchet@45203
   134
val known_szs_status_failures = known_szs_failures (prefix "SZS status ")
blanchet@45203
   135
val known_says_failures = known_szs_failures (prefix " says ")
blanchet@45203
   136
blanchet@40059
   137
(* named ATPs *)
blanchet@40059
   138
blanchet@46643
   139
val alt_ergoN = "alt_ergo"
blanchet@47055
   140
val dummy_thfN = "dummy_thf" (* for experiments *)
blanchet@40059
   141
val eN = "e"
blanchet@48651
   142
val e_malesN = "e_males"
blanchet@44590
   143
val e_sineN = "e_sine"
blanchet@44590
   144
val e_tofofN = "e_tofof"
blanchet@45338
   145
val iproverN = "iprover"
blanchet@45338
   146
val iprover_eqN = "iprover_eq"
blanchet@44099
   147
val leo2N = "leo2"
blanchet@44099
   148
val satallaxN = "satallax"
blanchet@44590
   149
val snarkN = "snark"
blanchet@40059
   150
val spassN = "spass"
blanchet@48131
   151
val spass_polyN = "spass_poly"
blanchet@40059
   152
val vampireN = "vampire"
blanchet@44590
   153
val waldmeisterN = "waldmeister"
blanchet@44423
   154
val z3_tptpN = "z3_tptp"
blanchet@40060
   155
val remote_prefix = "remote_"
blanchet@38001
   156
blanchet@38023
   157
structure Data = Theory_Data
blanchet@38023
   158
(
blanchet@47606
   159
  type T = ((unit -> atp_config) * stamp) Symtab.table
blanchet@38023
   160
  val empty = Symtab.empty
blanchet@38023
   161
  val extend = I
blanchet@46407
   162
  fun merge data : T =
blanchet@46407
   163
    Symtab.merge (eq_snd (op =)) data
blanchet@38023
   164
    handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@38023
   165
)
blanchet@38017
   166
blanchet@43981
   167
fun to_secs min time = Int.max (min, (Time.toMilliseconds time + 999) div 1000)
blanchet@36142
   168
blanchet@43473
   169
val sosN = "sos"
blanchet@43473
   170
val no_sosN = "no_sos"
blanchet@43473
   171
blanchet@44099
   172
val force_sos = Attrib.setup_config_bool @{binding atp_force_sos} (K false)
blanchet@44099
   173
blanchet@47032
   174
val smartN = "smart"
blanchet@47073
   175
(* val kboN = "kbo" *)
blanchet@47032
   176
val lpoN = "lpo"
blanchet@47034
   177
val xweightsN = "_weights"
blanchet@47034
   178
val xprecN = "_prec"
blanchet@47034
   179
val xsimpN = "_simp" (* SPASS-specific *)
blanchet@47032
   180
blanchet@47038
   181
(* Possible values for "atp_term_order":
blanchet@47049
   182
   "smart", "(kbo|lpo)(_weights)?(_prec|_simp)?" *)
blanchet@47032
   183
val term_order =
blanchet@47032
   184
  Attrib.setup_config_string @{binding atp_term_order} (K smartN)
blanchet@47032
   185
blanchet@46643
   186
(* Alt-Ergo *)
blanchet@46643
   187
blanchet@48130
   188
val alt_ergo_tff1 = TFF (Polymorphic, TPTP_Explicit)
blanchet@46643
   189
blanchet@46643
   190
val alt_ergo_config : atp_config =
blanchet@48376
   191
  {exec = (["WHY3_HOME"], ["why3"]),
blanchet@48651
   192
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@48651
   193
       "--format tff1 --prover alt-ergo --timelimit " ^
blanchet@48651
   194
       string_of_int (to_secs 1 timeout),
blanchet@46643
   195
   proof_delims = [],
blanchet@46643
   196
   known_failures =
blanchet@46643
   197
     [(ProofMissing, ": Valid"),
blanchet@46643
   198
      (TimedOut, ": Timeout"),
blanchet@46643
   199
      (GaveUp, ": Unknown")],
blanchet@47976
   200
   prem_role = Hypothesis,
blanchet@46643
   201
   best_slices = fn _ =>
blanchet@46643
   202
     (* FUDGE *)
blanchet@48716
   203
     [(1.0, ((100, alt_ergo_tff1, "poly_native", liftingN, false), ""))],
blanchet@47962
   204
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   205
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@46643
   206
blanchet@47646
   207
val alt_ergo = (alt_ergoN, fn () => alt_ergo_config)
blanchet@46643
   208
blanchet@46643
   209
blanchet@40059
   210
(* E *)
wenzelm@28596
   211
blanchet@48653
   212
fun is_e_at_least_1_3 () = (string_ord (getenv "E_VERSION", "1.3") <> LESS)
blanchet@48653
   213
fun is_e_at_least_1_6 () = (string_ord (getenv "E_VERSION", "1.6") <> LESS)
blanchet@44420
   214
blanchet@36369
   215
val tstp_proof_delims =
blanchet@42962
   216
  [("# SZS output start CNFRefutation.", "# SZS output end CNFRefutation"),
blanchet@42962
   217
   ("% SZS output start CNFRefutation", "% SZS output end CNFRefutation")]
blanchet@36369
   218
blanchet@43473
   219
val e_smartN = "smart"
blanchet@42646
   220
val e_autoN = "auto"
blanchet@42646
   221
val e_fun_weightN = "fun_weight"
blanchet@42646
   222
val e_sym_offset_weightN = "sym_offset_weight"
blanchet@41725
   223
blanchet@47032
   224
val e_selection_heuristic =
blanchet@47032
   225
  Attrib.setup_config_string @{binding atp_e_selection_heuristic} (K e_smartN)
blanchet@41770
   226
(* FUDGE *)
blanchet@42646
   227
val e_default_fun_weight =
blanchet@42646
   228
  Attrib.setup_config_real @{binding atp_e_default_fun_weight} (K 20.0)
blanchet@42646
   229
val e_fun_weight_base =
blanchet@42646
   230
  Attrib.setup_config_real @{binding atp_e_fun_weight_base} (K 0.0)
blanchet@42646
   231
val e_fun_weight_span =
blanchet@42646
   232
  Attrib.setup_config_real @{binding atp_e_fun_weight_span} (K 40.0)
blanchet@42646
   233
val e_default_sym_offs_weight =
blanchet@42646
   234
  Attrib.setup_config_real @{binding atp_e_default_sym_offs_weight} (K 1.0)
blanchet@42646
   235
val e_sym_offs_weight_base =
blanchet@42646
   236
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_base} (K ~20.0)
blanchet@42646
   237
val e_sym_offs_weight_span =
blanchet@42646
   238
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_span} (K 60.0)
blanchet@41725
   239
blanchet@47038
   240
fun e_selection_heuristic_case heuristic fw sow =
blanchet@47038
   241
  if heuristic = e_fun_weightN then fw
blanchet@47038
   242
  else if heuristic = e_sym_offset_weightN then sow
blanchet@47038
   243
  else raise Fail ("unexpected " ^ quote heuristic)
blanchet@41725
   244
blanchet@47038
   245
fun scaled_e_selection_weight ctxt heuristic w =
blanchet@47038
   246
  w * Config.get ctxt (e_selection_heuristic_case heuristic
blanchet@47029
   247
                           e_fun_weight_span e_sym_offs_weight_span)
blanchet@47038
   248
  + Config.get ctxt (e_selection_heuristic_case heuristic
blanchet@47029
   249
                         e_fun_weight_base e_sym_offs_weight_base)
blanchet@41725
   250
  |> Real.ceil |> signed_string_of_int
blanchet@41313
   251
blanchet@47038
   252
fun e_selection_weight_arguments ctxt heuristic sel_weights =
blanchet@47038
   253
  if heuristic = e_autoN then
blanchet@47038
   254
    "-xAuto"
blanchet@41725
   255
  else
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@41313
   274
blanchet@47038
   275
val e_ord_weights =
blanchet@47038
   276
  map (fn (s, w) => s ^ ":" ^ string_of_int w) #> space_implode ","
blanchet@47038
   277
fun e_ord_precedence [_] = ""
blanchet@47038
   278
  | e_ord_precedence info = info |> map fst |> space_implode "<"
blanchet@47038
   279
blanchet@47039
   280
fun e_term_order_info_arguments false false _ = ""
blanchet@47039
   281
  | e_term_order_info_arguments gen_weights gen_prec ord_info =
blanchet@47038
   282
    let val ord_info = ord_info () in
blanchet@47038
   283
      (if gen_weights then "--order-weights='" ^ e_ord_weights ord_info ^ "' "
blanchet@47038
   284
       else "") ^
blanchet@47038
   285
      (if gen_prec then "--precedence='" ^ e_ord_precedence ord_info ^ "' "
blanchet@47038
   286
       else "")
blanchet@47038
   287
    end
blanchet@47038
   288
blanchet@48232
   289
fun e_shell_level_argument full_proof =
blanchet@48653
   290
  if is_e_at_least_1_6 () then
blanchet@48232
   291
    " --pcl-shell-level=" ^ (if full_proof then "0" else "2")
blanchet@48232
   292
  else
blanchet@48232
   293
    ""
blanchet@48232
   294
blanchet@47032
   295
fun effective_e_selection_heuristic ctxt =
blanchet@48653
   296
  if is_e_at_least_1_3 () then Config.get ctxt e_selection_heuristic
blanchet@48232
   297
  else e_autoN
blanchet@42443
   298
blanchet@48653
   299
fun e_kbo () = if is_e_at_least_1_3 () then "KBO6" else "KBO"
blanchet@47505
   300
blanchet@40059
   301
val e_config : atp_config =
blanchet@48376
   302
  {exec = (["E_HOME"], ["eproof_ram", "eproof"]),
blanchet@48651
   303
   arguments = fn ctxt => fn full_proof => fn heuristic => fn timeout =>
blanchet@48651
   304
       fn ({is_lpo, gen_weights, gen_prec, ...}, ord_info, sel_weights) =>
blanchet@48651
   305
       "--tstp-in --tstp-out --output-level=5 --silent " ^
blanchet@48651
   306
       e_selection_weight_arguments ctxt heuristic sel_weights ^ " " ^
blanchet@48651
   307
       e_term_order_info_arguments gen_weights gen_prec ord_info ^ " " ^
blanchet@48651
   308
       "--term-ordering=" ^ (if is_lpo then "LPO4" else e_kbo ()) ^ " " ^
blanchet@48651
   309
       "--cpu-limit=" ^ string_of_int (to_secs 2 timeout) ^
blanchet@48651
   310
       e_shell_level_argument full_proof,
blanchet@48376
   311
   proof_delims = tstp_proof_delims,
blanchet@36265
   312
   known_failures =
blanchet@45203
   313
     [(TimedOut, "Failure: Resource limit exceeded (time)"),
blanchet@47972
   314
      (TimedOut, "time limit exceeded")] @
blanchet@47972
   315
     known_szs_status_failures,
blanchet@47976
   316
   prem_role = Conjecture,
blanchet@42646
   317
   best_slices = fn ctxt =>
blanchet@47038
   318
     let val heuristic = effective_e_selection_heuristic ctxt in
blanchet@43474
   319
       (* FUDGE *)
blanchet@47038
   320
       if heuristic = e_smartN then
blanchet@48716
   321
         [(0.333, ((500, FOF, "mono_tags??", combsN, false), e_fun_weightN)),
blanchet@48716
   322
          (0.334, ((50, FOF, "mono_guards??", combsN, false), e_fun_weightN)),
blanchet@48716
   323
          (0.333, ((1000, FOF, "mono_tags??", combsN, false), e_sym_offset_weightN))]
blanchet@43473
   324
       else
blanchet@48716
   325
         [(1.0, ((500, FOF, "mono_tags??", combsN, false), heuristic))]
blanchet@47962
   326
     end,
blanchet@47962
   327
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   328
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@38454
   329
blanchet@47646
   330
val e = (eN, fn () => e_config)
wenzelm@28596
   331
wenzelm@28596
   332
blanchet@48651
   333
(* E-MaLeS *)
blanchet@48651
   334
blanchet@48651
   335
val e_males_config : atp_config =
blanchet@48651
   336
  {exec = (["E_MALES_HOME"], ["emales.py"]),
blanchet@48651
   337
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@48651
   338
       "-t " ^ string_of_int (to_secs 1 timeout) ^ " -p",
blanchet@48651
   339
   proof_delims = tstp_proof_delims,
blanchet@48651
   340
   known_failures = #known_failures e_config,
blanchet@48651
   341
   prem_role = Conjecture,
blanchet@48651
   342
   best_slices =
blanchet@48651
   343
     (* FUDGE *)
blanchet@48716
   344
     K [(1.0, ((1000, FOF, "mono_tags??", combsN, false), ""))],
blanchet@48651
   345
   best_max_mono_iters = default_max_mono_iters,
blanchet@48651
   346
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@48651
   347
blanchet@48651
   348
val e_males = (e_malesN, fn () => e_males_config)
blanchet@48651
   349
blanchet@48651
   350
blanchet@48700
   351
(* iProver *)
blanchet@48700
   352
blanchet@48700
   353
val iprover_config : atp_config =
blanchet@48700
   354
  {exec = (["IPROVER_HOME"], ["iprover"]),
blanchet@48700
   355
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@48720
   356
       "--clausifier \"$IPROVER_HOME\"/vclausify_rel --time_out_real " ^
blanchet@48700
   357
       string_of_real (Time.toReal timeout),
blanchet@48700
   358
   proof_delims = tstp_proof_delims,
blanchet@48700
   359
   known_failures =
blanchet@48700
   360
     [(ProofIncomplete, "% SZS output start CNFRefutation")] @
blanchet@48700
   361
     known_szs_status_failures,
blanchet@48700
   362
   prem_role = Hypothesis,
blanchet@48700
   363
   best_slices =
blanchet@48700
   364
     (* FUDGE *)
blanchet@48716
   365
     K [(1.0, ((150, FOF, "mono_guards??", liftingN, false), ""))],
blanchet@48700
   366
   best_max_mono_iters = default_max_mono_iters,
blanchet@48700
   367
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@48700
   368
blanchet@48700
   369
val iprover = (iproverN, fn () => iprover_config)
blanchet@48700
   370
blanchet@48700
   371
blanchet@48700
   372
(* iProver-Eq *)
blanchet@48700
   373
blanchet@48700
   374
val iprover_eq_config : atp_config =
blanchet@48700
   375
  {exec = (["IPROVER_EQ_HOME"], ["iprover-eq"]),
blanchet@48700
   376
   arguments = #arguments iprover_config,
blanchet@48700
   377
   proof_delims = #proof_delims iprover_config,
blanchet@48700
   378
   known_failures = #known_failures iprover_config,
blanchet@48700
   379
   prem_role = #prem_role iprover_config,
blanchet@48700
   380
   best_slices = #best_slices iprover_config,
blanchet@48700
   381
   best_max_mono_iters = #best_max_mono_iters iprover_config,
blanchet@48700
   382
   best_max_new_mono_instances = #best_max_new_mono_instances iprover_config}
blanchet@48700
   383
blanchet@48700
   384
val iprover_eq = (iprover_eqN, fn () => iprover_eq_config)
blanchet@48700
   385
blanchet@48700
   386
blanchet@44099
   387
(* LEO-II *)
blanchet@44099
   388
blanchet@48004
   389
(* LEO-II supports definitions, but it performs significantly better on our
blanchet@48004
   390
   benchmarks when they are not used. *)
blanchet@48004
   391
val leo2_thf0 =
blanchet@48130
   392
  THF (Monomorphic, TPTP_Explicit, THF_Without_Choice, THF_Without_Defs)
blanchet@44754
   393
blanchet@44099
   394
val leo2_config : atp_config =
blanchet@48376
   395
  {exec = (["LEO2_HOME"], ["leo"]),
blanchet@48651
   396
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@48651
   397
       "--foatp e --atp e=\"$E_HOME\"/eprover \
blanchet@48651
   398
       \--atp epclextract=\"$E_HOME\"/epclextract \
blanchet@48651
   399
       \--proofoutput 1 --timeout " ^ string_of_int (to_secs 1 timeout),
blanchet@44099
   400
   proof_delims = tstp_proof_delims,
blanchet@45207
   401
   known_failures =
blanchet@47974
   402
     [(TimedOut, "CPU time limit exceeded, terminating"),
blanchet@47972
   403
      (GaveUp, "No.of.Axioms")] @
blanchet@47972
   404
     known_szs_status_failures,
blanchet@47976
   405
   prem_role = Hypothesis,
blanchet@47914
   406
   best_slices =
blanchet@44099
   407
     (* FUDGE *)
blanchet@48716
   408
     K [(1.0, ((40, leo2_thf0, "mono_native_higher", keep_lamsN, false), ""))],
blanchet@47962
   409
   best_max_mono_iters = default_max_mono_iters - 1 (* FUDGE *),
blanchet@47962
   410
   best_max_new_mono_instances = default_max_new_mono_instances div 2 (* FUDGE *)}
blanchet@39491
   411
blanchet@47646
   412
val leo2 = (leo2N, fn () => leo2_config)
blanchet@44099
   413
blanchet@44099
   414
blanchet@44099
   415
(* Satallax *)
blanchet@44099
   416
blanchet@48004
   417
val satallax_thf0 =
blanchet@48130
   418
  THF (Monomorphic, TPTP_Explicit, THF_With_Choice, THF_With_Defs)
blanchet@44754
   419
blanchet@44099
   420
val satallax_config : atp_config =
blanchet@48376
   421
  {exec = (["SATALLAX_HOME"], ["satallax"]),
blanchet@48651
   422
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@48651
   423
       "-p hocore -t " ^ string_of_int (to_secs 1 timeout),
blanchet@45162
   424
   proof_delims =
blanchet@45162
   425
     [("% Higher-Order Unsat Core BEGIN", "% Higher-Order Unsat Core END")],
blanchet@45203
   426
   known_failures = known_szs_status_failures,
blanchet@47981
   427
   prem_role = Hypothesis,
blanchet@44416
   428
   best_slices =
blanchet@44754
   429
     (* FUDGE *)
blanchet@48716
   430
     K [(1.0, ((60, satallax_thf0, "mono_native_higher", keep_lamsN, false), ""))],
blanchet@47962
   431
   best_max_mono_iters = default_max_mono_iters - 1 (* FUDGE *),
blanchet@47962
   432
   best_max_new_mono_instances = default_max_new_mono_instances div 2 (* FUDGE *)}
blanchet@44099
   433
blanchet@47646
   434
val satallax = (satallaxN, fn () => satallax_config)
blanchet@44099
   435
blanchet@44099
   436
blanchet@44099
   437
(* SPASS *)
blanchet@42725
   438
blanchet@48005
   439
val spass_H1SOS = "-Heuristic=1 -SOS"
blanchet@48005
   440
val spass_H2LR0LT0 = "-Heuristic=2 -LR=0 -LT=0"
blanchet@48005
   441
val spass_H2SOS = "-Heuristic=2 -SOS"
blanchet@48005
   442
val spass_H2NuVS0 = "-Heuristic=2 -RNuV=1 -Sorts=0"
blanchet@48005
   443
val spass_H2NuVS0Red2 = "-Heuristic=2 -RNuV=1 -Sorts=0 -RFRew=2 -RBRew=2 -RTaut=2"
blanchet@47055
   444
blanchet@48005
   445
(* FIXME: Make "SPASS_NEW_HOME" legacy. *)
blanchet@48005
   446
val spass_config : atp_config =
blanchet@48376
   447
  {exec = (["SPASS_NEW_HOME", "SPASS_HOME"], ["SPASS"]),
blanchet@48005
   448
   arguments = fn _ => fn _ => fn extra_options => fn timeout => fn _ =>
blanchet@48651
   449
       ("-Isabelle=1 -TimeLimit=" ^ string_of_int (to_secs 1 timeout))
blanchet@48651
   450
       |> extra_options <> "" ? prefix (extra_options ^ " "),
blanchet@36369
   451
   proof_delims = [("Here is a proof", "Formulae used in the proof")],
blanchet@36289
   452
   known_failures =
blanchet@48005
   453
     [(OldSPASS, "Unrecognized option Isabelle"),
blanchet@47950
   454
      (GaveUp, "SPASS beiseite: Completion found"),
blanchet@36370
   455
      (TimedOut, "SPASS beiseite: Ran out of time"),
blanchet@36965
   456
      (OutOfResources, "SPASS beiseite: Maximal number of loops exceeded"),
blanchet@37413
   457
      (MalformedInput, "Undefined symbol"),
blanchet@37414
   458
      (MalformedInput, "Free Variable"),
blanchet@44391
   459
      (Unprovable, "No formulae and clauses found in input file"),
blanchet@47972
   460
      (InternalError, "Please report this error")] @
blanchet@47972
   461
      known_perl_failures,
blanchet@47976
   462
   prem_role = Conjecture,
blanchet@48005
   463
   best_slices = fn _ =>
blanchet@42723
   464
     (* FUDGE *)
blanchet@48716
   465
     [(0.1667, ((150, DFG Monomorphic, "mono_native", combsN, true), "")),
blanchet@48716
   466
      (0.1667, ((500, DFG Monomorphic, "mono_native", liftingN, true), spass_H2SOS)),
blanchet@48716
   467
      (0.1666, ((50, DFG Monomorphic,  "mono_native", liftingN, true), spass_H2LR0LT0)),
blanchet@48716
   468
      (0.1000, ((250, DFG Monomorphic, "mono_native", combsN, true), spass_H2NuVS0)),
blanchet@48716
   469
      (0.1000, ((1000, DFG Monomorphic, "mono_native", liftingN, true), spass_H1SOS)),
blanchet@48716
   470
      (0.1000, ((150, DFG Monomorphic, "poly_guards??", liftingN, false), spass_H2NuVS0Red2)),
blanchet@48716
   471
      (0.1000, ((300, DFG Monomorphic, "mono_native", combsN, true), spass_H2SOS)),
blanchet@48716
   472
      (0.1000, ((100, DFG Monomorphic, "mono_native", combs_and_liftingN, true), ""))],
blanchet@47962
   473
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   474
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@38454
   475
blanchet@48005
   476
val spass = (spassN, fn () => spass_config)
blanchet@38454
   477
blanchet@37509
   478
(* Vampire *)
blanchet@37509
   479
blanchet@48007
   480
(* Vampire 1.8 has TFF support, but the support was buggy until revision
blanchet@48007
   481
   1435 (or shortly before). *)
blanchet@48653
   482
fun is_vampire_at_least_1_8 () =
blanchet@48653
   483
  string_ord (getenv "VAMPIRE_VERSION", "1.8") <> LESS
blanchet@48653
   484
fun is_vampire_beyond_1_8 () =
blanchet@47055
   485
  string_ord (getenv "VAMPIRE_VERSION", "1.8") = GREATER
blanchet@44420
   486
blanchet@48130
   487
val vampire_tff0 = TFF (Monomorphic, TPTP_Implicit)
blanchet@44589
   488
blanchet@40059
   489
val vampire_config : atp_config =
blanchet@48376
   490
  {exec = (["VAMPIRE_HOME"], ["vampire"]),
blanchet@43569
   491
   arguments = fn _ => fn _ => fn sos => fn timeout => fn _ =>
blanchet@48651
   492
       "--mode casc -t " ^ string_of_int (to_secs 1 timeout) ^
blanchet@48653
   493
       " --proof tptp --output_axiom_names on" ^
blanchet@48653
   494
       (if is_vampire_at_least_1_8 () then
blanchet@48653
   495
          " --forced_options propositional_to_bdd=off"
blanchet@48653
   496
        else
blanchet@48653
   497
          "") ^
blanchet@48653
   498
       " --thanks \"Andrei and Krystof\" --input_file"
blanchet@48651
   499
       |> sos = sosN ? prefix "--sos on ",
blanchet@37509
   500
   proof_delims =
blanchet@37509
   501
     [("=========== Refutation ==========",
blanchet@37509
   502
       "======= End of refutation ======="),
blanchet@38033
   503
      ("% SZS output start Refutation", "% SZS output end Refutation"),
blanchet@38033
   504
      ("% SZS output start Proof", "% SZS output end Proof")],
blanchet@37509
   505
   known_failures =
blanchet@43050
   506
     [(GaveUp, "UNPROVABLE"),
blanchet@43050
   507
      (GaveUp, "CANNOT PROVE"),
blanchet@37509
   508
      (Unprovable, "Satisfiability detected"),
blanchet@38647
   509
      (Unprovable, "Termination reason: Satisfiable"),
blanchet@47972
   510
      (Interrupted, "Aborted by signal SIGINT")] @
blanchet@47972
   511
     known_szs_status_failures,
blanchet@47976
   512
   prem_role = Conjecture,
blanchet@42725
   513
   best_slices = fn ctxt =>
blanchet@42723
   514
     (* FUDGE *)
blanchet@48653
   515
     (if is_vampire_beyond_1_8 () then
blanchet@48801
   516
        [(0.333, ((500, vampire_tff0, "mono_guards??", combs_or_liftingN, false), sosN)),
blanchet@48801
   517
         (0.333, ((150, vampire_tff0, "poly_tags??", combs_or_liftingN, false), sosN)),
blanchet@48716
   518
         (0.334, ((50, vampire_tff0, "mono_native", combs_or_liftingN, false), no_sosN))]
blanchet@47055
   519
      else
blanchet@48716
   520
        [(0.333, ((150, FOF, "poly_guards??", combs_or_liftingN, false), sosN)),
blanchet@48716
   521
         (0.333, ((500, FOF, "mono_tags??", combs_or_liftingN, false), sosN)),
blanchet@48716
   522
         (0.334, ((50, FOF, "mono_guards??", combs_or_liftingN, false), no_sosN))])
blanchet@44099
   523
     |> (if Config.get ctxt force_sos then hd #> apfst (K 1.0) #> single
blanchet@47962
   524
         else I),
blanchet@47962
   525
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   526
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@38454
   527
blanchet@47646
   528
val vampire = (vampireN, fn () => vampire_config)
blanchet@37509
   529
blanchet@38454
   530
blanchet@48803
   531
(* Z3 with TPTP syntax (half experimental, half legacy) *)
blanchet@41740
   532
blanchet@48130
   533
val z3_tff0 = TFF (Monomorphic, TPTP_Implicit)
blanchet@44589
   534
blanchet@44423
   535
val z3_tptp_config : atp_config =
blanchet@48376
   536
  {exec = (["Z3_HOME"], ["z3"]),
blanchet@43354
   537
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@48651
   538
       "MBQI=true DISPLAY_UNSAT_CORE=true -tptp -t:" ^
blanchet@48651
   539
       string_of_int (to_secs 1 timeout),
blanchet@48539
   540
   proof_delims = [("\ncore(", ").")],
blanchet@45203
   541
   known_failures = known_szs_status_failures,
blanchet@47976
   542
   prem_role = Hypothesis,
blanchet@42723
   543
   best_slices =
blanchet@44423
   544
     (* FUDGE *)
blanchet@48716
   545
     K [(0.5, ((250, z3_tff0, "mono_native", combsN, false), "")),
blanchet@48716
   546
        (0.25, ((125, z3_tff0, "mono_native", combsN, false), "")),
blanchet@48716
   547
        (0.125, ((62, z3_tff0, "mono_native", combsN, false), "")),
blanchet@48716
   548
        (0.125, ((31, z3_tff0, "mono_native", combsN, false), ""))],
blanchet@47962
   549
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   550
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@41740
   551
blanchet@47646
   552
val z3_tptp = (z3_tptpN, fn () => z3_tptp_config)
blanchet@41740
   553
blanchet@44590
   554
blanchet@48131
   555
(* Not really a prover: Experimental Polymorphic THF and DFG output *)
blanchet@44590
   556
blanchet@44754
   557
fun dummy_config format type_enc : atp_config =
blanchet@48376
   558
  {exec = (["ISABELLE_ATP"], ["scripts/dummy_atp"]),
blanchet@44590
   559
   arguments = K (K (K (K (K "")))),
blanchet@44590
   560
   proof_delims = [],
blanchet@45203
   561
   known_failures = known_szs_status_failures,
blanchet@47976
   562
   prem_role = Hypothesis,
blanchet@45521
   563
   best_slices =
blanchet@48716
   564
     K [(1.0, ((200, format, type_enc,
blanchet@48716
   565
                if is_format_higher_order format then keep_lamsN
blanchet@48716
   566
                else combsN, false), ""))],
blanchet@47962
   567
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   568
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@44590
   569
blanchet@48004
   570
val dummy_thf_format =
blanchet@48130
   571
  THF (Polymorphic, TPTP_Explicit, THF_With_Choice, THF_With_Defs)
blanchet@46435
   572
val dummy_thf_config = dummy_config dummy_thf_format "poly_native_higher"
blanchet@47646
   573
val dummy_thf = (dummy_thfN, fn () => dummy_thf_config)
blanchet@44754
   574
blanchet@48131
   575
val spass_poly_format = DFG Polymorphic
blanchet@48131
   576
val spass_poly_config = dummy_config spass_poly_format "tc_native"
blanchet@48131
   577
val spass_poly = (spass_polyN, fn () => spass_poly_config)
blanchet@41740
   578
blanchet@40059
   579
(* Remote ATP invocation via SystemOnTPTP *)
wenzelm@28596
   580
blanchet@49984
   581
val remote_systems = Synchronized.var "atp_remote_systems" ([] : string list)
immler@31835
   582
blanchet@49984
   583
fun get_remote_systems () =
blanchet@49987
   584
  TimeLimit.timeLimit (seconds 10.0)
blanchet@49987
   585
    (fn () =>
blanchet@49987
   586
        case Isabelle_System.bash_output
blanchet@49987
   587
            "\"$ISABELLE_ATP/scripts/remote_atp\" -w 2>&1" of
blanchet@49987
   588
          (output, 0) => split_lines output
blanchet@49987
   589
        | (output, _) =>
blanchet@49987
   590
          (warning (case extract_known_failure known_perl_failures output of
blanchet@49987
   591
                      SOME failure => string_for_failure failure
blanchet@49987
   592
                    | NONE => trim_line output ^ "."); [])) ()
blanchet@49991
   593
  handle TimeLimit.TimeOut => []
immler@31835
   594
blanchet@49984
   595
fun find_remote_system name [] systems =
blanchet@42537
   596
    find_first (String.isPrefix (name ^ "---")) systems
blanchet@49984
   597
  | find_remote_system name (version :: versions) systems =
blanchet@38690
   598
    case find_first (String.isPrefix (name ^ "---" ^ version)) systems of
blanchet@49984
   599
      NONE => find_remote_system name versions systems
blanchet@38690
   600
    | res => res
blanchet@38690
   601
blanchet@49984
   602
fun get_remote_system name versions =
blanchet@49984
   603
  Synchronized.change_result remote_systems
blanchet@49984
   604
      (fn systems => (if null systems then get_remote_systems () else systems)
blanchet@49984
   605
                     |> `(`(find_remote_system name versions)))
boehmes@32864
   606
blanchet@49984
   607
fun the_remote_system name versions =
blanchet@49984
   608
  case get_remote_system name versions of
blanchet@42955
   609
    (SOME sys, _) => sys
blanchet@46480
   610
  | (NONE, []) => error ("SystemOnTPTP is not available.")
blanchet@42955
   611
  | (NONE, syss) =>
blanchet@46480
   612
    case syss |> filter_out (String.isPrefix "%")
blanchet@46480
   613
              |> filter_out (curry (op =) "") of
blanchet@49990
   614
      [] => error ("SystemOnTPTP is currently not available.")
blanchet@49990
   615
    | [msg] => error ("SystemOnTPTP is currently not available: " ^ msg ^ ".")
blanchet@46480
   616
    | syss =>
blanchet@46480
   617
      error ("System " ^ quote name ^ " is not available at SystemOnTPTP.\n" ^
blanchet@46480
   618
             "(Available systems: " ^ commas_quote syss ^ ".)")
immler@31835
   619
blanchet@41148
   620
val max_remote_secs = 240 (* give Geoff Sutcliffe's servers a break *)
blanchet@41148
   621
blanchet@38690
   622
fun remote_config system_name system_versions proof_delims known_failures
blanchet@47976
   623
                  prem_role best_slice : atp_config =
blanchet@48376
   624
  {exec = (["ISABELLE_ATP"], ["scripts/remote_atp"]),
blanchet@47074
   625
   arguments = fn _ => fn _ => fn command => fn timeout => fn _ =>
blanchet@48651
   626
       (if command <> "" then "-c " ^ quote command ^ " " else "") ^
blanchet@49984
   627
       "-s " ^ the_remote_system system_name system_versions ^ " " ^
blanchet@48651
   628
       "-t " ^ string_of_int (Int.min (max_remote_secs, to_secs 1 timeout)),
blanchet@42962
   629
   proof_delims = union (op =) tstp_proof_delims proof_delims,
blanchet@45203
   630
   known_failures = known_failures @ known_perl_failures @ known_says_failures,
blanchet@47976
   631
   prem_role = prem_role,
blanchet@48716
   632
   best_slices = fn ctxt => [(1.0, best_slice ctxt)],
blanchet@47962
   633
   best_max_mono_iters = default_max_mono_iters,
blanchet@47962
   634
   best_max_new_mono_instances = default_max_new_mono_instances}
blanchet@42443
   635
blanchet@43500
   636
fun remotify_config system_name system_versions best_slice
blanchet@47976
   637
        ({proof_delims, known_failures, prem_role, ...} : atp_config)
blanchet@47912
   638
        : atp_config =
blanchet@38690
   639
  remote_config system_name system_versions proof_delims known_failures
blanchet@47976
   640
                prem_role best_slice
blanchet@38023
   641
blanchet@40059
   642
fun remote_atp name system_name system_versions proof_delims known_failures
blanchet@47976
   643
               prem_role best_slice =
blanchet@40060
   644
  (remote_prefix ^ name,
blanchet@47912
   645
   fn () => remote_config system_name system_versions proof_delims
blanchet@47976
   646
                          known_failures prem_role best_slice)
blanchet@43500
   647
fun remotify_atp (name, config) system_name system_versions best_slice =
blanchet@43500
   648
  (remote_prefix ^ name,
blanchet@47606
   649
   remotify_config system_name system_versions best_slice o config)
wenzelm@28592
   650
blanchet@48130
   651
val explicit_tff0 = TFF (Monomorphic, TPTP_Explicit)
blanchet@44589
   652
blanchet@43500
   653
val remote_e =
blanchet@43500
   654
  remotify_atp e "EP" ["1.0", "1.1", "1.2"]
blanchet@47074
   655
      (K ((750, FOF, "mono_tags??", combsN, false), "") (* FUDGE *))
blanchet@48700
   656
val remote_iprover =
blanchet@48700
   657
  remotify_atp iprover "iProver" []
blanchet@48700
   658
      (K ((150, FOF, "mono_guards??", liftingN, false), "") (* FUDGE *))
blanchet@48700
   659
val remote_iprover_eq =
blanchet@48700
   660
  remotify_atp iprover_eq "iProver-Eq" []
blanchet@48700
   661
      (K ((150, FOF, "mono_guards??", liftingN, false), "") (* FUDGE *))
blanchet@44099
   662
val remote_leo2 =
blanchet@44099
   663
  remotify_atp leo2 "LEO-II" ["1.2.8", "1.2.6"]
blanchet@47074
   664
      (K ((100, leo2_thf0, "mono_native_higher", liftingN, false), "") (* FUDGE *))
blanchet@44099
   665
val remote_satallax =
blanchet@47074
   666
  remotify_atp satallax "Satallax" ["2.3", "2.2", "2"]
blanchet@47076
   667
      (K ((100, satallax_thf0, "mono_native_higher", keep_lamsN, false), "") (* FUDGE *))
blanchet@43500
   668
val remote_vampire =
blanchet@48077
   669
  remotify_atp vampire "Vampire" ["2.6", "2.5", "1.8"]
blanchet@47074
   670
      (K ((250, vampire_tff0, "mono_native", combs_or_liftingN, false), "") (* FUDGE *))
blanchet@44092
   671
val remote_e_sine =
blanchet@47912
   672
  remote_atp e_sineN "SInE" ["0.4"] [] (#known_failures e_config) Conjecture
blanchet@47074
   673
      (K ((500, FOF, "mono_guards??", combsN, false), "") (* FUDGE *))
blanchet@41740
   674
val remote_snark =
blanchet@42939
   675
  remote_atp snarkN "SNARK" ["20080805r029", "20080805r024"]
blanchet@47912
   676
      [("refutation.", "end_refutation.")] [] Hypothesis
blanchet@47074
   677
      (K ((100, explicit_tff0, "mono_native", liftingN, false), "") (* FUDGE *))
blanchet@44092
   678
val remote_e_tofof =
blanchet@47912
   679
  remote_atp e_tofofN "ToFoF" ["0.1"] [] (#known_failures e_config) Hypothesis
blanchet@47074
   680
      (K ((150, explicit_tff0, "mono_native", liftingN, false), "") (* FUDGE *))
blanchet@42938
   681
val remote_waldmeister =
blanchet@42938
   682
  remote_atp waldmeisterN "Waldmeister" ["710"]
blanchet@45521
   683
      [("#START OF PROOF", "Proved Goals:")]
blanchet@45521
   684
      [(OutOfResources, "Too many function symbols"),
blanchet@47506
   685
       (Inappropriate, "****  Unexpected end of file."),
blanchet@45521
   686
       (Crashed, "Unrecoverable Segmentation Fault")]
blanchet@47912
   687
      Hypothesis
blanchet@47898
   688
      (K ((50, CNF_UEQ, "raw_mono_tags??", combsN, false), "") (* FUDGE *))
blanchet@38454
   689
blanchet@38454
   690
(* Setup *)
blanchet@38454
   691
blanchet@40059
   692
fun add_atp (name, config) thy =
blanchet@40059
   693
  Data.map (Symtab.update_new (name, (config, stamp ()))) thy
blanchet@40059
   694
  handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@40059
   695
blanchet@40059
   696
fun get_atp thy name =
blanchet@40059
   697
  the (Symtab.lookup (Data.get thy) name) |> fst
blanchet@40059
   698
  handle Option.Option => error ("Unknown ATP: " ^ name ^ ".")
blanchet@40059
   699
blanchet@41727
   700
val supported_atps = Symtab.keys o Data.get
blanchet@36371
   701
blanchet@40059
   702
fun is_atp_installed thy name =
blanchet@48376
   703
  let val {exec, ...} = get_atp thy name () in
blanchet@48376
   704
    exists (fn var => getenv var <> "") (fst exec)
blanchet@40059
   705
  end
blanchet@36371
   706
blanchet@40059
   707
fun refresh_systems_on_tptp () =
blanchet@49984
   708
  Synchronized.change remote_systems (fn _ => get_remote_systems ())
blanchet@40059
   709
blanchet@47055
   710
fun effective_term_order ctxt atp =
blanchet@47055
   711
  let val ord = Config.get ctxt term_order in
blanchet@47055
   712
    if ord = smartN then
blanchet@48005
   713
      if atp = spassN then
blanchet@47073
   714
        {is_lpo = false, gen_weights = true, gen_prec = true, gen_simp = false}
blanchet@47055
   715
      else
blanchet@47055
   716
        {is_lpo = false, gen_weights = false, gen_prec = false,
blanchet@47055
   717
         gen_simp = false}
blanchet@47055
   718
    else
blanchet@47055
   719
      let val is_lpo = String.isSubstring lpoN ord in
blanchet@47055
   720
        {is_lpo = is_lpo,
blanchet@47055
   721
         gen_weights = not is_lpo andalso String.isSubstring xweightsN ord,
blanchet@47055
   722
         gen_prec = String.isSubstring xprecN ord,
blanchet@47055
   723
         gen_simp = String.isSubstring xsimpN ord}
blanchet@47055
   724
      end
blanchet@47055
   725
  end
blanchet@47055
   726
blanchet@47606
   727
val atps=
blanchet@48700
   728
  [alt_ergo, e, e_males, iprover, iprover_eq, leo2, satallax, spass, spass_poly,
blanchet@48700
   729
   vampire, z3_tptp, dummy_thf, remote_e, remote_e_sine, remote_e_tofof,
blanchet@48700
   730
   remote_iprover, remote_iprover_eq, remote_leo2, remote_satallax,
blanchet@48803
   731
   remote_vampire, remote_snark, remote_waldmeister]
blanchet@47055
   732
blanchet@47606
   733
val setup = fold add_atp atps
blanchet@35867
   734
wenzelm@28592
   735
end;