src/HOL/Tools/Sledgehammer/sledgehammer_isar.ML
author blanchet
Sun May 01 18:37:25 2011 +0200 (2011-05-01 ago)
changeset 42581 398fff2c6b8f
parent 42579 2552c09b1a72
child 42589 9f7c48463645
permissions -rw-r--r--
use ! for mildly unsound and !! for very unsound encodings
blanchet@36375
     1
(*  Title:      HOL/Tools/Sledgehammer/sledgehammer_isar.ML
blanchet@35866
     2
    Author:     Jasmin Blanchette, TU Muenchen
blanchet@35866
     3
blanchet@35866
     4
Adds "sledgehammer" and related commands to Isabelle/Isar's outer syntax.
blanchet@35866
     5
*)
blanchet@35866
     6
blanchet@35963
     7
signature SLEDGEHAMMER_ISAR =
blanchet@35963
     8
sig
blanchet@41087
     9
  type params = Sledgehammer_Provers.params
blanchet@35963
    10
blanchet@39318
    11
  val auto : bool Unsynchronized.ref
blanchet@40059
    12
  val provers : string Unsynchronized.ref
blanchet@39318
    13
  val timeout : int Unsynchronized.ref
blanchet@39318
    14
  val full_types : bool Unsynchronized.ref
blanchet@40069
    15
  val default_params : Proof.context -> (string * string) list -> params
blanchet@39318
    16
  val setup : theory -> theory
blanchet@35963
    17
end;
blanchet@35963
    18
blanchet@35971
    19
structure Sledgehammer_Isar : SLEDGEHAMMER_ISAR =
blanchet@35866
    20
struct
blanchet@35866
    21
blanchet@38028
    22
open ATP_Systems
blanchet@35971
    23
open Sledgehammer_Util
blanchet@41138
    24
open Sledgehammer_ATP_Translate
blanchet@41087
    25
open Sledgehammer_Provers
blanchet@38988
    26
open Sledgehammer_Minimize
blanchet@41087
    27
open Sledgehammer_Run
blanchet@35866
    28
blanchet@39318
    29
val auto = Unsynchronized.ref false
blanchet@39318
    30
blanchet@39318
    31
val _ =
blanchet@39318
    32
  ProofGeneralPgip.add_preference Preferences.category_tracing
blanchet@39318
    33
      (Preferences.bool_pref auto "auto-sledgehammer"
blanchet@39327
    34
           "Run Sledgehammer automatically.")
blanchet@39318
    35
blanchet@36394
    36
(** Sledgehammer commands **)
blanchet@36394
    37
blanchet@39318
    38
val no_relevance_override = {add = [], del = [], only = false}
blanchet@39318
    39
fun add_relevance_override ns : relevance_override =
blanchet@35966
    40
  {add = ns, del = [], only = false}
blanchet@39318
    41
fun del_relevance_override ns : relevance_override =
blanchet@35966
    42
  {add = [], del = ns, only = false}
blanchet@35966
    43
fun only_relevance_override ns : relevance_override =
blanchet@35966
    44
  {add = ns, del = [], only = true}
blanchet@36003
    45
fun merge_relevance_override_pairwise (r1 : relevance_override)
blanchet@36003
    46
                                      (r2 : relevance_override) =
