src/HOL/Tools/ATP/atp_systems.ML
author blanchet
Sat Feb 04 12:08:18 2012 +0100 (2012-02-04)
changeset 46409 d4754183ccce
parent 46407 30e9720cc0b9
child 46427 4fd25dadbd94
permissions -rw-r--r--
made option available to users (mostly for experiments)
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@45301
    10
  type atp_format = ATP_Problem.atp_format
blanchet@42577
    11
  type formula_kind = ATP_Problem.formula_kind
blanchet@39491
    12
  type failure = ATP_Proof.failure
blanchet@38023
    13
blanchet@46409
    14
  type slice_spec = int * atp_format * string * string * bool
blanchet@40059
    15
  type atp_config =
blanchet@42578
    16
    {exec : string * string,
blanchet@42578
    17
     required_execs : (string * string) list,
blanchet@42646
    18
     arguments :
blanchet@43473
    19
       Proof.context -> bool -> string -> Time.time
blanchet@43354
    20
       -> (unit -> (string * real) list) -> string,
blanchet@42578
    21
     proof_delims : (string * string) list,
blanchet@42578
    22
     known_failures : (failure * string) list,
blanchet@42709
    23
     conj_sym_kind : formula_kind,
blanchet@42709
    24
     prem_kind : formula_kind,
blanchet@43473
    25
     best_slices :
blanchet@46409
    26
       Proof.context -> (real * (bool * (slice_spec * string))) list}
blanchet@38023
    27
blanchet@44099
    28
  val force_sos : bool Config.T
blanchet@43566
    29
  val e_smartN : string
blanchet@43566
    30
  val e_autoN : string
blanchet@43566
    31
  val e_fun_weightN : string
blanchet@43566
    32
  val e_sym_offset_weightN : string
blanchet@42646
    33
  val e_weight_method : string Config.T
blanchet@42646
    34
  val e_default_fun_weight : real Config.T
blanchet@42646
    35
  val e_fun_weight_base : real Config.T
blanchet@42646
    36
  val e_fun_weight_span : real Config.T
blanchet@42646
    37
  val e_default_sym_offs_weight : real Config.T
blanchet@42646
    38
  val e_sym_offs_weight_base : real Config.T
blanchet@42646
    39
  val e_sym_offs_weight_span : real Config.T
blanchet@46380
    40
  val spass_incompleteN : string
blanchet@40059
    41
  val eN : string
blanchet@44590
    42
  val e_sineN : string
blanchet@44590
    43
  val e_tofofN : string
blanchet@45338
    44
  val iproverN : string
blanchet@45338
    45
  val iprover_eqN : string
blanchet@44590
    46
  val leo2N : string
blanchet@45365
    47
  val dummy_tff1N : string
blanchet@45365
    48
  val dummy_thfN : string
blanchet@44590
    49
  val satallaxN : string
blanchet@44590
    50
  val snarkN : string
blanchet@40059
    51
  val spassN : string
blanchet@45301
    52
  val spass_newN : string
blanchet@40059
    53
  val vampireN : string
blanchet@42938
    54
  val waldmeisterN : string
blanchet@44423
    55
  val z3_tptpN : string
blanchet@40060
    56
  val remote_prefix : string
blanchet@41738
    57
  val remote_atp :
blanchet@41738
    58
    string -> string -> string list -> (string * string) list
blanchet@44416
    59
    -> (failure * string) list -> formula_kind -> formula_kind
blanchet@46409
    60
    -> (Proof.context -> slice_spec) -> string * atp_config
blanchet@40059
    61
  val add_atp : string * atp_config -> theory -> theory
blanchet@40059
    62
  val get_atp : theory -> string -> atp_config
blanchet@41727
    63
  val supported_atps : theory -> string list
blanchet@40059
    64
  val is_atp_installed : theory -> string -> bool
blanchet@35867
    65
  val refresh_systems_on_tptp : unit -> unit
blanchet@35867
    66
  val setup : theory -> theory
wenzelm@28592
    67
end;
wenzelm@28592
    68
blanchet@36376
    69
structure ATP_Systems : ATP_SYSTEMS =
wenzelm@28592
    70
struct
wenzelm@28596
    71
blanchet@42577
    72
open ATP_Problem
blanchet@39491
    73
open ATP_Proof
blanchet@46320
    74
open ATP_Problem_Generate
boehmes@32864
    75
blanchet@40059
    76
(* ATP configuration *)
boehmes@32864
    77
blanchet@46409
    78
type slice_spec = int * atp_format * string * string * bool
blanchet@46409
    79
blanchet@40059
    80
type atp_config =
blanchet@42578
    81
  {exec : string * string,
blanchet@42578
    82
   required_execs : (string * string) list,
blanchet@42646
    83
   arguments :
blanchet@43473
    84
     Proof.context -> bool -> string -> Time.time
blanchet@43473
    85
     -> (unit -> (string * real) list) -> string,
blanchet@42578
    86
   proof_delims : (string * string) list,
blanchet@42578
    87
   known_failures : (failure * string) list,
blanchet@42709
    88
   conj_sym_kind : formula_kind,
blanchet@42709
    89
   prem_kind : formula_kind,
blanchet@46409
    90
   best_slices : Proof.context -> (real * (bool * (slice_spec * string))) list}
wenzelm@28596
    91
blanchet@42723
    92
