src/HOL/Tools/ATP/atp_systems.ML
author blanchet
Mon Jun 27 13:52:47 2011 +0200 (2011-06-27)
changeset 43567 dda3e38cc351
parent 43566 a818d5a34cca
child 43569 b342cd125533
permissions -rw-r--r--
remove experimental trimming feature -- it slowed down things on Linux for some reason
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@42578
    24
     formats : format list,
blanchet@43473
    25
     best_slices :
blanchet@43473
    26
       Proof.context -> (real * (bool * (int * string list * string))) list}
blanchet@38023
    27
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@42725
    39
  val spass_force_sos : bool Config.T
blanchet@42725
    40
  val vampire_force_sos : bool Config.T
blanchet@40059
    41
  val eN : string
blanchet@40059
    42
  val spassN : string
blanchet@40059
    43
  val vampireN : string
blanchet@42962
    44
  val leo2N : string
blanchet@42962
    45
  val satallaxN : string
blanchet@40059
    46
  val sine_eN : string
blanchet@40059
    47
  val snarkN : string
blanchet@42962
    48
  val tofof_eN : string
blanchet@42938
    49
  val waldmeisterN : string
blanchet@41738
    50
  val z3_atpN : string
blanchet@40060
    51
  val remote_prefix : string
blanchet@41738
    52
  val remote_atp :
blanchet@41738
    53
    string -> string -> string list -> (string * string) list
blanchet@42709
    54
    -> (failure * string) list -> formula_kind -> formula_kind -> format list
blanchet@42723
    55
    -> (Proof.context -> int * string list) -> string * atp_config
blanchet@40059
    56
  val add_atp : string * atp_config -> theory -> theory
blanchet@40059
    57
  val get_atp : theory -> string -> atp_config
blanchet@41727
    58
  val supported_atps : theory -> string list
blanchet@40059
    59
  val is_atp_installed : theory -> string -> bool
blanchet@35867
    60
  val refresh_systems_on_tptp : unit -> unit
blanchet@35867
    61
  val setup : theory -> theory
wenzelm@28592
    62
end;
wenzelm@28592
    63
blanchet@36376
    64
structure ATP_Systems : ATP_SYSTEMS =
wenzelm@28592
    65
struct
wenzelm@28596
    66
blanchet@42577
    67
open ATP_Problem
blanchet@39491
    68
open ATP_Proof
boehmes@32864
    69
blanchet@40059
    70
(* ATP configuration *)
boehmes@32864
    71
blanchet@40059
    72
type atp_config =
blanchet@42578
    73
  {exec : string * string,
blanchet@42578
    74
   required_execs : (string * string) list,
blanchet@42646
    75
   arguments :
blanchet@43473
    76
     Proof.context -> bool -> string -> Time.time
blanchet@43473
    77
     -> (unit -> (string * real) list) -> string,
blanchet@42578
    78
   proof_delims : (string * string) list,
blanchet@42578
    79
   known_failures : (failure * string) list,
blanchet@42709
    80
   conj_sym_kind : formula_kind,
blanchet@42709
    81
   prem_kind : formula_kind,
blanchet@42578
    82
   formats : format list,
blanchet@43473
    83
   best_slices :
blanchet@43473
    84
     Proof.context -> (real * (bool * (int * string list * string))) list}
wenzelm@28596
    85
blanchet@42723
    86
(* "best_slices" must be found empirically, taking a wholistic approach since
blanchet@42723
    87
   the ATPs are run in parallel. The "real" components give the faction of the
blanchet@42723
    88
   time available given to the slice; these should add up to 1.0. The "bool"
blanchet@42723
    89
   component indicates whether the slice's strategy is complete; the "int", the
blanchet@42723
    90
   preferred number of facts to pass; the "string list", the preferred type
blanchet@42723
    91
   systems, which should be of the form [sound] or [unsound, sound], where
blanchet@42723
    92
   "sound" is a sound type system and "unsound" is an unsound one.
blanchet@42723
    93
blanchet@42723
    94
   The last slice should be the most "normal" one, because it will get all the
blanchet@42723
    95
   time available if the other slices fail early and also because it is used for
blanchet@42723
    96
   remote provers and if slicing is disabled. *)