blanchet@35966
    47
  {add = #add r1 @ #add r2, del = #del r1 @ #del r2,
blanchet@36183
    48
   only = #only r1 andalso #only r2}
blanchet@36188
    49
fun merge_relevance_overrides rs =
blanchet@36188
    50
  fold merge_relevance_override_pairwise rs (only_relevance_override [])
blanchet@35965
    51
blanchet@36371
    52
(*** parameters ***)
blanchet@36371
    53
blanchet@40059
    54
val provers = Unsynchronized.ref ""
blanchet@39335
    55
val timeout = Unsynchronized.ref 30
blanchet@36371
    56
val full_types = Unsynchronized.ref false
blanchet@36371
    57
blanchet@36371
    58
val _ =
blanchet@36371
    59
  ProofGeneralPgip.add_preference Preferences.category_proof
blanchet@40059
    60
      (Preferences.string_pref provers
blanchet@40059
    61
          "Sledgehammer: Provers"
blanchet@36371
    62
          "Default automatic provers (separated by whitespace)")
blanchet@36371
    63
blanchet@36371
    64
val _ =
blanchet@36371
    65
  ProofGeneralPgip.add_preference Preferences.category_proof
blanchet@36371
    66
      (Preferences.int_pref timeout
blanchet@36373
    67
          "Sledgehammer: Time Limit"
blanchet@36371
    68
          "ATPs will be interrupted after this time (in seconds)")
blanchet@36371
    69
blanchet@36371
    70
val _ =
blanchet@36371
    71
  ProofGeneralPgip.add_preference Preferences.category_proof
blanchet@36371
    72
      (Preferences.bool_pref full_types
blanchet@36373
    73
          "Sledgehammer: Full Types" "ATPs will use full type information")
blanchet@36371
    74
blanchet@35963
    75
type raw_param = string * string list
blanchet@35963
    76
blanchet@35963
    77
val default_default_params =
blanchet@41208
    78
  [("debug", "false"),
blanchet@35963
    79
   ("verbose", "false"),
blanchet@36143
    80
   ("overlord", "false"),
blanchet@41208
    81
   ("blocking", "false"),
blanchet@42523
    82
   ("type_sys", "smart"),
blanchet@42180
    83
   ("relevance_thresholds", "0.45 0.85"),
blanchet@42180
    84
   ("max_relevant", "smart"),
blanchet@42180
    85
   ("monomorphize_limit", "4"),
blanchet@36235
    86
   ("explicit_apply", "false"),
blanchet@35963
    87
   ("isar_proof", "false"),
blanchet@42443
    88
   ("isar_shrink_factor", "1"),
blanchet@42443
    89
   ("slicing", "true")]
blanchet@35963
    90
blanchet@36140
    91
val alias_params =
blanchet@40059
    92
  [("prover", "provers"),
blanchet@40059
    93
   ("atps", "provers"), (* FIXME: legacy *)
blanchet@40059
    94
   ("atp", "provers")]  (* FIXME: legacy *)
blanchet@36140
    95
val negated_alias_params =
blanchet@41208
    96
  [("no_debug", "debug"),
blanchet@35963
    97
   ("quiet", "verbose"),
blanchet@36143
    98
   ("no_overlord", "overlord"),
blanchet@41208
    99
   ("non_blocking", "blocking"),
blanchet@36399
   100
   ("partial_types", "full_types"),
blanchet@36235
   101
   ("implicit_apply", "explicit_apply"),
blanchet@42443
   102
   ("no_isar_proof", "isar_proof"),
blanchet@42443
   103
   ("no_slicing", "slicing")]
blanchet@35963
   104
blanchet@36281
   105
val params_for_minimize =
blanchet@41136
   106
  ["debug", "verbose", "overlord", "type_sys", "full_types", "isar_proof",
blanchet@38590
   107
   "isar_shrink_factor", "timeout"]
blanchet@36281
   108
blanchet@40059
   109
val property_dependent_params = ["provers", "full_types", "timeout"]
blanchet@35866
   110
blanchet@35963
   111
fun is_known_raw_param s =
blanchet@35963
   112
  AList.defined (op =) default_default_params s orelse
blanchet@36140
   113
  AList.defined (op =) alias_params s orelse
blanchet@36140
   114
  AList.defined (op =) negated_alias_params s orelse
blanchet@38985
   115
  member (op =) property_dependent_params s orelse s = "expect"
blanchet@35963
   116
blanchet@41258
   117
fun is_prover_list ctxt s =
blanchet@41258
   118
  case space_explode " " s of
blanchet@41727
   119
    ss as _ :: _ => forall (is_prover_supported ctxt) ss
blanchet@41258
   120
  | _ => false
blanchet@41258
   121
blanchet@41258
   122
fun check_and_repair_raw_param ctxt (name, value) =
blanchet@41258
   123
  if is_known_raw_param name then (name, value)
blanchet@41258
   124
  else if is_prover_list ctxt name andalso null value then ("provers", [name])
blanchet@41258
   125
  else error ("Unknown parameter: " ^ quote name ^ ".")
blanchet@35866
   126
blanchet@36140
   127
fun unalias_raw_param (name, value) =
blanchet@36140
   128
  case AList.lookup (op =) alias_params name of
blanchet@36140
   129
    SOME name' => (name', value)