(* "best_slices" must be found empirically, taking a wholistic approach since
blanchet@46407
    93
   the ATPs are run in parallel. The "real" component gives the faction of the
blanchet@46409
    94
   time available given to the slice and should add up to 1.0. The first "bool"
blanchet@42723
    95
   component indicates whether the slice's strategy is complete; the "int", the
blanchet@43569
    96
   preferred number of facts to pass; the first "string", the preferred type
blanchet@45521
    97
   system (which should be sound or quasi-sound); the second "string", the
blanchet@46409
    98
   preferred lambda translation scheme; the second "bool", whether uncurried
blanchet@46409
    99
   aliased should be generated; the third "string", extra information to
blanchet@45521
   100
   the prover (e.g., SOS or no SOS).
blanchet@42723
   101
blanchet@42723
   102
   The last slice should be the most "normal" one, because it will get all the
blanchet@43569
   103
   time available if the other slices fail early and also because it is used if
blanchet@43569
   104
   slicing is disabled (e.g., by the minimizer). *)
blanchet@42710
   105
blanchet@38061
   106
val known_perl_failures =
blanchet@38094
   107
  [(CantConnect, "HTTP error"),
blanchet@38094
   108
   (NoPerl, "env: perl"),
blanchet@38065
   109
   (NoLibwwwPerl, "Can't locate HTTP")]
wenzelm@28596
   110
blanchet@45203
   111
fun known_szs_failures wrap =
blanchet@45203
   112
  [(Unprovable, wrap "CounterSatisfiable"),
blanchet@45203
   113
   (Unprovable, wrap "Satisfiable"),
blanchet@45203
   114
   (GaveUp, wrap "GaveUp"),
blanchet@45203
   115
   (GaveUp, wrap "Unknown"),
blanchet@45203
   116
   (GaveUp, wrap "Incomplete"),
blanchet@45203
   117
   (ProofMissing, wrap "Theorem"),
blanchet@45203
   118
   (ProofMissing, wrap "Unsatisfiable"),
blanchet@45203
   119
   (TimedOut, wrap "Timeout"),
blanchet@45203
   120
   (Inappropriate, wrap "Inappropriate"),
blanchet@45203
   121
   (OutOfResources, wrap "ResourceOut"),
blanchet@45203
   122
   (OutOfResources, wrap "MemoryOut"),
blanchet@45203
   123
   (Interrupted, wrap "Forced"),
blanchet@45203
   124
   (Interrupted, wrap "User")]
blanchet@45203
   125
blanchet@45203
   126
val known_szs_status_failures = known_szs_failures (prefix "SZS status ")
blanchet@45203
   127
val known_says_failures = known_szs_failures (prefix " says ")
blanchet@45203
   128
blanchet@40059
   129
(* named ATPs *)
blanchet@40059
   130
blanchet@40059
   131
val eN = "e"
blanchet@44590
   132
val e_sineN = "e_sine"
blanchet@44590
   133
val e_tofofN = "e_tofof"
blanchet@45338
   134
val iproverN = "iprover"
blanchet@45338
   135
val iprover_eqN = "iprover_eq"
blanchet@44099
   136
val leo2N = "leo2"
blanchet@45365
   137
val dummy_tff1N = "dummy_tff1" (* experimental *)
blanchet@45365
   138
val dummy_thfN = "dummy_thf" (* experimental *)
blanchet@44099
   139
val satallaxN = "satallax"
blanchet@44590
   140
val snarkN = "snark"
blanchet@40059
   141
val spassN = "spass"
blanchet@45365
   142
val spass_newN = "spass_new" (* experimental *)
blanchet@40059
   143
val vampireN = "vampire"
blanchet@44590
   144
val waldmeisterN = "waldmeister"
blanchet@44423
   145
val z3_tptpN = "z3_tptp"
blanchet@40060
   146
val remote_prefix = "remote_"
blanchet@38001
   147
blanchet@38023
   148
structure Data = Theory_Data
blanchet@38023
   149
(
blanchet@40059
   150
  type T = (atp_config * stamp) Symtab.table
blanchet@38023
   151
  val empty = Symtab.empty
blanchet@38023
   152
  val extend = I
blanchet@46407
   153
  fun merge data : T =
blanchet@46407
   154
    Symtab.merge (eq_snd (op =)) data
blanchet@38023
   155
    handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@38023
   156
)
blanchet@38017
   157
blanchet@43981
   158
fun to_secs min time = Int.max (min, (Time.toMilliseconds time + 999) div 1000)
blanchet@36142
   159
blanchet@43473
   160
val sosN = "sos"
blanchet@43473
   161
val no_sosN = "no_sos"
blanchet@43473
   162
blanchet@44099
   163
val force_sos = Attrib.setup_config_bool @{binding atp_force_sos} (K false)
blanchet@44099
   164
blanchet@39491
   165
blanchet@40059
   166
(* E *)
wenzelm@28596
   167
blanchet@44420
   168
fun is_old_e_version () = (string_ord (getenv "E_VERSION", "1.2w") = LESS)
blanchet@44420
   169
blanchet@36369
   170
val tstp_proof_delims =
blanchet@42962
   171
  [("# SZS output start CNFRefutation.", "# SZS output end CNFRefutation"),
blanchet@42962
   172
   ("% SZS output start CNFRefutation", "% SZS output end CNFRefutation")]
blanchet@36369
   173
blanchet@43473
   174
val e_smartN = "smart"
blanchet@42646
   175
val e_autoN = "auto"
blanchet@42646
   176