blanchet@42710
    97
blanchet@38061
    98
val known_perl_failures =
blanchet@38094
    99
  [(CantConnect, "HTTP error"),
blanchet@38094
   100
   (NoPerl, "env: perl"),
blanchet@38065
   101
   (NoLibwwwPerl, "Can't locate HTTP")]
wenzelm@28596
   102
blanchet@40059
   103
(* named ATPs *)
blanchet@40059
   104
blanchet@40059
   105
val eN = "e"
blanchet@40059
   106
val spassN = "spass"
blanchet@40059
   107
val vampireN = "vampire"
blanchet@41740
   108
val z3_atpN = "z3_atp"
blanchet@42962
   109
val leo2N = "leo2"
blanchet@42962
   110
val satallaxN = "satallax"
blanchet@40059
   111
val sine_eN = "sine_e"
blanchet@40059
   112
val snarkN = "snark"
blanchet@42962
   113
val tofof_eN = "tofof_e"
blanchet@42938
   114
val waldmeisterN = "waldmeister"
blanchet@40060
   115
val remote_prefix = "remote_"
blanchet@38001
   116
blanchet@38023
   117
structure Data = Theory_Data
blanchet@38023
   118
(
blanchet@40059
   119
  type T = (atp_config * stamp) Symtab.table
blanchet@38023
   120
  val empty = Symtab.empty
blanchet@38023
   121
  val extend = I
blanchet@38023
   122
  fun merge data : T = Symtab.merge (eq_snd op =) data
blanchet@38023
   123
    handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@38023
   124
)
blanchet@38017
   125
blanchet@43056
   126
fun to_secs time = (Time.toMilliseconds time + 999) div 1000
blanchet@36142
   127
blanchet@43473
   128
val sosN = "sos"
blanchet@43473
   129
val no_sosN = "no_sos"
blanchet@43473
   130
blanchet@39491
   131
blanchet@40059
   132
(* E *)
wenzelm@28596
   133
blanchet@36369
   134
val tstp_proof_delims =
blanchet@42962
   135
  [("# SZS output start CNFRefutation.", "# SZS output end CNFRefutation"),
blanchet@42962
   136
   ("% SZS output start CNFRefutation", "% SZS output end CNFRefutation")]
blanchet@36369
   137
blanchet@43473
   138
val e_smartN = "smart"
blanchet@42646
   139
val e_autoN = "auto"
blanchet@42646
   140
val e_fun_weightN = "fun_weight"
blanchet@42646
   141
val e_sym_offset_weightN = "sym_offset_weight"
blanchet@41725
   142
blanchet@42646
   143
val e_weight_method =
blanchet@43473
   144
  Attrib.setup_config_string @{binding atp_e_weight_method} (K e_smartN)
blanchet@41770
   145
(* FUDGE *)
blanchet@42646
   146
val e_default_fun_weight =
blanchet@42646
   147
  Attrib.setup_config_real @{binding atp_e_default_fun_weight} (K 20.0)
blanchet@42646
   148
val e_fun_weight_base =
blanchet@42646
   149
  Attrib.setup_config_real @{binding atp_e_fun_weight_base} (K 0.0)
blanchet@42646
   150
val e_fun_weight_span =
blanchet@42646
   151
  Attrib.setup_config_real @{binding atp_e_fun_weight_span} (K 40.0)
blanchet@42646
   152
val e_default_sym_offs_weight =
blanchet@42646
   153
  Attrib.setup_config_real @{binding atp_e_default_sym_offs_weight} (K 1.0)
blanchet@42646
   154