blanchet@36140
   130
  | NONE =>
blanchet@36140
   131
    case AList.lookup (op =) negated_alias_params name of
blanchet@36140
   132
      SOME name' => (name', case value of
blanchet@36140
   133
                              ["false"] => ["true"]
blanchet@36140
   134
                            | ["true"] => ["false"]
blanchet@36140
   135
                            | [] => ["false"]
blanchet@36140
   136
                            | _ => value)
blanchet@36140
   137
    | NONE => (name, value)
blanchet@35963
   138
wenzelm@41472
   139
structure Data = Theory_Data
wenzelm@41472
   140
(
blanchet@35963
   141
  type T = raw_param list
blanchet@35963
   142
  val empty = default_default_params |> map (apsnd single)
blanchet@35963
   143
  val extend = I
wenzelm@41472
   144
  fun merge data : T = AList.merge (op =) (K true) data
wenzelm@41472
   145
)
blanchet@35866
   146
blanchet@41727
   147
fun remotify_prover_if_supported_and_not_already_remote ctxt name =
blanchet@40072
   148
  if String.isPrefix remote_prefix name then
blanchet@40072
   149
    SOME name
blanchet@40072
   150
  else
blanchet@40072
   151
    let val remote_name = remote_prefix ^ name in
blanchet@41727
   152
      if is_prover_supported ctxt remote_name then SOME remote_name else NONE
blanchet@40072
   153
    end
blanchet@40072
   154
blanchet@40072
   155
fun remotify_prover_if_not_installed ctxt name =
blanchet@41727
   156
  if is_prover_supported ctxt name andalso is_prover_installed ctxt name then
blanchet@40941
   157
    SOME name
blanchet@40941
   158
  else
blanchet@41727
   159
    remotify_prover_if_supported_and_not_already_remote ctxt name
blanchet@40072
   160
blanchet@40072
   161
fun avoid_too_many_local_threads _ _ [] = []
blanchet@40941
   162
  | avoid_too_many_local_threads ctxt 0 provers =
blanchet@41727
   163
    map_filter (remotify_prover_if_supported_and_not_already_remote ctxt)
blanchet@40941
   164
               provers
blanchet@40941
   165
  | avoid_too_many_local_threads ctxt n (prover :: provers) =
blanchet@40072
   166
    let val n = if String.isPrefix remote_prefix prover then n else n - 1 in
blanchet@40941
   167
      prover :: avoid_too_many_local_threads ctxt n provers
blanchet@40072
   168
    end
blanchet@40059
   169
blanchet@40059
   170
(* The first ATP of the list is used by Auto Sledgehammer. Because of the low
blanchet@40059
   171
   timeout, it makes sense to put SPASS first. *)
blanchet@40069
   172
fun default_provers_param_value ctxt =
blanchet@40941
   173
  [spassN, eN, vampireN, sine_eN, SMT_Solver.solver_name_of ctxt]
blanchet@40941
   174
  |> map_filter (remotify_prover_if_not_installed ctxt)
blanchet@40941
   175
  |> avoid_too_many_local_threads ctxt (Multithreading.max_threads_value ())