val e_fun_weightN = "fun_weight"
blanchet@42646
   177
val e_sym_offset_weightN = "sym_offset_weight"
blanchet@41725
   178
blanchet@42646
   179
val e_weight_method =
blanchet@43473
   180
  Attrib.setup_config_string @{binding atp_e_weight_method} (K e_smartN)
blanchet@41770
   181
(* FUDGE *)
blanchet@42646
   182
val e_default_fun_weight =
blanchet@42646
   183
  Attrib.setup_config_real @{binding atp_e_default_fun_weight} (K 20.0)
blanchet@42646
   184
val e_fun_weight_base =
blanchet@42646
   185
  Attrib.setup_config_real @{binding atp_e_fun_weight_base} (K 0.0)
blanchet@42646
   186
val e_fun_weight_span =
blanchet@42646
   187
  Attrib.setup_config_real @{binding atp_e_fun_weight_span} (K 40.0)
blanchet@42646
   188
val e_default_sym_offs_weight =
blanchet@42646
   189
  Attrib.setup_config_real @{binding atp_e_default_sym_offs_weight} (K 1.0)
blanchet@42646
   190
val e_sym_offs_weight_base =
blanchet@42646
   191
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_base} (K ~20.0)
blanchet@42646
   192
val e_sym_offs_weight_span =
blanchet@42646
   193
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_span} (K 60.0)
blanchet@41725
   194
blanchet@42443
   195
fun e_weight_method_case method fw sow =
blanchet@42646
   196
  if method = e_fun_weightN then fw
blanchet@42646
   197
  else if method = e_sym_offset_weightN then sow
blanchet@43478
   198
  else raise Fail ("unexpected " ^ quote method)
blanchet@41725
   199
blanchet@42646
   200
fun scaled_e_weight ctxt method w =
blanchet@42646
   201
  w * Config.get ctxt
blanchet@42646
   202
          (e_weight_method_case method e_fun_weight_span e_sym_offs_weight_span)
blanchet@42646
   203
  + Config.get ctxt
blanchet@42646
   204
        (e_weight_method_case method e_fun_weight_base e_sym_offs_weight_base)
blanchet@41725
   205
  |> Real.ceil |> signed_string_of_int
blanchet@41313
   206
blanchet@42646
   207
fun e_weight_arguments ctxt method weights =
blanchet@42646
   208
  if method = e_autoN then
blanchet@41725
   209
    "-xAutoDev"
blanchet@41725
   210
  else
blanchet@43622
   211
    (* supplied by Stephan Schulz *)
blanchet@41314
   212
    "--split-clauses=4 --split-reuse-defs --simul-paramod --forward-context-sr \
blanchet@41314
   213
    \--destructive-er-aggressive --destructive-er --presat-simplify \
blanchet@41314
   214
    \--prefer-initial-clauses -tKBO6 -winvfreqrank -c1 -Ginvfreqconjmax -F1 \
blanchet@41314
   215
    \--delete-bad-limit=150000000 -WSelectMaxLComplexAvoidPosPred \
blanchet@42443
   216
    \-H'(4*" ^ e_weight_method_case method "FunWeight" "SymOffsetWeight" ^
blanchet@41725
   217
    "(SimulateSOS, " ^
blanchet@42646
   218
    (e_weight_method_case method e_default_fun_weight e_default_sym_offs_weight
blanchet@42646
   219
     |> Config.get ctxt |> Real.ceil |> signed_string_of_int) ^
blanchet@41314
   220
    ",20,1.5,1.5,1" ^
blanchet@42646
   221
    (weights ()
blanchet@42646
   222
     |> map (fn (s, w) => "," ^ s ^ ":" ^ scaled_e_weight ctxt method w)
blanchet@42646
   223
     |> implode) ^
blanchet@41314
   224
    "),3*ConjectureGeneralSymbolWeight(PreferNonGoals,200,100,200,50,50,1,100,\
blanchet@41314
   225
    \1.5,1.5,1),1*Clauseweight(PreferProcessed,1,1,1),1*\
blanchet@41314
   226
    \FIFOWeight(PreferProcessed))'"
blanchet@41313
   227
blanchet@42646
   228
fun effective_e_weight_method ctxt =
blanchet@42646
   229
  if is_old_e_version () then e_autoN else Config.get ctxt e_weight_method
blanchet@42443
   230
blanchet@40059
   231
val e_config : atp_config =
blanchet@38092
   232
  {exec = ("E_HOME", "eproof"),
blanchet@38092
   233
   required_execs = [],
blanchet@43354
   234
   arguments =
blanchet@43567
   235
     fn ctxt => fn _ => fn method => fn timeout => fn weights =>
blanchet@43473
   236
        "--tstp-in --tstp-out -l5 " ^ e_weight_arguments ctxt method weights ^
blanchet@43981
   237
        " -tAutoDev --silent --cpu-limit=" ^ string_of_int (to_secs 2 timeout),
blanchet@42962
   238
   proof_delims = tstp_proof_delims,
blanchet@36265
   239
   known_failures =
blanchet@45203
   240
     known_szs_status_failures @
blanchet@45203
   241
     [(TimedOut, "Failure: Resource limit exceeded (time)"),
blanchet@36370
   242
      (TimedOut, "time limit exceeded"),
blanchet@45203
   243
      (OutOfResources, "# Cannot determine problem status")],
blanchet@43466
   244
   conj_sym_kind = Hypothesis,
blanchet@42709
   245
   prem_kind = Conjecture,
blanchet@42646
   246
   best_slices = fn ctxt =>
blanchet@43473
   247
     let val method = effective_e_weight_method ctxt in
blanchet@43474
   248
       (* FUDGE *)
blanchet@43473
   249
       if method = e_smartN then
blanchet@46409
   250
         [(0.333, (true, ((500, FOF, "mono_tags??", combsN, false),
blanchet@46409
   251
                          e_fun_weightN))),
blanchet@46409
   252
          (0.334, (true, ((50, FOF, "mono_guards??", combsN, false),
blanchet@46409
   253
                          e_fun_weightN))),
blanchet@46409
   254
          (0.333, (true, ((1000, FOF, "mono_tags??", combsN, false),
blanchet@45521
   255
                          e_sym_offset_weightN)))]
blanchet@43473
   256
       else
blanchet@46409
   257
         [(1.0, (true, ((500, FOF, "mono_tags??", combsN, false), method)))]
blanchet@43473
   258
     end}
