src/HOL/Tools/ATP_Manager/atp_manager.ML
author wenzelm
Tue Aug 04 19:20:24 2009 +0200 (2009-08-04)
changeset 32327 0971cc0b6a57
parent 31793 src/HOL/Tools/atp_manager.ML@7c10b13d49fe
child 32451 8f0dc876fb1b
permissions -rw-r--r--
src/HOL/Tools/ATP_Manager as separate component, with (almost) everything in one place;
wenzelm@32327
     1
(*  Title:      HOL/Tools/ATP_Manager/atp_manager.ML
wenzelm@28477
     2
    Author:     Fabian Immler, TU Muenchen
wenzelm@28477
     3
wenzelm@28571
     4
ATP threads are registered here.
wenzelm@28571
     5
Threads with the same birth-time are seen as one group.
wenzelm@28571
     6
All threads of a group are killed when one thread of it has been successful,
wenzelm@28571
     7
or after a certain time,
wenzelm@28571
     8
or when the maximum number of threads exceeds; then the oldest thread is killed.
wenzelm@28477
     9
*)
wenzelm@28477
    10
wenzelm@28477
    11
signature ATP_MANAGER =
wenzelm@28477
    12
sig
wenzelm@28586
    13
  val get_atps: unit -> string
wenzelm@28477
    14
  val set_atps: string -> unit
wenzelm@28586
    15
  val get_max_atps: unit -> int
wenzelm@28586
    16
  val set_max_atps: int -> unit
wenzelm@28586
    17
  val get_timeout: unit -> int
wenzelm@28477
    18
  val set_timeout: int -> unit
nipkow@31791
    19
  val get_full_types: unit -> bool
wenzelm@31793
    20
  val set_full_types: bool -> unit
wenzelm@28586
    21
  val kill: unit -> unit
wenzelm@28586
    22
  val info: unit -> unit
wenzelm@29112
    23
  val messages: int option -> unit
immler@31409
    24
  type prover = int -> (thm * (string * int)) list option ->
immler@31752
    25
    (thm * (string * int)) list option -> string -> int ->
immler@31409
    26
    Proof.context * (thm list * thm) ->
immler@31752
    27
    bool * string * string * string vector * (thm * (string * int)) list
wenzelm@28595
    28
  val add_prover: string -> prover -> theory -> theory
wenzelm@28484
    29
  val print_provers: theory -> unit
immler@31037
    30
  val get_prover: string -> theory -> prover option
wenzelm@28571
    31
  val sledgehammer: string list -> Proof.state -> unit
wenzelm@28477
    32
end;
wenzelm@28477
    33
wenzelm@28586
    34
structure AtpManager: ATP_MANAGER =
wenzelm@28477
    35
struct
wenzelm@28477
    36
wenzelm@28586
    37
(** preferences **)
wenzelm@28586
    38
wenzelm@29112
    39
val message_store_limit = 20;
wenzelm@29112
    40
val message_display_limit = 5;
wenzelm@29112
    41
wenzelm@28586
    42
local
wenzelm@28586
    43
immler@29598
    44
val atps = ref "e remote_vampire";
wenzelm@28586
    45
val max_atps = ref 5;   (* ~1 means infinite number of atps *)
immler@29784
    46
val timeout = ref 60;
nipkow@31791
    47
val full_types = ref false;
wenzelm@28586
    48
wenzelm@28586
    49
in
wenzelm@28586
    50
wenzelm@28586
    51
fun get_atps () = CRITICAL (fn () => ! atps);
wenzelm@28586
    52
fun set_atps str = CRITICAL (fn () => atps := str);
wenzelm@28586
    53
wenzelm@28586
    54
fun get_max_atps () = CRITICAL (fn () => ! max_atps);
wenzelm@28586
    55
fun set_max_atps number = CRITICAL (fn () => max_atps := number);
wenzelm@28586
    56
wenzelm@28586
    57
fun get_timeout () = CRITICAL (fn () => ! timeout);
wenzelm@28586
    58
fun set_timeout time = CRITICAL (fn () => timeout := time);
wenzelm@28586
    59
nipkow@31791
    60
fun get_full_types () = CRITICAL (fn () => ! full_types);
wenzelm@31793
    61
fun set_full_types bool = CRITICAL (fn () => full_types := bool);
nipkow@31791
    62
wenzelm@28586
    63
val _ =
wenzelm@30982
    64
  ProofGeneralPgip.add_preference Preferences.category_proof