val e_sym_offs_weight_base =
blanchet@42646
   155
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_base} (K ~20.0)
blanchet@42646
   156
val e_sym_offs_weight_span =
blanchet@42646
   157
  Attrib.setup_config_real @{binding atp_e_sym_offs_weight_span} (K 60.0)
blanchet@41725
   158
blanchet@42443
   159
fun e_weight_method_case method fw sow =
blanchet@42646
   160
  if method = e_fun_weightN then fw
blanchet@42646
   161
  else if method = e_sym_offset_weightN then sow
blanchet@43478
   162
  else raise Fail ("unexpected " ^ quote method)
blanchet@41725
   163
blanchet@42646
   164
fun scaled_e_weight ctxt method w =
blanchet@42646
   165
  w * Config.get ctxt
blanchet@42646
   166
          (e_weight_method_case method e_fun_weight_span e_sym_offs_weight_span)
blanchet@42646
   167
  + Config.get ctxt
blanchet@42646
   168
        (e_weight_method_case method e_fun_weight_base e_sym_offs_weight_base)
blanchet@41725
   169
  |> Real.ceil |> signed_string_of_int
blanchet@41313
   170
blanchet@42646
   171
fun e_weight_arguments ctxt method weights =
blanchet@42646
   172
  if method = e_autoN then
blanchet@41725
   173
    "-xAutoDev"
blanchet@41725
   174
  else
blanchet@41314
   175
    "--split-clauses=4 --split-reuse-defs --simul-paramod --forward-context-sr \
blanchet@41314
   176
    \--destructive-er-aggressive --destructive-er --presat-simplify \
blanchet@41314
   177
    \--prefer-initial-clauses -tKBO6 -winvfreqrank -c1 -Ginvfreqconjmax -F1 \
blanchet@41314
   178
    \--delete-bad-limit=150000000 -WSelectMaxLComplexAvoidPosPred \
blanchet@42443
   179
    \-H'(4*" ^ e_weight_method_case method "FunWeight" "SymOffsetWeight" ^
blanchet@41725
   180
    "(SimulateSOS, " ^
blanchet@42646
   181
    (e_weight_method_case method e_default_fun_weight e_default_sym_offs_weight
blanchet@42646
   182
     |> Config.get ctxt |> Real.ceil |> signed_string_of_int) ^
blanchet@41314
   183
    ",20,1.5,1.5,1" ^
blanchet@42646
   184
    (weights ()
blanchet@42646
   185
     |> map (fn (s, w) => "," ^ s ^ ":" ^ scaled_e_weight ctxt method w)
blanchet@42646
   186
     |> implode) ^
blanchet@41314
   187
    "),3*ConjectureGeneralSymbolWeight(PreferNonGoals,200,100,200,50,50,1,100,\
blanchet@41314
   188
    \1.5,1.5,1),1*Clauseweight(PreferProcessed,1,1,1),1*\
blanchet@41314
   189
    \FIFOWeight(PreferProcessed))'"
blanchet@41313
   190
blanchet@42443
   191
fun is_old_e_version () = (string_ord (getenv "E_VERSION", "1.2w") = LESS)
blanchet@42443
   192
blanchet@42646
   193
fun effective_e_weight_method ctxt =
blanchet@42646
   194
  if is_old_e_version () then e_autoN else Config.get ctxt e_weight_method
blanchet@42443
   195
blanchet@40059
   196