blanchet@38454
   259
blanchet@40059
   260
val e = (eN, e_config)
wenzelm@28596
   261
wenzelm@28596
   262
blanchet@44099
   263
(* LEO-II *)
blanchet@44099
   264
blanchet@44754
   265
val leo2_thf0 = THF (TPTP_Monomorphic, TPTP_Explicit, THF_Without_Choice)
blanchet@44754
   266
blanchet@44099
   267
val leo2_config : atp_config =
blanchet@44099
   268
  {exec = ("LEO2_HOME", "leo"),
blanchet@44099
   269
   required_execs = [],
blanchet@44099
   270
   arguments =
blanchet@44099
   271
     fn _ => fn _ => fn sos => fn timeout => fn _ =>
blanchet@45300
   272
        "--proofoutput 1 --timeout " ^ string_of_int (to_secs 1 timeout)
blanchet@44099
   273
        |> sos = sosN ? prefix "--sos ",
blanchet@44099
   274
   proof_delims = tstp_proof_delims,
blanchet@45207
   275
   known_failures =
blanchet@45207
   276
     known_szs_status_failures @
blanchet@45207
   277
     [(TimedOut, "CPU time limit exceeded, terminating")],
blanchet@44099
   278
   conj_sym_kind = Axiom,
blanchet@44099
   279
   prem_kind = Hypothesis,
blanchet@44099
   280
   best_slices = fn ctxt =>
blanchet@44099
   281
     (* FUDGE *)
blanchet@46409
   282
     [(0.667, (false, ((150, leo2_thf0, "mono_simple_higher", liftingN, false),
blanchet@45521
   283
                       sosN))),
blanchet@46409
   284
      (0.333, (true, ((50, leo2_thf0, "mono_simple_higher", liftingN, false),
blanchet@45521
   285
                      no_sosN)))]
blanchet@44099
   286
     |> (if Config.get ctxt force_sos then hd #> apfst (K 1.0) #> single
blanchet@44099
   287
         else I)}
blanchet@39491
   288
blanchet@44099
   289
val leo2 = (leo2N, leo2_config)
blanchet@44099
   290
blanchet@44099
   291
blanchet@44099
   292
(* Satallax *)
blanchet@44099
   293
blanchet@44754
   294
val satallax_thf0 = THF (TPTP_Monomorphic, TPTP_Explicit, THF_With_Choice)
blanchet@44754
   295
blanchet@44099
   296
val satallax_config : atp_config =
blanchet@44099
   297
  {exec = ("SATALLAX_HOME", "satallax"),
blanchet@44099
   298
   required_execs = [],
blanchet@44099
   299
   arguments =
blanchet@44099
   300
     fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@45162
   301
        "-p hocore -t " ^ string_of_int (to_secs 1 timeout),
blanchet@45162
   302
   proof_delims =
blanchet@45162
   303
     [("% Higher-Order Unsat Core BEGIN", "% Higher-Order Unsat Core END")],
blanchet@45203
   304
   known_failures = known_szs_status_failures,
blanchet@44099
   305
   conj_sym_kind = Axiom,
blanchet@44099
   306
   prem_kind = Hypothesis,
blanchet@44416
   307
   best_slices =
blanchet@44754
   308
     (* FUDGE *)
blanchet@46409
   309
     K [(1.0, (true, ((100, satallax_thf0, "mono_simple_higher", keep_lamsN,
blanchet@46409
   310
                       false), "")))]}
blanchet@44099
   311
blanchet@44099
   312
val satallax = (satallaxN, satallax_config)
blanchet@44099
   313
blanchet@44099
   314
blanchet@44099
   315
(* SPASS *)
blanchet@42725
   316
blanchet@46380
   317
val spass_incompleteN = "incomplete"
blanchet@46380
   318
blanchet@36219
   319
(* The "-VarWeight=3" option helps the higher-order problems, probably by
blanchet@44450
   320
   counteracting the presence of explicit application operators. *)
blanchet@40059
   321