wenzelm@28586
    65
    (Preferences.string_pref atps
wenzelm@28589
    66
      "ATP: provers" "Default automatic provers (separated by whitespace)");
wenzelm@28586
    67
wenzelm@30982
    68
val _ =
wenzelm@30982
    69
  ProofGeneralPgip.add_preference Preferences.category_proof
wenzelm@28586
    70
    (Preferences.int_pref max_atps
wenzelm@28589
    71
      "ATP: maximum number" "How many provers may run in parallel");
wenzelm@28586
    72
wenzelm@30982
    73
val _ =
wenzelm@30982
    74
  ProofGeneralPgip.add_preference Preferences.category_proof
wenzelm@28586
    75
    (Preferences.int_pref timeout
wenzelm@28589
    76
      "ATP: timeout" "ATPs will be interrupted after this time (in seconds)");
wenzelm@28586
    77
nipkow@31791
    78
val _ =
nipkow@31791
    79
  ProofGeneralPgip.add_preference Preferences.category_proof
nipkow@31791
    80
    (Preferences.bool_pref full_types
nipkow@31791
    81
      "ATP: full types" "ATPs will use full type information");
nipkow@31791
    82
wenzelm@28586
    83
end;
wenzelm@28586
    84
wenzelm@28586
    85
wenzelm@28586
    86
wenzelm@28586
    87
(** thread management **)
wenzelm@28586
    88
wenzelm@28582
    89
(* data structures over threads *)
wenzelm@28582
    90
wenzelm@28582
    91
structure ThreadHeap = HeapFun
wenzelm@28582
    92
(
wenzelm@28582
    93
  type elem = Time.time * Thread.thread;
wenzelm@28582
    94
  fun ord ((a, _), (b, _)) = Time.compare (a, b);
wenzelm@28595
    95
);
wenzelm@28582
    96
wenzelm@31368
    97
fun lookup_thread xs = AList.lookup Thread.equal xs;
wenzelm@31368
    98
fun delete_thread xs = AList.delete Thread.equal xs;
wenzelm@31368
    99
fun update_thread xs = AList.update Thread.equal xs;
wenzelm@28582
   100
wenzelm@28582
   101
wenzelm@28582
   102
(* state of thread manager *)
wenzelm@28477
   103
wenzelm@28582
   104
datatype T = State of
immler@30830
   105
 {managing_thread: Thread.thread option,
immler@30830
   106
  timeout_heap: ThreadHeap.T,
wenzelm@28582
   107
  oldest_heap: ThreadHeap.T,
wenzelm@28582
   108
  active: (Thread.thread * (Time.time * Time.time * string)) list,
wenzelm@29112
   109
  cancelling: (Thread.thread * (Time.time * Time.time * string)) list,
immler@29620
   110
  messages: string list,
immler@29620
   111
  store: string list};
wenzelm@28582
   112
immler@30830
   113
fun make_state managing_thread timeout_heap oldest_heap active cancelling messages store =
immler@30830
   114
  State {managing_thread = managing_thread, timeout_heap = timeout_heap, oldest_heap = oldest_heap,
immler@29620
   115
    active = active, cancelling = cancelling, messages = messages, store = store};
wenzelm@28582
   116
immler@30830
   117
val state = Synchronized.var "atp_manager"
immler@30830
   118
  (make_state NONE ThreadHeap.empty ThreadHeap.empty [] [] [] []);
wenzelm@28582
   119
wenzelm@31368
   120
wenzelm@29150
   121
(* unregister thread *)
wenzelm@28582
   122
immler@29620
   123
