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