val spass_config : atp_config =
blanchet@38092
   322
  {exec = ("ISABELLE_ATP", "scripts/spass"),
blanchet@39002
   323
   required_execs = [("SPASS_HOME", "SPASS"), ("SPASS_HOME", "tptp2dfg")],
blanchet@43569
   324
   arguments = fn _ => fn _ => fn sos => fn timeout => fn _ =>
blanchet@37962
   325
     ("-Auto -PGiven=0 -PProblem=0 -Splits=0 -FullRed=0 -DocProof \
blanchet@43981
   326
      \-VarWeight=3 -TimeLimit=" ^ string_of_int (to_secs 1 timeout))
blanchet@43473
   327
     |> sos = sosN ? prefix "-SOS=1 ",
blanchet@36369
   328
   proof_delims = [("Here is a proof", "Formulae used in the proof")],
blanchet@36289
   329
   known_failures =
blanchet@38061
   330
     known_perl_failures @
blanchet@43050
   331
     [(GaveUp, "SPASS beiseite: Completion found"),
blanchet@36370
   332
      (TimedOut, "SPASS beiseite: Ran out of time"),
blanchet@36965
   333
      (OutOfResources, "SPASS beiseite: Maximal number of loops exceeded"),
blanchet@37413
   334
      (MalformedInput, "Undefined symbol"),
blanchet@37414
   335
      (MalformedInput, "Free Variable"),
blanchet@44391
   336
      (Unprovable, "No formulae and clauses found in input file"),
blanchet@39263
   337
      (InternalError, "Please report this error")],
blanchet@43466
   338
   conj_sym_kind = Hypothesis,
blanchet@42709
   339
   prem_kind = Conjecture,
blanchet@42725
   340
   best_slices = fn ctxt =>
blanchet@42723
   341
     (* FUDGE *)
blanchet@46409
   342
     [(0.333, (false, ((150, DFG DFG_Unsorted, "mono_tags??", liftingN, false),
blanchet@45521
   343
                       sosN))),
blanchet@46409
   344
      (0.333, (false, ((300, DFG DFG_Unsorted, "poly_tags??", liftingN, false),
blanchet@45521
   345
                       sosN))),
blanchet@46409
   346
      (0.334, (false, ((50, DFG DFG_Unsorted, "mono_tags??", liftingN, false),
blanchet@45876
   347
                       no_sosN)))]
blanchet@44099
   348
     |> (if Config.get ctxt force_sos then hd #> apfst (K 1.0) #> single
blanchet@42725
   349
         else I)}
blanchet@38454
   350
blanchet@40059
   351
val spass = (spassN, spass_config)
wenzelm@28596
   352
blanchet@46409
   353
val spass_new_slice_1 = (300, DFG DFG_Sorted, "mono_simple", combsN, true)
blanchet@46409
   354
val spass_new_slice_2 = (50, DFG DFG_Sorted, "mono_simple", combsN, true)
blanchet@46409
   355
val spass_new_slice_3 = (150, DFG DFG_Sorted, "mono_simple", liftingN, true)
blanchet@46407
   356
blanchet@45301
   357
(* Experimental *)
blanchet@45301
   358
val spass_new_config : atp_config =
blanchet@46370
   359
  {exec = ("ISABELLE_ATP", "scripts/spass_new"),
blanchet@46398
   360
   required_execs =
blanchet@46398
   361
     [("SPASS_NEW_HOME", "SPASS"), ("SPASS_NEW_HOME", "tptp2dfg")],
blanchet@46380
   362
   arguments = fn _ => fn _ => fn incomplete => fn timeout => fn _ =>
blanchet@46402
   363
     ("-Auto -LR=1 -LT=1 -Isabelle=1 -TimeLimit=" ^
blanchet@46402
   364
      string_of_int (to_secs 1 timeout))
blanchet@46380
   365
     |> incomplete = spass_incompleteN ? prefix "-Splits=0 -FullRed=0 ",
blanchet@45301
   366
   proof_delims = #proof_delims spass_config,
blanchet@45301
   367
   known_failures = #known_failures spass_config,
blanchet@45301
   368
   conj_sym_kind = #conj_sym_kind spass_config,
blanchet@45301
   369
   prem_kind = #prem_kind spass_config,
blanchet@46381
   370
   best_slices = fn _ =>
blanchet@45301
   371
     (* FUDGE *)
blanchet@46409
   372
     [(0.300, (true, (spass_new_slice_1, ""))),
blanchet@46409
   373
      (0.333, (true, (spass_new_slice_2, ""))),
blanchet@46409
   374
      (0.333, (true, (spass_new_slice_3, "")))]}
blanchet@45301
   375
blanchet@45301
   376
val spass_new = (spass_newN, spass_new_config)
blanchet@45301
   377
blanchet@38454
   378
blanchet@37509
   379
(* Vampire *)
blanchet@37509
   380
blanchet@44507
   381
(* Vampire 1.8 has TFF support, but it's buggy and therefore disabled on
blanchet@44507
   382
   SystemOnTPTP. *)
blanchet@44420
   383
fun is_old_vampire_version () =
blanchet@44507
   384
  string_ord (getenv "VAMPIRE_VERSION", "1.8") <> GREATER
blanchet@44420
   385
blanchet@44754
   386
val vampire_tff0 = TFF (TPTP_Monomorphic, TPTP_Implicit)
blanchet@44589
   387
blanchet@40059
   388
val vampire_config : atp_config =
blanchet@38092
   389
  {exec = ("VAMPIRE_HOME", "vampire"),
blanchet@38092
   390
   required_execs = [],
blanchet@43569
   391
   arguments = fn _ => fn _ => fn sos => fn timeout => fn _ =>
blanchet@44417
   392
     "--mode casc -t " ^ string_of_int (to_secs 1 timeout) ^
blanchet@45234
   393
     " --proof tptp --output_axiom_names on\
blanchet@45234
   394
     \ --forced_options propositional_to_bdd=off\
blanchet@44417
   395
     \ --thanks \"Andrei and Krystof\" --input_file"
blanchet@43473
   396
     |> sos = sosN ? prefix "--sos on ",
blanchet@37509
   397
   proof_delims =
blanchet@37509
   398
     [("=========== Refutation ==========",
blanchet@37509
   399
       "======= End of refutation ======="),
blanchet@38033
   400
      ("% SZS output start Refutation", "% SZS output end Refutation"),
blanchet@38033
   401
      ("% SZS output start Proof", "% SZS output end Proof")],
blanchet@37509
   402
   known_failures =
blanchet@45203
   403
     known_szs_status_failures @
blanchet@43050
   404
     [(GaveUp, "UNPROVABLE"),
blanchet@43050
   405
      (GaveUp, "CANNOT PROVE"),
blanchet@37509
   406
      (Unprovable, "Satisfiability detected"),
blanchet@38647
   407
      (Unprovable, "Termination reason: Satisfiable"),
blanchet@39263
   408
      (Interrupted, "Aborted by signal SIGINT")],
blanchet@43466
   409
   conj_sym_kind = Conjecture,
blanchet@42709
   410
   prem_kind = Conjecture,
blanchet@42725
   411
   best_slices = fn ctxt =>
blanchet@42723
   412
     (* FUDGE *)
blanchet@44420
   413
     (if is_old_vampire_version () then
blanchet@46409
   414
        [(0.333, (false, ((150, FOF, "poly_guards??", combs_or_liftingN, false),
blanchet@46409
   415
                          sosN))),
blanchet@46409
   416
         (0.333, (false, ((500, FOF, "mono_tags??", combs_or_liftingN, false),
blanchet@46409
   417
                          sosN))),
blanchet@46409
   418
         (0.334, (true, ((50, FOF, "mono_guards??", combs_or_liftingN, false),
blanchet@46407
   419
                         no_sosN)))]
blanchet@44420
   420
      else
blanchet@46407
   421
        [(0.333, (false, ((150, vampire_tff0, "poly_guards??",
blanchet@46409
   422
                           combs_or_liftingN, false), sosN))),
blanchet@46409
   423
         (0.333, (false, ((500, vampire_tff0, "mono_simple", combs_or_liftingN,
blanchet@46409
   424
                           false), sosN))),
blanchet@46409
   425
         (0.334, (true, ((50, vampire_tff0, "mono_simple", combs_or_liftingN,
blanchet@46409
   426
                          false), no_sosN)))])
blanchet@44099
   427
     |> (if Config.get ctxt force_sos then hd #> apfst (K 1.0) #> single
blanchet@42725
   428
         else I)}
blanchet@38454
   429
blanchet@40059
   430
val vampire = (vampireN, vampire_config)
blanchet@37509
   431
blanchet@38454
   432
blanchet@41740
   433
(* Z3 with TPTP syntax *)
blanchet@41740
   434
blanchet@44754
   435
val z3_tff0 = TFF (TPTP_Monomorphic, TPTP_Implicit)
blanchet@44589
   436
blanchet@44423
   437
val z3_tptp_config : atp_config =
blanchet@41740
   438
  {exec = ("Z3_HOME", "z3"),
blanchet@41740
   439
   required_execs = [],
blanchet@43354
   440
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@44420
   441
     "MBQI=true -tptp -t:" ^ string_of_int (to_secs 1 timeout),
blanchet@41740
   442
   proof_delims = [],
blanchet@45203
   443
   known_failures = known_szs_status_failures,
blanchet@42709
   444
   conj_sym_kind = Hypothesis,
blanchet@42709
   445
   prem_kind = Hypothesis,
blanchet@42723
   446
   best_slices =
blanchet@44423
   447
     (* FUDGE *)
blanchet@46409
   448
     K [(0.5, (false, ((250, z3_tff0, "mono_simple", combsN, false), ""))),
blanchet@46409
   449
        (0.25, (false, ((125, z3_tff0, "mono_simple", combsN, false), ""))),
blanchet@46409
   450
        (0.125, (false, ((62, z3_tff0, "mono_simple", combsN, false), ""))),
blanchet@46409
   451
        (0.125, (false, ((31, z3_tff0, "mono_simple", combsN, false), "")))]}
blanchet@41740
   452
blanchet@44423
   453
val z3_tptp = (z3_tptpN, z3_tptp_config)
blanchet@41740
   454
blanchet@44590
   455
blanchet@44754
   456
(* Not really a prover: Experimental Polymorphic TFF and THF output *)
blanchet@44590
   457
blanchet@44754
   458
fun dummy_config format type_enc : atp_config =
blanchet@44596
   459
  {exec = ("ISABELLE_ATP", "scripts/dummy_atp"),
blanchet@44590
   460
   required_execs = [],
blanchet@44590
   461
   arguments = K (K (K (K (K "")))),
blanchet@44590
   462
   proof_delims = [],
blanchet@45203
   463
   known_failures = known_szs_status_failures,
blanchet@44590
   464
   conj_sym_kind = Hypothesis,
blanchet@44590
   465
   prem_kind = Hypothesis,
blanchet@45521
   466
   best_slices =
blanchet@46407
   467
     K [(1.0, (false, ((200, format, type_enc,
blanchet@46407
   468
                        if is_format_higher_order format then keep_lamsN
blanchet@46409
   469
                        else combsN, false), "")))]}
blanchet@44590
   470
blanchet@45365
   471
val dummy_tff1_format = TFF (TPTP_Polymorphic, TPTP_Explicit)
blanchet@45365
   472
val dummy_tff1_config = dummy_config dummy_tff1_format "poly_simple"
blanchet@45365
   473
val dummy_tff1 = (dummy_tff1N, dummy_tff1_config)
blanchet@44590
   474
blanchet@45365
   475
val dummy_thf_format = THF (TPTP_Polymorphic, TPTP_Explicit, THF_With_Choice)
blanchet@45365
   476
val dummy_thf_config = dummy_config dummy_thf_format "poly_simple_higher"
blanchet@45365
   477
val dummy_thf = (dummy_thfN, dummy_thf_config)
blanchet@44754
   478
blanchet@41740
   479
blanchet@40059
   480
(* Remote ATP invocation via SystemOnTPTP *)
wenzelm@28596
   481
blanchet@38061
   482
val systems = Synchronized.var "atp_systems" ([] : string list)
immler@31835
   483
immler@31835
   484
fun get_systems () =
blanchet@44589
   485
  case Isabelle_System.bash_output
blanchet@44589
   486
           "\"$ISABELLE_ATP/scripts/remote_atp\" -w 2>&1" of
blanchet@39491
   487
    (output, 0) => split_lines output
blanchet@39491
   488
  | (output, _) =>
blanchet@39491
   489
    error (case extract_known_failure known_perl_failures output of
blanchet@41744
   490
             SOME failure => string_for_failure failure
blanchet@39491
   491
           | NONE => perhaps (try (unsuffix "\n")) output ^ ".")
immler@31835
   492
blanchet@42537
   493
fun find_system name [] systems =
blanchet@42537
   494
    find_first (String.isPrefix (name ^ "---")) systems
blanchet@38690
   495
  | find_system name (version :: versions) systems =
blanchet@38690
   496
    case find_first (String.isPrefix (name ^ "---" ^ version)) systems of
blanchet@38690
   497
      NONE => find_system name versions systems
blanchet@38690
   498
    | res => res
blanchet@38690
   499
blanchet@38690
   500
fun get_system name versions =
blanchet@38589
   501
  Synchronized.change_result systems
blanchet@38589
   502
      (fn systems => (if null systems then get_systems () else systems)
blanchet@42955
   503
                     |> `(`(find_system name versions)))