fun unregister (success, message) thread = Synchronized.change state
immler@30830
   124
  (fn state as State {managing_thread, timeout_heap, oldest_heap, active, cancelling, messages, store} =>
wenzelm@29150
   125
    (case lookup_thread active thread of
wenzelm@29150
   126
      SOME (birthtime, _, description) =>
wenzelm@29150
   127
        let
wenzelm@29150
   128
          val (group, active') =
wenzelm@29150
   129
            if success then List.partition (fn (_, (tb, _, _)) => tb = birthtime) active
wenzelm@29150
   130
            else List.partition (fn (th, _) => Thread.equal (th, thread)) active
wenzelm@28582
   131
wenzelm@29150
   132
          val now = Time.now ()
wenzelm@29150
   133
          val cancelling' =
immler@29620
   134
            fold (fn (th, (tb, _, desc)) => update_thread (th, (tb, now, desc))) group cancelling
wenzelm@28582
   135
immler@29620
   136
          val message' = description ^ "\n" ^ message ^
immler@29596
   137
            (if length group <= 1 then ""
immler@29596
   138
             else "\nInterrupted " ^ string_of_int (length group - 1) ^ " other group members")
immler@29620
   139
          val store' = message' ::
immler@29620
   140
            (if length store <= message_store_limit then store
immler@29620
   141
             else #1 (chop message_store_limit store))
immler@30830
   142
        in make_state
immler@30830
   143
          managing_thread timeout_heap oldest_heap active' cancelling' (message' :: messages) store'
immler@30830
   144
        end
wenzelm@30800
   145
    | NONE => state));
wenzelm@28582
   146
wenzelm@28582
   147
wenzelm@28595
   148
(* kill excessive atp threads *)
wenzelm@28595
   149
wenzelm@28595
   150
fun excessive_atps active =
wenzelm@28595
   151
  let val max = get_max_atps ()
wenzelm@28595
   152
  in length active > max andalso max > ~1 end;
wenzelm@28595
   153
wenzelm@28595
   154
local
wenzelm@28595
   155
wenzelm@28595
   156
fun kill_oldest () =
wenzelm@28595
   157
  let exception Unchanged in
wenzelm@29112
   158
    Synchronized.change_result state
immler@30830
   159
      (fn State {managing_thread, timeout_heap, oldest_heap, active, cancelling, messages, store} =>
wenzelm@28595
   160
        if ThreadHeap.is_empty oldest_heap orelse not (excessive_atps active)
wenzelm@28595
   161
        then raise Unchanged
wenzelm@28595
   162
        else
wenzelm@28595
   163
          let val ((_, oldest_thread), oldest_heap') = ThreadHeap.min_elem oldest_heap
immler@30830
   164
          in (oldest_thread,
immler@30830
   165
          make_state managing_thread timeout_heap oldest_heap' active cancelling messages store) end)
immler@29620
   166
      |> unregister (false, "Interrupted (maximum number of ATPs exceeded)")
wenzelm@28595
   167
    handle Unchanged => ()
wenzelm@28595
   168
  end;
wenzelm@28595
   169
wenzelm@28595
   170
in
wenzelm@28595
   171
wenzelm@28595
   172
fun kill_excessive () =
wenzelm@28595
   173
  let val State {active, ...} = Synchronized.value state
wenzelm@28595
   174
  in if excessive_atps active then (kill_oldest (); kill_excessive ()) else () end;
wenzelm@28595
   175
wenzelm@28595
   176
end;
wenzelm@28595
   177
immler@29620
   178
fun print_new_messages () =
immler@29620
   179
  let val to_print = Synchronized.change_result state
immler@30830
   180
    (fn State {managing_thread, timeout_heap, oldest_heap, active, cancelling, messages, store} =>
immler@30830
   181
      (messages, make_state managing_thread timeout_heap oldest_heap active cancelling [] store))
wenzelm@30800
   182
  in
wenzelm@30800
   183
    if null to_print then ()
wenzelm@30800
   184
    else priority ("Sledgehammer: " ^ space_implode "\n\n" to_print)
wenzelm@30800
   185
  end;
immler@29620
   186
wenzelm@28595
   187
wenzelm@30800
   188
(* start a watching thread -- only one may exist *)
wenzelm@28582
   189
immler@30830
   190
fun check_thread_manager () = Synchronized.change state
immler@30830
   191
  (fn State {managing_thread, timeout_heap, oldest_heap, active, cancelling, messages, store} =>
immler@30830
   192
    if (case managing_thread of SOME thread => Thread.isActive thread | NONE => false)
immler@30830
   193
    then make_state managing_thread timeout_heap oldest_heap active cancelling messages store
immler@30830
   194
    else let val managing_thread = SOME (SimpleThread.fork false (fn () =>
immler@30830
   195
      let
immler@30830
   196
        val min_wait_time = Time.fromMilliseconds 300
immler@30830
   197
        val max_wait_time = Time.fromSeconds 10
wenzelm@28582
   198
immler@30830
   199
        (* wait for next thread to cancel, or maximum*)
immler@30830
   200
        fun time_limit (State {timeout_heap, ...}) =
immler@30830
   201
          (case try ThreadHeap.min timeout_heap of
immler@30830
   202
            NONE => SOME (Time.+ (Time.now (), max_wait_time))
immler@30830
   203
          | SOME (time, _) => SOME time)
wenzelm@28582
   204
immler@30830
   205
        (* action: find threads whose timeout is reached, and interrupt cancelling threads *)
immler@30830
   206
        fun action (State {managing_thread, timeout_heap, oldest_heap, active, cancelling,
immler@30830
   207
                           messages, store}) =
immler@30830
   208
          let val (timeout_threads, timeout_heap') =
immler@30830
   209
            ThreadHeap.upto (Time.now (), Thread.self ()) timeout_heap
immler@30830
   210
          in
immler@30830
   211
            if null timeout_threads andalso null cancelling andalso not (excessive_atps active)
immler@30830
   212
            then NONE
immler@30830
   213
            else
immler@30830
   214
              let
immler@30830
   215
                val _ = List.app (SimpleThread.interrupt o #1) cancelling
immler@30830
   216
                val cancelling' = filter (Thread.isActive o #1) cancelling
immler@30830
   217
                val state' = make_state
immler@30830
   218
                  managing_thread timeout_heap' oldest_heap active cancelling' messages store
immler@30830
   219
              in SOME (map #2 timeout_threads, state') end
immler@30830
   220
          end
immler@30830
   221
      in
immler@30830
   222
        while Synchronized.change_result state
immler@30830
   223
          (fn st as
immler@30830
   224
            State {managing_thread, timeout_heap, oldest_heap, active, cancelling, messages, store} =>
immler@30830
   225
            if (null active) andalso (null cancelling) andalso (null messages)
immler@30830
   226
            then (false, make_state NONE timeout_heap oldest_heap active cancelling messages store)
immler@30830
   227
            else (true, st))
immler@30830
   228
        do
immler@30830
   229
          (Synchronized.timed_access state time_limit action
immler@30830
   230
            |> these
immler@30830
   231
            |> List.app (unregister (false, "Interrupted (reached timeout)"));
immler@30830
   232
            kill_excessive ();
immler@30830
   233
            print_new_messages ();
immler@30830
   234
            (*give threads time to respond to interrupt*)
immler@30830
   235
            OS.Process.sleep min_wait_time)
immler@30830
   236
      end))
immler@30830
   237
    in make_state managing_thread timeout_heap oldest_heap active cancelling messages store end);
wenzelm@28582
   238
wenzelm@28582
   239
wenzelm@28582
   240
(* thread is registered here by sledgehammer *)
wenzelm@28477
   241
wenzelm@28582
   242
fun register birthtime deadtime (thread, desc) =
immler@30798
   243
 (Synchronized.change state
immler@30830
   244
    (fn State {managing_thread, timeout_heap, oldest_heap, active, cancelling, messages, store} =>
wenzelm@29112
   245
      let
wenzelm@29112
   246
        val timeout_heap' = ThreadHeap.insert (deadtime, thread) timeout_heap
wenzelm@29112
   247
        val oldest_heap' = ThreadHeap.insert (birthtime, thread) oldest_heap
wenzelm@29112
   248
        val active' = update_thread (thread, (birthtime, deadtime, desc)) active
immler@30830
   249
      in make_state managing_thread timeout_heap' oldest_heap' active' cancelling messages store end);
immler@30798
   250
  check_thread_manager ());
wenzelm@28477
   251
wenzelm@28477
   252
wenzelm@28586
   253
wenzelm@28586
   254
(** user commands **)
wenzelm@28582
   255
wenzelm@28586
   256
(* kill: move all threads to cancelling *)
wenzelm@28586
   257
wenzelm@28586
   258
fun kill () = Synchronized.change state
immler@30830
   259
  (fn State {managing_thread, timeout_heap, oldest_heap, active, cancelling, messages, store} =>
wenzelm@28582
   260
    let val formerly_active = map (fn (th, (tb, _, desc)) => (th, (tb, Time.now (), desc))) active
immler@30830
   261
    in make_state
immler@30830
   262
      managing_thread timeout_heap oldest_heap [] (formerly_active @ cancelling) messages store
immler@30830
   263
    end);
wenzelm@28582
   264
wenzelm@28582
   265
wenzelm@29112
   266
(* ATP info *)
wenzelm@28582
   267
wenzelm@28582
   268
fun info () =
wenzelm@28582
   269
  let
wenzelm@29112
   270
    val State {active, cancelling, ...} = Synchronized.value state
wenzelm@29112
   271
wenzelm@28571
   272
    fun running_info (_, (birth_time, dead_time, desc)) = "Running: "
wenzelm@28589
   273
        ^ (string_of_int o Time.toSeconds) (Time.- (Time.now (), birth_time))
wenzelm@28477
   274
        ^ " s  --  "
wenzelm@28589
   275
        ^ (string_of_int o Time.toSeconds) (Time.- (dead_time, Time.now ()))
wenzelm@28571
   276
        ^ " s to live:\n" ^ desc
wenzelm@28571
   277
    fun cancelling_info (_, (_, dead_time, desc)) = "Trying to interrupt thread since "
wenzelm@28586
   278
        ^ (string_of_int o Time.toSeconds) (Time.- (Time.now (), dead_time))
wenzelm@28571
   279
        ^ " s:\n" ^ desc
wenzelm@29112
   280
wenzelm@28589
   281
    val running =
wenzelm@28589
   282
      if null active then "No ATPs running."
wenzelm@28589
   283
      else space_implode "\n\n" ("Running ATPs:" :: map running_info active)
wenzelm@28589
   284
    val interrupting =
wenzelm@28589
   285
      if null cancelling then ""
wenzelm@28589
   286
      else space_implode "\n\n"
wenzelm@28589
   287
        ("Trying to interrupt the following ATPs:" :: map cancelling_info cancelling)
wenzelm@29112
   288
wenzelm@28582
   289
  in writeln (running ^ "\n" ^ interrupting) end;
wenzelm@28582
   290
wenzelm@29112
   291
fun messages opt_limit =
wenzelm@29112
   292
  let
wenzelm@29112
   293
    val limit = the_default message_display_limit opt_limit;
immler@29620
   294
    val State {store = msgs, ...} = Synchronized.value state
wenzelm@29112
   295
    val header = "Recent ATP messages" ^
wenzelm@29112
   296
      (if length msgs <= limit then ":" else " (" ^ string_of_int limit ^ " displayed):");
wenzelm@29116
   297
  in writeln (space_implode "\n\n" (header :: #1 (chop limit msgs))) end;
wenzelm@29112
   298
wenzelm@28582
   299
wenzelm@28477
   300
wenzelm@28586
   301
(** The Sledgehammer **)
wenzelm@28477
   302
wenzelm@28582
   303
(* named provers *)
wenzelm@28484
   304
immler@31409
   305
type prover = int -> (thm * (string * int)) list option ->
immler@31752
   306
  (thm * (string * int)) list option -> string -> int ->
immler@31409
   307
  Proof.context * (thm list * thm) ->
immler@31752
   308
  bool * string * string * string vector * (thm * (string * int)) list
wenzelm@28595
   309
wenzelm@28582
   310
fun err_dup_prover name = error ("Duplicate prover: " ^ quote name);
wenzelm@28477
   311
wenzelm@28582
   312
structure Provers = TheoryDataFun
wenzelm@28582
   313
(
wenzelm@28595
   314
  type T = (prover * stamp) Symtab.table
wenzelm@28582
   315
  val empty = Symtab.empty
wenzelm@28582
   316
  val copy = I
wenzelm@28582
   317
  val extend = I
wenzelm@28582
   318
  fun merge _ tabs : T = Symtab.merge (eq_snd op =) tabs
wenzelm@28589
   319
    handle Symtab.DUP dup => err_dup_prover dup
wenzelm@28582
   320
);
wenzelm@28484
   321
wenzelm@28595
   322
fun add_prover name prover thy =
wenzelm@28595
   323
  Provers.map (Symtab.update_new (name, (prover, stamp ()))) thy
wenzelm@28582
   324
    handle Symtab.DUP dup => err_dup_prover dup;
wenzelm@28582
   325
wenzelm@28582
   326
fun print_provers thy = Pretty.writeln
wenzelm@28582
   327
  (Pretty.strs ("external provers:" :: sort_strings (Symtab.keys (Provers.get thy))));
wenzelm@28571
   328
immler@31037
   329
fun get_prover name thy = case Symtab.lookup (Provers.get thy) name of
immler@31037
   330
  NONE => NONE
immler@31037
   331
| SOME (prover, _) => SOME prover;
wenzelm@28586
   332
wenzelm@28595
   333
(* start prover thread *)
wenzelm@28484
   334
wenzelm@28595
   335
fun start_prover name birthtime deadtime i proof_state =
immler@31037
   336
  (case get_prover name (Proof.theory_of proof_state) of
wenzelm@28595
   337
    NONE => warning ("Unknown external prover: " ^ quote name)
immler@31037
   338
  | SOME prover =>
wenzelm@28595
   339
      let
wenzelm@28595
   340
        val (ctxt, (_, goal)) = Proof.get_goal proof_state
wenzelm@28595
   341
        val desc =
wenzelm@28595
   342
          "external prover " ^ quote name ^ " for subgoal " ^ string_of_int i ^ ":\n" ^
wenzelm@28595
   343
            Syntax.string_of_term ctxt (Thm.term_of (Thm.cprem_of goal i))
wenzelm@28595
   344
        val _ = SimpleThread.fork true (fn () =>
wenzelm@28595
   345
          let
wenzelm@28595
   346
            val _ = register birthtime deadtime (Thread.self (), desc)
immler@31037
   347
            val result =
immler@31409
   348
              let val (success, message, _, _, _) =
immler@31409
   349
                prover (get_timeout ()) NONE NONE name i (Proof.get_goal proof_state)
immler@31037
   350
              in (success, message) end
wenzelm@28835
   351
              handle ResHolClause.TOO_TRIVIAL
wenzelm@28835
   352
                => (true, "Empty clause: Try this command: " ^ Markup.markup Markup.sendback "apply metis")
wenzelm@28835
   353
              | ERROR msg
wenzelm@28835
   354
                => (false, "Error: " ^ msg)
immler@29620
   355
            val _ = unregister result (Thread.self ())
wenzelm@28595
   356
          in () end handle Interrupt => ())
wenzelm@28595
   357
      in () end);
wenzelm@28582
   358
wenzelm@28582
   359
wenzelm@28582
   360
(* sledghammer for first subgoal *)
wenzelm@28582
   361
wenzelm@28582
   362
fun sledgehammer names proof_state =
wenzelm@28582
   363
  let
wenzelm@28595
   364
    val provers =
wenzelm@28586
   365
      if null names then String.tokens (Symbol.is_ascii_blank o String.str) (get_atps ())
wenzelm@28582
   366
      else names
wenzelm@28582
   367
    val birthtime = Time.now ()
wenzelm@28595
   368
    val deadtime = Time.+ (birthtime, Time.fromSeconds (get_timeout ()))
wenzelm@28595
   369
  in List.app (fn name => start_prover name birthtime deadtime 1 proof_state) provers end;
wenzelm@28582
   370
wenzelm@28582
   371
wenzelm@28586
   372
wenzelm@28586
   373
(** Isar command syntax **)
wenzelm@28582
   374
wenzelm@28582
   375
local structure K = OuterKeyword and P = OuterParse in
wenzelm@28582
   376
wenzelm@28582
   377
val _ =
wenzelm@28582
   378
  OuterSyntax.improper_command "atp_kill" "kill all managed provers" K.diag
wenzelm@28586
   379
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative kill));
wenzelm@28582
   380
wenzelm@28582
   381
val _ =
wenzelm@28582
   382
  OuterSyntax.improper_command "atp_info" "print information about managed provers" K.diag
wenzelm@28582
   383
    (Scan.succeed (Toplevel.no_timing o Toplevel.imperative info));
wenzelm@28582
   384
wenzelm@28582
   385
val _ =
wenzelm@29112
   386
  OuterSyntax.improper_command "atp_messages" "print recent messages issued by managed provers" K.diag
wenzelm@29112
   387
    (Scan.option (P.$$$ "(" |-- P.nat --| P.$$$ ")") >>
wenzelm@29112
   388
      (fn limit => Toplevel.no_timing o Toplevel.imperative (fn () => messages limit)));
wenzelm@29112
   389
wenzelm@29112
   390
val _ =
wenzelm@28582
   391
  OuterSyntax.improper_command "print_atps" "print external provers" K.diag
wenzelm@28582
   392
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_theory o
wenzelm@28582
   393
      Toplevel.keep (print_provers o Toplevel.theory_of)));
wenzelm@28582
   394
wenzelm@28582
   395
val _ =
wenzelm@28582
   396
  OuterSyntax.command "sledgehammer" "call all automatic theorem provers" K.diag
wenzelm@28582
   397
    (Scan.repeat P.xname >> (fn names => Toplevel.no_timing o Toplevel.unknown_proof o
wenzelm@30800
   398
      Toplevel.keep (sledgehammer names o Toplevel.proof_of)));
wenzelm@28582
   399
wenzelm@28582
   400
end;
wenzelm@28582
   401
wenzelm@28582
   402
end;
immler@30537
   403