val e_config : atp_config =
blanchet@38092
   197
  {exec = ("E_HOME", "eproof"),
blanchet@38092
   198
   required_execs = [],
blanchet@43354
   199
   arguments =
blanchet@43567
   200
     fn ctxt => fn _ => fn method => fn timeout => fn weights =>
blanchet@43473
   201
        "--tstp-in --tstp-out -l5 " ^ e_weight_arguments ctxt method weights ^
blanchet@43567
   202
        " -tAutoDev --silent --cpu-limit=" ^ string_of_int (to_secs timeout),
blanchet@42962
   203
   proof_delims = tstp_proof_delims,
blanchet@36265
   204
   known_failures =
blanchet@37995
   205
     [(Unprovable, "SZS status: CounterSatisfiable"),
blanchet@37995
   206
      (Unprovable, "SZS status CounterSatisfiable"),
blanchet@42844
   207
      (ProofMissing, "SZS status Theorem"),
blanchet@36370
   208
      (TimedOut, "Failure: Resource limit exceeded (time)"),
blanchet@36370
   209
      (TimedOut, "time limit exceeded"),
blanchet@43467
   210
      (OutOfResources, "# Cannot determine problem status"),
blanchet@36370
   211
      (OutOfResources, "SZS status: ResourceOut"),
blanchet@36370
   212
      (OutOfResources, "SZS status ResourceOut")],
blanchet@43466
   213
   conj_sym_kind = Hypothesis,
blanchet@42709
   214
   prem_kind = Conjecture,
blanchet@42937
   215
   formats = [FOF],
blanchet@42646
   216
   best_slices = fn ctxt =>
blanchet@43473
   217
     let val method = effective_e_weight_method ctxt in
blanchet@43474
   218
       (* FUDGE *)
blanchet@43473
   219
       if method = e_smartN then
blanchet@43478
   220
         [(0.333, (true, (500, ["mangled_tags?"], e_fun_weightN))),
blanchet@43497
   221
          (0.334, (true, (50, ["mangled_preds?"], e_fun_weightN))),
blanchet@43497
   222
          (0.333, (true, (1000, ["mangled_tags?"], e_sym_offset_weightN)))]
blanchet@43473
   223
       else
blanchet@43497
   224
         [(1.0, (true, (500, ["mangled_tags?"], method)))]
blanchet@43473
   225
     end}
blanchet@38454
   226
blanchet@40059
   227
val e = (eN, e_config)
wenzelm@28596
   228
wenzelm@28596
   229
blanchet@39491
   230
(* SPASS *)
blanchet@39491
   231
blanchet@42725
   232
val spass_force_sos =
blanchet@42725
   233
  Attrib.setup_config_bool @{binding atp_spass_force_sos} (K false)
blanchet@42725
   234
blanchet@36219
   235
(* The "-VarWeight=3" option helps the higher-order problems, probably by
blanchet@36219
   236
   counteracting the presence of "hAPP". *)
blanchet@40059
   237