boehmes@32864
   504
blanchet@38690
   505
fun the_system name versions =
blanchet@38690
   506
  case get_system name versions of
blanchet@42955
   507
    (SOME sys, _) => sys
blanchet@42955
   508
  | (NONE, []) => error ("SystemOnTPTP is currently not available.")
blanchet@42955
   509
  | (NONE, syss) =>
blanchet@42955
   510
    error ("System " ^ quote name ^ " is not available at SystemOnTPTP.\n" ^
blanchet@42955
   511
           "(Available systems: " ^ commas_quote syss ^ ".)")
immler@31835
   512
blanchet@41148
   513
val max_remote_secs = 240 (* give Geoff Sutcliffe's servers a break *)
blanchet@41148
   514
blanchet@38690
   515
fun remote_config system_name system_versions proof_delims known_failures
blanchet@44416
   516
                  conj_sym_kind prem_kind best_slice : atp_config =
blanchet@38092
   517
  {exec = ("ISABELLE_ATP", "scripts/remote_atp"),
blanchet@38092
   518
   required_execs = [],
blanchet@43354
   519
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@46409
   520
     "-t " ^ string_of_int (Int.min (max_remote_secs, to_secs 1 timeout)) ^
blanchet@46409
   521
     " -s " ^ the_system system_name system_versions,
blanchet@42962
   522
   proof_delims = union (op =) tstp_proof_delims proof_delims,
blanchet@45203
   523
   known_failures = known_failures @ known_perl_failures @ known_says_failures,
blanchet@42709
   524
   conj_sym_kind = conj_sym_kind,
blanchet@42709
   525
   prem_kind = prem_kind,
blanchet@46409
   526
   best_slices = fn ctxt => [(1.0, (false, (best_slice ctxt, "")))]}
blanchet@42443
   527
blanchet@43500
   528
fun remotify_config system_name system_versions best_slice
blanchet@44416
   529
        ({proof_delims, known_failures, conj_sym_kind, prem_kind, ...}
blanchet@43500
   530
         : atp_config) : atp_config =
blanchet@38690
   531
  remote_config system_name system_versions proof_delims known_failures
blanchet@44416
   532
                conj_sym_kind prem_kind best_slice
blanchet@38023
   533
blanchet@40059
   534
fun remote_atp name system_name system_versions proof_delims known_failures
blanchet@44416
   535
               conj_sym_kind prem_kind best_slice =
blanchet@40060
   536
  (remote_prefix ^ name,
blanchet@38690
   537
   remote_config system_name system_versions proof_delims known_failures
blanchet@44416
   538
                 conj_sym_kind prem_kind best_slice)
blanchet@43500
   539
fun remotify_atp (name, config) system_name system_versions best_slice =
blanchet@43500
   540
  (remote_prefix ^ name,
blanchet@43500
   541
   remotify_config system_name system_versions best_slice config)
wenzelm@28592
   542
blanchet@44754
   543
val explicit_tff0 = TFF (TPTP_Monomorphic, TPTP_Explicit)
blanchet@44589
   544
blanchet@43500
   545
val remote_e =
blanchet@43500
   546
  remotify_atp e "EP" ["1.0", "1.1", "1.2"]
blanchet@46409
   547
      (K (750, FOF, "mono_tags??", combsN, false) (* FUDGE *))
blanchet@44099
   548
val remote_leo2 =
blanchet@44099
   549
  remotify_atp leo2 "LEO-II" ["1.2.8", "1.2.6"]
blanchet@46409
   550
      (K (100, leo2_thf0, "mono_simple_higher", liftingN, false) (* FUDGE *))
blanchet@44099
   551
val remote_satallax =
blanchet@44099
   552
  remotify_atp satallax "Satallax" ["2.1", "2.0", "2"]
blanchet@46409
   553
      (K (100, satallax_thf0, "mono_simple_higher", keep_lamsN, false)
blanchet@46409
   554
         (* FUDGE *))
blanchet@43500
   555
val remote_vampire =
blanchet@44499
   556
  remotify_atp vampire "Vampire" ["1.8"]
blanchet@46409
   557
      (K (250, FOF, "mono_guards??", combs_or_liftingN, false) (* FUDGE *))
blanchet@44423
   558
val remote_z3_tptp =
blanchet@44754
   559
  remotify_atp z3_tptp "Z3" ["3.0"]
blanchet@46409
   560
      (K (250, z3_tff0, "mono_simple", combsN, false) (* FUDGE *))
blanchet@44092
   561
val remote_e_sine =
blanchet@44092
   562
  remote_atp e_sineN "SInE" ["0.4"] [] (#known_failures e_config) Axiom
blanchet@46409
   563
      Conjecture (K (500, FOF, "mono_guards??", combsN, false) (* FUDGE *))
blanchet@45338
   564
val remote_iprover =
blanchet@45338
   565
  remote_atp iproverN "iProver" [] [] [] Axiom Conjecture
blanchet@46409
   566
      (K (150, FOF, "mono_guards??", liftingN, false) (* FUDGE *))
blanchet@45338
   567
val remote_iprover_eq =
blanchet@45338
   568
  remote_atp iprover_eqN "iProver-Eq" [] [] [] Axiom Conjecture
blanchet@46409
   569
      (K (150, FOF, "mono_guards??", liftingN, false) (* FUDGE *))
blanchet@41740
   570
val remote_snark =
blanchet@42939
   571
  remote_atp snarkN "SNARK" ["20080805r029", "20080805r024"]
blanchet@45521
   572
      [("refutation.", "end_refutation.")] [] Hypothesis Hypothesis
blanchet@46409
   573
      (K (100, explicit_tff0, "mono_simple", liftingN, false) (* FUDGE *))
blanchet@44092
   574
val remote_e_tofof =
blanchet@44589
   575
  remote_atp e_tofofN "ToFoF" ["0.1"] [] (#known_failures e_config) Axiom
blanchet@45521
   576
      Hypothesis
blanchet@46409
   577
      (K (150, explicit_tff0, "mono_simple", liftingN, false) (* FUDGE *))
blanchet@42938
   578
val remote_waldmeister =
blanchet@42938
   579
  remote_atp waldmeisterN "Waldmeister" ["710"]
blanchet@45521
   580
      [("#START OF PROOF", "Proved Goals:")]
blanchet@45521
   581
      [(OutOfResources, "Too many function symbols"),
blanchet@45521
   582
       (Crashed, "Unrecoverable Segmentation Fault")]
blanchet@45521
   583
      Hypothesis Hypothesis
blanchet@46409
   584
      (K (50, CNF_UEQ, "mono_tags??", combsN, false) (* FUDGE *))
blanchet@38454
   585
blanchet@38454
   586
(* Setup *)
blanchet@38454
   587
blanchet@40059
   588
fun add_atp (name, config) thy =
blanchet@40059
   589
  Data.map (Symtab.update_new (name, (config, stamp ()))) thy
blanchet@40059
   590
  handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@40059
   591
blanchet@40059
   592
fun get_atp thy name =
blanchet@40059
   593
  the (Symtab.lookup (Data.get thy) name) |> fst
blanchet@40059
   594
  handle Option.Option => error ("Unknown ATP: " ^ name ^ ".")
blanchet@40059
   595
blanchet@41727
   596
val supported_atps = Symtab.keys o Data.get
blanchet@36371
   597
blanchet@40059
   598
fun is_atp_installed thy name =
blanchet@40059
   599
  let val {exec, required_execs, ...} = get_atp thy name in
blanchet@40059
   600
    forall (curry (op <>) "" o getenv o fst) (exec :: required_execs)
blanchet@40059
   601
  end
blanchet@36371
   602
blanchet@40059
   603
fun refresh_systems_on_tptp () =
blanchet@40059
   604
  Synchronized.change systems (fn _ => get_systems ())
blanchet@40059
   605
blanchet@42962
   606
val atps =
blanchet@45365
   607
  [e, leo2, dummy_tff1, dummy_thf, satallax, spass, spass_new, vampire, z3_tptp,
blanchet@45365
   608
   remote_e, remote_e_sine, remote_e_tofof, remote_iprover, remote_iprover_eq,
blanchet@45339
   609
   remote_leo2, remote_satallax, remote_vampire, remote_z3_tptp, remote_snark,
blanchet@45339
   610
   remote_waldmeister]
blanchet@40059
   611
val setup = fold add_atp atps
blanchet@35867
   612
wenzelm@28592
   613
end;