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