val spass_config : atp_config =
blanchet@38092
   238
  {exec = ("ISABELLE_ATP", "scripts/spass"),
blanchet@39002
   239
   required_execs = [("SPASS_HOME", "SPASS"), ("SPASS_HOME", "tptp2dfg")],
blanchet@43473
   240
   arguments = fn ctxt => fn _ => fn sos => fn timeout => fn _ =>
blanchet@37962
   241
     ("-Auto -PGiven=0 -PProblem=0 -Splits=0 -FullRed=0 -DocProof \
blanchet@43056
   242
      \-VarWeight=3 -TimeLimit=" ^ string_of_int (to_secs timeout))
blanchet@43473
   243
     |> sos = sosN ? prefix "-SOS=1 ",
blanchet@36369
   244
   proof_delims = [("Here is a proof", "Formulae used in the proof")],
blanchet@36289
   245
   known_failures =
blanchet@38061
   246
     known_perl_failures @
blanchet@43050
   247
     [(GaveUp, "SPASS beiseite: Completion found"),
blanchet@36370
   248
      (TimedOut, "SPASS beiseite: Ran out of time"),
blanchet@36965
   249
      (OutOfResources, "SPASS beiseite: Maximal number of loops exceeded"),
blanchet@37413
   250
      (MalformedInput, "Undefined symbol"),
blanchet@37414
   251
      (MalformedInput, "Free Variable"),
blanchet@39263
   252
      (SpassTooOld, "tptp2dfg"),
blanchet@39263
   253
      (InternalError, "Please report this error")],
blanchet@43466
   254
   conj_sym_kind = Hypothesis,
blanchet@42709
   255
   prem_kind = Conjecture,
blanchet@42937
   256
   formats = [FOF],
blanchet@42725
   257
   best_slices = fn ctxt =>
blanchet@42723
   258
     (* FUDGE *)
blanchet@43497
   259
     [(0.333, (false, (150, ["mangled_tags"], sosN))),
blanchet@43497
   260
      (0.333, (false, (300, ["poly_tags?"], sosN))),
blanchet@43475
   261
      (0.334, (true, (50, ["mangled_tags?"], no_sosN)))]
blanchet@42725
   262
     |> (if Config.get ctxt spass_force_sos then hd #> apfst (K 1.0) #> single
blanchet@42725
   263
         else I)}
blanchet@38454
   264
blanchet@40059
   265
val spass = (spassN, spass_config)
wenzelm@28596
   266
blanchet@38454
   267
blanchet@37509
   268
(* Vampire *)
blanchet@37509
   269
blanchet@42725
   270
val vampire_force_sos =
blanchet@42725
   271
  Attrib.setup_config_bool @{binding atp_vampire_force_sos} (K false)
blanchet@42725
   272
blanchet@40059
   273
val vampire_config : atp_config =
blanchet@38092
   274
  {exec = ("VAMPIRE_HOME", "vampire"),
blanchet@38092
   275
   required_execs = [],
blanchet@43473
   276
   arguments = fn ctxt => fn _ => fn sos => fn timeout => fn _ =>
blanchet@43056
   277
     "--proof tptp --mode casc -t " ^ string_of_int (to_secs timeout) ^
blanchet@41203
   278
     " --thanks \"Andrei and Krystof\" --input_file"
blanchet@43473
   279
     |> sos = sosN ? prefix "--sos on ",
blanchet@37509
   280
   proof_delims =
blanchet@37509
   281
     [("=========== Refutation ==========",
blanchet@37509
   282
       "======= End of refutation ======="),
blanchet@38033
   283
      ("% SZS output start Refutation", "% SZS output end Refutation"),
blanchet@38033
   284
      ("% SZS output start Proof", "% SZS output end Proof")],
blanchet@37509
   285
   known_failures =
blanchet@43050
   286
     [(GaveUp, "UNPROVABLE"),
blanchet@43050
   287
      (GaveUp, "CANNOT PROVE"),
blanchet@43050
   288
      (GaveUp, "SZS status GaveUp"),
blanchet@42882
   289
      (ProofIncomplete, "predicate_definition_introduction,[]"),
blanchet@38092
   290
      (TimedOut, "SZS status Timeout"),
blanchet@37509
   291
      (Unprovable, "Satisfiability detected"),
blanchet@38647
   292
      (Unprovable, "Termination reason: Satisfiable"),
blanchet@39263
   293
      (VampireTooOld, "not a valid option"),
blanchet@39263
   294
      (Interrupted, "Aborted by signal SIGINT")],
blanchet@43466
   295
   conj_sym_kind = Conjecture,
blanchet@42709
   296
   prem_kind = Conjecture,
blanchet@42937
   297
   formats = [FOF],
blanchet@42725
   298
   best_slices = fn ctxt =>
blanchet@42723
   299
     (* FUDGE *)
blanchet@43497
   300
     [(0.333, (false, (150, ["poly_preds"], sosN))),
blanchet@43497
   301
      (0.334, (true, (50, ["mangled_preds?"], no_sosN))),
blanchet@43497
   302
      (0.333, (false, (500, ["mangled_tags?"], sosN)))]
blanchet@42725
   303
     |> (if Config.get ctxt vampire_force_sos then hd #> apfst (K 1.0) #> single
blanchet@42725
   304
         else I)}
blanchet@38454
   305
blanchet@40059
   306
val vampire = (vampireN, vampire_config)
blanchet@37509
   307
blanchet@38454
   308
blanchet@41740
   309
(* Z3 with TPTP syntax *)
blanchet@41740
   310
blanchet@41740
   311
val z3_atp_config : atp_config =
blanchet@41740
   312
  {exec = ("Z3_HOME", "z3"),
blanchet@41740
   313
   required_execs = [],
blanchet@43354
   314
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@43056
   315
     "MBQI=true -p -t:" ^ string_of_int (to_secs timeout),
blanchet@41740
   316
   proof_delims = [],
blanchet@41740
   317
   known_failures =
blanchet@41742
   318
     [(Unprovable, "\nsat"),
blanchet@43050
   319
      (GaveUp, "\nunknown"),
blanchet@43050
   320
      (GaveUp, "SZS status Satisfiable"),
blanchet@42443
   321
      (ProofMissing, "\nunsat"),
blanchet@42443
   322
      (ProofMissing, "SZS status Unsatisfiable")],
blanchet@42709
   323
   conj_sym_kind = Hypothesis,
blanchet@42709
   324
   prem_kind = Hypothesis,
blanchet@42937
   325
   formats = [FOF],
blanchet@42723
   326
   best_slices =
blanchet@42723
   327
     (* FUDGE (FIXME) *)
blanchet@43473
   328
     K [(1.0, (false, (250, [], "")))]}
blanchet@41740
   329
blanchet@41740
   330
val z3_atp = (z3_atpN, z3_atp_config)
blanchet@41740
   331
blanchet@41740
   332
blanchet@40059
   333
(* Remote ATP invocation via SystemOnTPTP *)
wenzelm@28596
   334
blanchet@38061
   335
val systems = Synchronized.var "atp_systems" ([] : string list)
immler@31835
   336
immler@31835
   337
fun get_systems () =
blanchet@38061
   338
  case bash_output "\"$ISABELLE_ATP/scripts/remote_atp\" -w 2>&1" of
blanchet@39491
   339
    (output, 0) => split_lines output
blanchet@39491
   340
  | (output, _) =>
blanchet@39491
   341
    error (case extract_known_failure known_perl_failures output of
blanchet@41744
   342
             SOME failure => string_for_failure failure
blanchet@39491
   343
           | NONE => perhaps (try (unsuffix "\n")) output ^ ".")
immler@31835
   344
blanchet@42537
   345
fun find_system name [] systems =
blanchet@42537
   346
    find_first (String.isPrefix (name ^ "---")) systems
blanchet@38690
   347
  | find_system name (version :: versions) systems =
blanchet@38690
   348
    case find_first (String.isPrefix (name ^ "---" ^ version)) systems of
blanchet@38690
   349
      NONE => find_system name versions systems
blanchet@38690
   350
    | res => res
blanchet@38690
   351
blanchet@38690
   352
fun get_system name versions =
blanchet@38589
   353
  Synchronized.change_result systems
blanchet@38589
   354
      (fn systems => (if null systems then get_systems () else systems)
blanchet@42955
   355
                     |> `(`(find_system name versions)))