blanchet@40941
   176
  |> space_implode " "
blanchet@40059
   177
blanchet@36140
   178
val set_default_raw_param = Data.map o AList.update (op =) o unalias_raw_param
blanchet@40069
   179
fun default_raw_params ctxt =
wenzelm@42361
   180
  let val thy = Proof_Context.theory_of ctxt in
blanchet@40069
   181
    Data.get thy
blanchet@40069
   182
    |> fold (AList.default (op =))
blanchet@40069
   183
            [("provers", [case !provers of
blanchet@40069
   184
                            "" => default_provers_param_value ctxt
blanchet@40069
   185
                          | s => s]),
blanchet@40069
   186
             ("full_types", [if !full_types then "true" else "false"]),
blanchet@40069
   187
             ("timeout", let val timeout = !timeout in
blanchet@40069
   188
                           [if timeout <= 0 then "none"
blanchet@40341
   189
                            else string_of_int timeout]
blanchet@40069
   190
                         end)]
blanchet@40069
   191
  end
blanchet@35963
   192
blanchet@35963
   193
val infinity_time_in_secs = 60 * 60 * 24 * 365
blanchet@35963
   194
val the_timeout = the_default (Time.fromSeconds infinity_time_in_secs)
blanchet@35866
   195
blanchet@39318
   196
fun extract_params auto default_params override_params =
blanchet@35963
   197
  let
blanchet@36140
   198
    val override_params = map unalias_raw_param override_params
blanchet@35963
   199
    val raw_params = rev override_params @ rev default_params
blanchet@35963
   200
    val lookup = Option.map (space_implode " ") o AList.lookup (op =) raw_params
blanchet@35963
   201
    val lookup_string = the_default "" o lookup
blanchet@35963
   202
    fun general_lookup_bool option default_value name =
blanchet@35963
   203
      case lookup name of
blanchet@35970
   204
        SOME s => parse_bool_option option name s
blanchet@35963
   205
      | NONE => default_value
blanchet@35963
   206
    val lookup_bool = the o general_lookup_bool false (SOME false)
blanchet@35963
   207
    fun lookup_time name =
blanchet@39318
   208
      case lookup name of
blanchet@39318
   209
        SOME s => parse_time_option name s
blanchet@39318
   210
      | NONE => NONE
blanchet@35966
   211
    fun lookup_int name =
blanchet@35963
   212
      case lookup name of
blanchet@35966
   213
        NONE => 0
blanchet@35966
   214
      | SOME s => case Int.fromString s of
blanchet@35966
   215
                    SOME n => n
blanchet@35966
   216
                  | NONE => error ("Parameter " ^ quote name ^
blanchet@35966
   217
                                   " must be assigned an integer value.")
blanchet@40343
   218
    fun lookup_real_pair name =
blanchet@38745
   219
      case lookup name of
blanchet@40343
   220
        NONE => (0.0, 0.0)
blanchet@40343
   221
      | SOME s => case s |> space_explode " " |> map Real.fromString of
blanchet@40343
   222
                    [SOME r1, SOME r2] => (r1, r2)
