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