boehmes@32864
   356
blanchet@38690
   357
fun the_system name versions =
blanchet@38690
   358
  case get_system name versions of
blanchet@42955
   359
    (SOME sys, _) => sys
blanchet@42955
   360
  | (NONE, []) => error ("SystemOnTPTP is currently not available.")
blanchet@42955
   361
  | (NONE, syss) =>
blanchet@42955
   362
    error ("System " ^ quote name ^ " is not available at SystemOnTPTP.\n" ^
blanchet@42955
   363
           "(Available systems: " ^ commas_quote syss ^ ".)")
immler@31835
   364
blanchet@41148
   365
val max_remote_secs = 240 (* give Geoff Sutcliffe's servers a break *)
blanchet@41148
   366
blanchet@38690
   367
fun remote_config system_name system_versions proof_delims known_failures
blanchet@42723
   368
                  conj_sym_kind prem_kind formats best_slice : atp_config =
blanchet@38092
   369
  {exec = ("ISABELLE_ATP", "scripts/remote_atp"),
blanchet@38092
   370
   required_execs = [],
blanchet@43354
   371
   arguments = fn _ => fn _ => fn _ => fn timeout => fn _ =>
blanchet@43056
   372
     "-t " ^ string_of_int (Int.min (max_remote_secs, to_secs timeout))
blanchet@41148
   373
     ^ " -s " ^ the_system system_name system_versions,
blanchet@42962
   374
   proof_delims = union (op =) tstp_proof_delims proof_delims,
blanchet@42965
   375
   known_failures = known_failures @ known_perl_failures @
blanchet@42941
   376
     [(Unprovable, "says Satisfiable"),
blanchet@42999
   377
      (Unprovable, "says CounterSatisfiable"),
blanchet@43050
   378
      (GaveUp, "says Unknown"),
blanchet@43050
   379
      (GaveUp, "says GaveUp"),
blanchet@42965
   380
      (ProofMissing, "says Theorem"),
blanchet@42999
   381
      (ProofMissing, "says Unsatisfiable"),
blanchet@42953
   382
      (TimedOut, "says Timeout"),
blanchet@42953
   383
      (Inappropriate, "says Inappropriate")],
blanchet@42709
   384
   conj_sym_kind = conj_sym_kind,
blanchet@42709
   385
   prem_kind = prem_kind,
blanchet@42578
   386
   formats = formats,
blanchet@43473
   387
   best_slices = fn ctxt =>
blanchet@43473
   388
     let val (max_relevant, type_syss) = best_slice ctxt in
blanchet@43473
   389
       [(1.0, (false, (max_relevant, type_syss, "")))]
blanchet@43473
   390
     end}
blanchet@42443
   391
blanchet@43500
   392
fun remotify_config system_name system_versions best_slice
blanchet@43500
   393
        ({proof_delims, known_failures, conj_sym_kind, prem_kind, formats, ...}
blanchet@43500
   394
         : atp_config) : atp_config =
blanchet@38690
   395
  remote_config system_name system_versions proof_delims known_failures
blanchet@43500
   396
                conj_sym_kind prem_kind formats best_slice
blanchet@38023
   397
blanchet@40059
   398
fun remote_atp name system_name system_versions proof_delims known_failures
blanchet@42723
   399
        conj_sym_kind prem_kind formats best_slice =
blanchet@40060
   400
  (remote_prefix ^ name,
blanchet@38690
   401
   remote_config system_name system_versions proof_delims known_failures
blanchet@42723
   402
                 conj_sym_kind prem_kind formats best_slice)
blanchet@43500
   403
fun remotify_atp (name, config) system_name system_versions best_slice =
blanchet@43500
   404
  (remote_prefix ^ name,
blanchet@43500
   405
   remotify_config system_name system_versions best_slice config)
wenzelm@28592
   406
blanchet@43500
   407
val remote_e =
blanchet@43500
   408
  remotify_atp e "EP" ["1.0", "1.1", "1.2"]
blanchet@43500
   409
               (K (750, ["mangled_tags?"]) (* FUDGE *))
blanchet@43500
   410
val remote_vampire =
blanchet@43500
   411
  remotify_atp vampire "Vampire" ["0.6", "9.0", "1.0"]
blanchet@43529
   412
               (K (200, ["mangled_preds?"]) (* FUDGE *))
blanchet@43500
   413
val remote_z3_atp =
blanchet@43500
   414
  remotify_atp z3_atp "Z3" ["2.18"] (K (250, ["mangled_preds?"]) (* FUDGE *))
blanchet@42962
   415
val remote_leo2 =
blanchet@42962
   416
  remote_atp leo2N "LEO-II" ["1.2.6"] [] [] Axiom Hypothesis [THF]
blanchet@42971
   417
             (K (100, ["simple"]) (* FUDGE *))
blanchet@42962
   418
val remote_satallax =
blanchet@42962
   419
  remote_atp satallaxN "Satallax" ["2.0"] [] [] Axiom Hypothesis [THF]
blanchet@42971
   420
             (K (64, ["simple"]) (* FUDGE *))
blanchet@41740
   421
val remote_sine_e =
blanchet@42962
   422
  remote_atp sine_eN "SInE" ["0.4"] [] (#known_failures e_config)
blanchet@42962
   423
             Axiom Conjecture [FOF]
blanchet@43529
   424
             (K (500, ["mangled_preds?"]) (* FUDGE *))
blanchet@41740
   425
val remote_snark =
blanchet@42939
   426
  remote_atp snarkN "SNARK" ["20080805r029", "20080805r024"]
blanchet@42962
   427
             [("refutation.", "end_refutation.")] [] Hypothesis Hypothesis
blanchet@42971
   428
             [TFF, FOF] (K (100, ["simple"]) (* FUDGE *))
blanchet@42962
   429
val remote_tofof_e =
blanchet@42962
   430
  remote_atp tofof_eN "ToFoF" ["0.1"] [] (#known_failures e_config)
blanchet@42969
   431
             Axiom Hypothesis [TFF] (K (150, ["simple"]) (* FUDGE *))
blanchet@42938
   432
val remote_waldmeister =
blanchet@42938
   433
  remote_atp waldmeisterN "Waldmeister" ["710"]
blanchet@42944
   434
             [("#START OF PROOF", "Proved Goals:")]
blanchet@42953
   435
             [(OutOfResources, "Too many function symbols"),
blanchet@42953
   436
              (Crashed, "Unrecoverable Segmentation Fault")]
blanchet@42953
   437
             Hypothesis Hypothesis [CNF_UEQ]
blanchet@43500
   438
             (K (50, ["mangled_tags?"]) (* FUDGE *))
blanchet@38454
   439
blanchet@38454
   440
(* Setup *)
blanchet@38454
   441
blanchet@40059
   442
fun add_atp (name, config) thy =
blanchet@40059
   443
  Data.map (Symtab.update_new (name, (config, stamp ()))) thy
blanchet@40059
   444
  handle Symtab.DUP name => error ("Duplicate ATP: " ^ quote name ^ ".")
blanchet@40059
   445
blanchet@40059
   446
fun get_atp thy name =
blanchet@40059
   447
  the (Symtab.lookup (Data.get thy) name) |> fst
blanchet@40059
   448
  handle Option.Option => error ("Unknown ATP: " ^ name ^ ".")
blanchet@40059
   449
blanchet@41727
   450
val supported_atps = Symtab.keys o Data.get
blanchet@36371
   451
blanchet@40059
   452
fun is_atp_installed thy name =
blanchet@40059
   453
  let val {exec, required_execs, ...} = get_atp thy name in
blanchet@40059
   454
    forall (curry (op <>) "" o getenv o fst) (exec :: required_execs)
blanchet@40059
   455
  end
blanchet@36371
   456
blanchet@40059
   457
fun refresh_systems_on_tptp () =
blanchet@40059
   458
  Synchronized.change systems (fn _ => get_systems ())
blanchet@40059
   459
blanchet@42962
   460
val atps =
blanchet@42962
   461
  [e, spass, vampire, z3_atp, remote_e, remote_vampire, remote_z3_atp,
blanchet@42963
   462
   remote_leo2, remote_satallax, remote_sine_e, remote_snark, remote_tofof_e,
blanchet@42963
   463
   remote_waldmeister]
blanchet@40059
   464
val setup = fold add_atp atps
blanchet@35867
   465
wenzelm@28592
   466
end;