blanchet@38745
   223
                  | _ => error ("Parameter " ^ quote name ^
blanchet@40343
   224
                                "must be assigned a pair of floating-point \
blanchet@40343
   225
                                \values (e.g., \"0.6 0.95\")")
blanchet@38589
   226
    fun lookup_int_option name =
blanchet@38589
   227
      case lookup name of
blanchet@38589
   228
        SOME "smart" => NONE
blanchet@38589
   229
      | _ => SOME (lookup_int name)
blanchet@39318
   230
    val debug = not auto andalso lookup_bool "debug"
blanchet@39318
   231
    val verbose = debug orelse (not auto andalso lookup_bool "verbose")
blanchet@36143
   232
    val overlord = lookup_bool "overlord"
blanchet@41208
   233
    val blocking = auto orelse debug orelse lookup_bool "blocking"
blanchet@40059
   234
    val provers = lookup_string "provers" |> space_explode " "
blanchet@40059
   235
                  |> auto ? single o hd
blanchet@42579
   236
    val type_sys = lookup_string "type_sys"
blanchet@42548
   237
    val type_sys =
blanchet@42579
   238
      (case try (unprefix "mono_") type_sys of
blanchet@42579
   239
         SOME s => (true, s)
blanchet@42579
   240
       | NONE => (false, type_sys))
blanchet@42581
   241
      ||> (fn s => case try (unsuffix " !!") s of
blanchet@42579
   242
                     SOME s => (Unsound, s)
blanchet@42581
   243
                   | NONE => case try (unsuffix " !") s of
blanchet@42579
   244
                               SOME s => (Half_Sound, s)
blanchet@42579
   245
                             | NONE => (Sound, s))
blanchet@42579
   246
      |> (fn (mono, (level, core)) =>
blanchet@42579
   247
             case (core, (mono, level)) of
blanchet@42579
   248
               ("many_typed", (false, Sound)) => Dumb_Type_Sys Many_Typed
blanchet@42579
   249
             | ("mangled", (false, level)) => Dumb_Type_Sys (Mangled level)
blanchet@42579
   250
             | ("args", extra) => Dumb_Type_Sys (Args extra)
blanchet@42579
   251
             | ("tags", extra) => Dumb_Type_Sys (Tags extra)
blanchet@42579
   252
             | ("none", (false, Sound)) => Dumb_Type_Sys No_Types
blanchet@42579
   253
             | ("smart", (false, Sound)) =>
blanchet@42579
   254
               Smart_Type_Sys (lookup_bool "full_types")
blanchet@42579
   255
             | _ => error ("Unknown type system: " ^ quote type_sys ^ "."))
blanchet@42180
   256
    val relevance_thresholds = lookup_real_pair "relevance_thresholds"
blanchet@42180
   257
    val max_relevant = lookup_int_option "max_relevant"
blanchet@42180
   258
    val monomorphize_limit = lookup_int "monomorphize_limit"
blanchet@36235
   259
    val explicit_apply = lookup_bool "explicit_apply"
blanchet@35963
   260
    val isar_proof = lookup_bool "isar_proof"
blanchet@36924
   261
    val isar_shrink_factor = Int.max (1, lookup_int "isar_shrink_factor")
blanchet@42444
   262
    val slicing = not auto andalso lookup_bool "slicing"
blanchet@39318
   263
    val timeout = (if auto then NONE else lookup_time "timeout") |> the_timeout
blanchet@38985
   264
    val expect = lookup_string "expect"
blanchet@35963
   265
  in
blanchet@41208
   266
    {debug = debug, verbose = verbose, overlord = overlord, blocking = blocking,
blanchet@42180
   267
     provers = provers, relevance_thresholds = relevance_thresholds,
blanchet@42579
   268
     max_relevant = max_relevant, monomorphize_limit = monomorphize_limit,
blanchet@42579
   269
     type_sys = type_sys, explicit_apply = explicit_apply,
blanchet@42579
   270
     isar_proof = isar_proof, isar_shrink_factor = isar_shrink_factor,
blanchet@42579
   271
     slicing = slicing, timeout = timeout, expect = expect}
blanchet@35963
   272
  end
blanchet@35866
   273
blanchet@40069
   274
fun get_params auto ctxt = extract_params auto (default_raw_params ctxt)
blanchet@39318
   275
fun default_params thy = get_params false thy o map (apsnd single)
blanchet@35866
   276
blanchet@36373
   277
(* Sledgehammer the given subgoal *)
blanchet@36373
   278
blanchet@36373
   279
val sledgehammerN = "sledgehammer"
blanchet@36373
   280
val sledgehammer_paramsN = "sledgehammer_params"
blanchet@36373
   281
blanchet@35965
   282
val runN = "run"
blanchet@35965
   283
val minimizeN = "minimize"
blanchet@35965
   284
val messagesN = "messages"
blanchet@41727
   285
val supported_proversN = "supported_provers"
blanchet@40059
   286
val running_proversN = "running_provers"
blanchet@40059
   287
val kill_proversN = "kill_provers"
blanchet@35965
   288
val refresh_tptpN = "refresh_tptp"
blanchet@35866
   289
blanchet@36281
   290
val is_raw_param_relevant_for_minimize =
blanchet@36281
   291
  member (op =) params_for_minimize o fst o unalias_raw_param
blanchet@36281
   292
fun string_for_raw_param (key, values) =
blanchet@36481
   293
  key ^ (case space_implode " " values of "" => "" | value => " = " ^ value)
blanchet@36281
   294
blanchet@40059
   295
fun minimize_command override_params i prover_name fact_names =
blanchet@40059
   296
  sledgehammerN ^ " " ^ minimizeN ^ " [prover = " ^ prover_name ^
blanchet@36281
   297
  (override_params |> filter is_raw_param_relevant_for_minimize
blanchet@36281
   298
                   |> implode o map (prefix ", " o string_for_raw_param)) ^
blanchet@37171
   299
  "] (" ^ space_implode " " fact_names ^ ")" ^
blanchet@36281
   300
  (if i = 1 then "" else " " ^ string_of_int i)
blanchet@36281
   301
blanchet@35966
   302
fun hammer_away override_params subcommand opt_i relevance_override state =
blanchet@35963
   303
  let
blanchet@40069
   304
    val ctxt = Proof.context_of state
blanchet@41258
   305
    val override_params =
blanchet@41258
   306
      override_params |> map (check_and_repair_raw_param ctxt)
blanchet@35965
   307
  in
blanchet@35965
   308
    if subcommand = runN then
blanchet@36281
   309
      let val i = the_default 1 opt_i in
blanchet@42444
   310
        run_sledgehammer (get_params false ctxt override_params) false i
blanchet@39318
   311
                         relevance_override (minimize_command override_params i)
blanchet@39318
   312
                         state
blanchet@39318
   313
        |> K ()
blanchet@36281
   314
      end
blanchet@35965
   315
    else if subcommand = minimizeN then
blanchet@40069
   316
      run_minimize (get_params false ctxt override_params) (the_default 1 opt_i)
blanchet@38590
   317
                   (#add relevance_override) state
blanchet@35965
   318
    else if subcommand = messagesN then
blanchet@35965
   319
      messages opt_i
blanchet@41727
   320
    else if subcommand = supported_proversN then
blanchet@41727
   321
      supported_provers ctxt
blanchet@40059
   322
    else if subcommand = running_proversN then
blanchet@40059
   323
      running_provers ()
blanchet@40059
   324
    else if subcommand = kill_proversN then
blanchet@40059
   325
      kill_provers ()
blanchet@35965
   326
    else if subcommand = refresh_tptpN then
blanchet@35965
   327
      refresh_systems_on_tptp ()
blanchet@35965
   328
    else
blanchet@35965
   329
      error ("Unknown subcommand: " ^ quote subcommand ^ ".")
blanchet@35965
   330
  end
blanchet@35963
   331
blanchet@35966
   332
fun sledgehammer_trans (((subcommand, params), relevance_override), opt_i) =
blanchet@35966
   333
  Toplevel.keep (hammer_away params subcommand opt_i relevance_override
blanchet@35966
   334
                 o Toplevel.proof_of)
blanchet@35963
   335
blanchet@35963
   336
fun string_for_raw_param (name, value) = name ^ " = " ^ space_implode " " value
blanchet@35963
   337
blanchet@35965
   338
fun sledgehammer_params_trans params =
blanchet@35963
   339
  Toplevel.theory
blanchet@35965
   340
      (fold set_default_raw_param params
blanchet@39318
   341
       #> tap (fn thy =>
wenzelm@42361
   342
                  let val ctxt = Proof_Context.init_global thy in
blanchet@40069
   343
                    writeln ("Default parameters for Sledgehammer:\n" ^
blanchet@40069
   344
                             (case default_raw_params ctxt |> rev of
blanchet@40069
   345
                                [] => "none"
blanchet@40069
   346
                              | params =>
blanchet@41258
   347
                                params |> map (check_and_repair_raw_param ctxt)
blanchet@41258
   348
                                       |> map string_for_raw_param
blanchet@41258
   349
                                       |> sort_strings |> cat_lines))
blanchet@40069
   350
                  end))
blanchet@35963
   351
wenzelm@36960
   352
val parse_key = Scan.repeat1 Parse.typ_group >> space_implode " "
blanchet@42581
   353
val parse_value =
blanchet@42581
   354
  Scan.repeat1 (Parse.xname || Parse.float_number || Parse.$$$ "!!"
blanchet@42581
   355
                || Parse.$$$ "!")
wenzelm@36960
   356
val parse_param = parse_key -- Scan.optional (Parse.$$$ "=" |-- parse_value) []
wenzelm@36960
   357
val parse_params = Scan.optional (Args.bracks (Parse.list parse_param)) []
blanchet@35965
   358
val parse_fact_refs =
blanchet@38996
   359
  Scan.repeat1 (Scan.unless (Parse.name -- Args.colon) Parse_Spec.xthm)
blanchet@35966
   360
val parse_relevance_chunk =
blanchet@39318
   361
  (Args.add |-- Args.colon |-- parse_fact_refs >> add_relevance_override)
blanchet@39318
   362
  || (Args.del |-- Args.colon |-- parse_fact_refs >> del_relevance_override)
blanchet@36188
   363
  || (parse_fact_refs >> only_relevance_override)
blanchet@35966
   364
val parse_relevance_override =
blanchet@36188
   365
  Scan.optional (Args.parens (Scan.repeat parse_relevance_chunk
blanchet@36188
   366
                              >> merge_relevance_overrides))
blanchet@39318
   367
                no_relevance_override
blanchet@35963
   368
val parse_sledgehammer_command =
blanchet@37399
   369
  (Scan.optional Parse.short_ident runN -- parse_params
blanchet@37399
   370
   -- parse_relevance_override -- Scan.option Parse.nat) #>> sledgehammer_trans
blanchet@35963
   371
val parse_sledgehammer_params_command =
blanchet@35963
   372
  parse_params #>> sledgehammer_params_trans
blanchet@35963
   373
blanchet@35963
   374
val _ =
wenzelm@36960
   375
  Outer_Syntax.improper_command sledgehammerN
wenzelm@36960
   376
      "search for first-order proof using automatic theorem provers" Keyword.diag
blanchet@36394
   377
      parse_sledgehammer_command
blanchet@35963
   378
val _ =
wenzelm@36960
   379
  Outer_Syntax.command sledgehammer_paramsN
wenzelm@36960
   380
      "set and display the default parameters for Sledgehammer" Keyword.thy_decl
blanchet@36394
   381
      parse_sledgehammer_params_command
blanchet@36394
   382
blanchet@39318
   383
fun auto_sledgehammer state =
blanchet@40931
   384
  let val ctxt = Proof.context_of state in
blanchet@42447
   385
    run_sledgehammer (get_params true ctxt []) true 1 no_relevance_override
blanchet@42447
   386
                     (minimize_command [] 1) state
blanchet@40931
   387
  end
blanchet@39318
   388
blanchet@40931
   389
val setup = Auto_Tools.register_tool (auto, auto_sledgehammer)
blanchet@39318
   390
blanchet@35866
   391
end;