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