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