src/HOL/Tools/Sledgehammer/sledgehammer_isar.ML
author blanchet
Fri, 23 Apr 2010 19:12:49 +0200
changeset 36378 f32c567dbcaa
parent 36376 e83d52a52449
child 36394 1a48d18449d8
permissions -rw-r--r--
remove some bloat
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36375
2482446a604c move the minimizer to the Sledgehammer directory
blanchet
parents: 36373
diff changeset
     1
(*  Title:      HOL/Tools/Sledgehammer/sledgehammer_isar.ML
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
     2
    Author:     Jasmin Blanchette, TU Muenchen
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
     3
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
     4
Adds "sledgehammer" and related commands to Isabelle/Isar's outer syntax.
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
     5
*)
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
     6
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
     7
signature SLEDGEHAMMER_ISAR =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
     8
sig
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
     9
  type params = ATP_Manager.params
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    10
36371
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    11
  val atps: string Unsynchronized.ref
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    12
  val timeout: int Unsynchronized.ref
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    13
  val full_types: bool Unsynchronized.ref
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    14
  val default_params : theory -> (string * string) list -> params
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    15
end;
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    16
35971
4f24a4e9af4a make Mirabelle happy again
blanchet
parents: 35970
diff changeset
    17
structure Sledgehammer_Isar : SLEDGEHAMMER_ISAR =
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
    18
struct
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
    19
35971
4f24a4e9af4a make Mirabelle happy again
blanchet
parents: 35970
diff changeset
    20
open Sledgehammer_Util
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
    21
open ATP_Manager
36376
e83d52a52449 renamed module "ATP_Wrapper" to "ATP_Systems"
blanchet
parents: 36375
diff changeset
    22
open ATP_Systems
36375
2482446a604c move the minimizer to the Sledgehammer directory
blanchet
parents: 36373
diff changeset
    23
open Sledgehammer_Fact_Minimizer
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
    24
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
    25
structure K = OuterKeyword and P = OuterParse
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
    26
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    27
fun add_to_relevance_override ns : relevance_override =
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    28
  {add = ns, del = [], only = false}
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    29
fun del_from_relevance_override ns : relevance_override =
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    30
  {add = [], del = ns, only = false}
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    31
fun only_relevance_override ns : relevance_override =
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    32
  {add = ns, del = [], only = true}
36188
35b9f0db49a0 fiddle with Sledgehammer option syntax
blanchet
parents: 36183
diff changeset
    33
val no_relevance_override = add_to_relevance_override []
36003
eb44a5d40b9e make SML/NJ happy
blanchet
parents: 35971
diff changeset
    34
fun merge_relevance_override_pairwise (r1 : relevance_override)
eb44a5d40b9e make SML/NJ happy
blanchet
parents: 35971
diff changeset
    35
                                      (r2 : relevance_override) =
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    36
  {add = #add r1 @ #add r2, del = #del r1 @ #del r2,
36183
f723348b2231 Sledgehammer: the empty set of fact () should mean nothing, not unchanged
blanchet
parents: 36143
diff changeset
    37
   only = #only r1 andalso #only r2}
36188
35b9f0db49a0 fiddle with Sledgehammer option syntax
blanchet
parents: 36183
diff changeset
    38
fun merge_relevance_overrides rs =
35b9f0db49a0 fiddle with Sledgehammer option syntax
blanchet
parents: 36183
diff changeset
    39
  fold merge_relevance_override_pairwise rs (only_relevance_override [])
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
    40
36371
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    41
(*** parameters ***)
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    42
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    43
val atps = Unsynchronized.ref (default_atps_param_value ())
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    44
val timeout = Unsynchronized.ref 60
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    45
val full_types = Unsynchronized.ref false
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    46
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    47
val _ =
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    48
  ProofGeneralPgip.add_preference Preferences.category_proof
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    49
      (Preferences.string_pref atps
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    50
          "Sledgehammer: ATPs"
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    51
          "Default automatic provers (separated by whitespace)")
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    52
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    53
val _ =
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    54
  ProofGeneralPgip.add_preference Preferences.category_proof
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    55
      (Preferences.int_pref timeout
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
    56
          "Sledgehammer: Time Limit"
36371
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    57
          "ATPs will be interrupted after this time (in seconds)")
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    58
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    59
val _ =
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    60
  ProofGeneralPgip.add_preference Preferences.category_proof
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    61
      (Preferences.bool_pref full_types
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
    62
          "Sledgehammer: Full Types" "ATPs will use full type information")
36371
8c83ea1a7740 move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents: 36290
diff changeset
    63
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    64
type raw_param = string * string list
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    65
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    66
val default_default_params =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    67
  [("debug", "false"),
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    68
   ("verbose", "false"),
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
    69
   ("overlord", "false"),
36235
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
    70
   ("explicit_apply", "false"),
36058
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36003
diff changeset
    71
   ("respect_no_atp", "true"),
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
    72
   ("relevance_threshold", "50"),
36058
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36003
diff changeset
    73
   ("convergence", "320"),
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36189
diff changeset
    74
   ("theory_relevant", "smart"),
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    75
   ("higher_order", "smart"),
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    76
   ("follow_defs", "false"),
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    77
   ("isar_proof", "false"),
36064
48aec67c284f added "modulus" and "sorts" options to control Sledgehammer's Isar proof output
blanchet
parents: 36063
diff changeset
    78
   ("modulus", "1"),
48aec67c284f added "modulus" and "sorts" options to control Sledgehammer's Isar proof output
blanchet
parents: 36063
diff changeset
    79
   ("sorts", "false"),
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    80
   ("minimize_timeout", "5 s")]
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    81
36140
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
    82
val alias_params =
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
    83
  [("atp", "atps")]
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
    84
val negated_alias_params =
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    85
  [("no_debug", "debug"),
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    86
   ("quiet", "verbose"),
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
    87
   ("no_overlord", "overlord"),
36235
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
    88
   ("implicit_apply", "explicit_apply"),
36058
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36003
diff changeset
    89
   ("ignore_no_atp", "respect_no_atp"),
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    90
   ("partial_types", "full_types"),
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36189
diff changeset
    91
   ("theory_irrelevant", "theory_relevant"),
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    92
   ("first_order", "higher_order"),
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    93
   ("dont_follow_defs", "follow_defs"),
36064
48aec67c284f added "modulus" and "sorts" options to control Sledgehammer's Isar proof output
blanchet
parents: 36063
diff changeset
    94
   ("metis_proof", "isar_proof"),
48aec67c284f added "modulus" and "sorts" options to control Sledgehammer's Isar proof output
blanchet
parents: 36063
diff changeset
    95
   ("no_sorts", "sorts")]
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
    96
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
    97
val params_for_minimize =
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
    98
  ["full_types", "explicit_apply", "higher_order", "isar_proof", "modulus",
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
    99
   "sorts", "minimize_timeout"]
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   100
35971
4f24a4e9af4a make Mirabelle happy again
blanchet
parents: 35970
diff changeset
   101
val property_dependent_params = ["atps", "full_types", "timeout"]
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   102
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   103
fun is_known_raw_param s =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   104
  AList.defined (op =) default_default_params s orelse
36140
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   105
  AList.defined (op =) alias_params s orelse
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   106
  AList.defined (op =) negated_alias_params s orelse
35971
4f24a4e9af4a make Mirabelle happy again
blanchet
parents: 35970
diff changeset
   107
  member (op =) property_dependent_params s
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   108
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   109
fun check_raw_param (s, _) =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   110
  if is_known_raw_param s then ()
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   111
  else error ("Unknown parameter: " ^ quote s ^ ".")
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   112
36140
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   113
fun unalias_raw_param (name, value) =
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   114
  case AList.lookup (op =) alias_params name of
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   115
    SOME name' => (name', value)
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   116
  | NONE =>
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   117
    case AList.lookup (op =) negated_alias_params name of
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   118
      SOME name' => (name', case value of
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   119
                              ["false"] => ["true"]
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   120
                            | ["true"] => ["false"]
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   121
                            | [] => ["false"]
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   122
                            | _ => value)
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   123
    | NONE => (name, value)
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   124
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   125
structure Data = Theory_Data(
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   126
  type T = raw_param list
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   127
  val empty = default_default_params |> map (apsnd single)
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   128
  val extend = I
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   129
  fun merge p : T = AList.merge (op =) (K true) p)
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   130
36140
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   131
val set_default_raw_param = Data.map o AList.update (op =) o unalias_raw_param
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   132
fun default_raw_params thy =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   133
  Data.get thy
36140
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   134
  |> fold (AList.default (op =))
36290
c29283184c7a remove hack that is no longer necessary now that "ATP_Wrapper" properly detects which ATPs are installed
blanchet
parents: 36281
diff changeset
   135
          [("atps", [!atps]),
36140
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   136
           ("full_types", [if !full_types then "true" else "false"]),
36142
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36141
diff changeset
   137
           ("timeout", let val timeout = !timeout in
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36141
diff changeset
   138
                         [if timeout <= 0 then "none"
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36141
diff changeset
   139
                          else string_of_int timeout ^ " s"]
f5e15e9aae10 make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents: 36141
diff changeset
   140
                       end)]
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   141
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   142
val infinity_time_in_secs = 60 * 60 * 24 * 365
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   143
val the_timeout = the_default (Time.fromSeconds infinity_time_in_secs)
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   144
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   145
fun extract_params thy default_params override_params =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   146
  let
36140
08b2a7ecb6c3 fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents: 36064
diff changeset
   147
    val override_params = map unalias_raw_param override_params
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   148
    val raw_params = rev override_params @ rev default_params
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   149
    val lookup = Option.map (space_implode " ") o AList.lookup (op =) raw_params
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   150
    val lookup_string = the_default "" o lookup
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   151
    fun general_lookup_bool option default_value name =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   152
      case lookup name of
35970
3d41a2a490f0 revert debugging output that shouldn't have been submitted in the first place
blanchet
parents: 35966
diff changeset
   153
        SOME s => parse_bool_option option name s
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   154
      | NONE => default_value
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   155
    val lookup_bool = the o general_lookup_bool false (SOME false)
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   156
    val lookup_bool_option = general_lookup_bool true NONE
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   157
    fun lookup_time name =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   158
      the_timeout (case lookup name of
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   159
                     NONE => NONE
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   160
                   | SOME s => parse_time_option name s)
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   161
    fun lookup_int name =
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   162
      case lookup name of
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   163
        NONE => 0
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   164
      | SOME s => case Int.fromString s of
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   165
                    SOME n => n
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   166
                  | NONE => error ("Parameter " ^ quote name ^
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   167
                                   " must be assigned an integer value.")
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   168
    val debug = lookup_bool "debug"
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   169
    val verbose = debug orelse lookup_bool "verbose"
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   170
    val overlord = lookup_bool "overlord"
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   171
    val atps = lookup_string "atps" |> space_explode " "
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   172
    val full_types = lookup_bool "full_types"
36235
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
   173
    val explicit_apply = lookup_bool "explicit_apply"
36058
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36003
diff changeset
   174
    val respect_no_atp = lookup_bool "respect_no_atp"
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   175
    val relevance_threshold =
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   176
      0.01 * Real.fromInt (lookup_int "relevance_threshold")
36058
8256d5a185bd added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents: 36003
diff changeset
   177
    val convergence = 0.01 * Real.fromInt (lookup_int "convergence")
36220
f3655a3ae1ab rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents: 36189
diff changeset
   178
    val theory_relevant = lookup_bool_option "theory_relevant"
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   179
    val higher_order = lookup_bool_option "higher_order"
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   180
    val follow_defs = lookup_bool "follow_defs"
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   181
    val isar_proof = lookup_bool "isar_proof"
36064
48aec67c284f added "modulus" and "sorts" options to control Sledgehammer's Isar proof output
blanchet
parents: 36063
diff changeset
   182
    val modulus = Int.max (1, lookup_int "modulus")
48aec67c284f added "modulus" and "sorts" options to control Sledgehammer's Isar proof output
blanchet
parents: 36063
diff changeset
   183
    val sorts = lookup_bool "sorts"
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   184
    val timeout = lookup_time "timeout"
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   185
    val minimize_timeout = lookup_time "minimize_timeout"
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   186
  in
36143
6490319b1703 added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents: 36142
diff changeset
   187
    {debug = debug, verbose = verbose, overlord = overlord, atps = atps,
36235
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
   188
     full_types = full_types, explicit_apply = explicit_apply,
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
   189
     respect_no_atp = respect_no_atp, relevance_threshold = relevance_threshold,
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
   190
     convergence = convergence, theory_relevant = theory_relevant,
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
   191
     higher_order = higher_order, follow_defs = follow_defs,
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
   192
     isar_proof = isar_proof, modulus = modulus, sorts = sorts,
61159615a0c5 added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents: 36223
diff changeset
   193
     timeout = timeout, minimize_timeout = minimize_timeout}
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   194
  end
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   195
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   196
fun get_params thy = extract_params thy (default_raw_params thy)
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   197
fun default_params thy = get_params thy o map (apsnd single)
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   198
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   199
(* Sledgehammer the given subgoal *)
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   200
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   201
fun run {atps = [], ...} _ _ _ _ = error "No ATP is set."
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   202
  | run (params as {atps, timeout, ...}) i relevance_override minimize_command
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   203
        proof_state =
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   204
    let
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   205
      val birth_time = Time.now ()
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   206
      val death_time = Time.+ (birth_time, timeout)
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   207
      val _ = kill_atps ()  (* race w.r.t. other invocations of Sledgehammer *)
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   208
      val _ = priority "Sledgehammering..."
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   209
      val _ = List.app (start_prover_thread params birth_time death_time i
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   210
                                            relevance_override minimize_command
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   211
                                            proof_state) atps
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   212
    in () end
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   213
36378
f32c567dbcaa remove some bloat
blanchet
parents: 36376
diff changeset
   214
fun minimize override_params i fact_refs state =
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   215
  let
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   216
    val thy = Proof.theory_of state
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   217
    val ctxt = Proof.context_of state
36378
f32c567dbcaa remove some bloat
blanchet
parents: 36376
diff changeset
   218
    val theorems_from_refs =
f32c567dbcaa remove some bloat
blanchet
parents: 36376
diff changeset
   219
      map o pairf Facts.string_of_ref o ProofContext.get_fact
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   220
    val name_thms_pairs = theorems_from_refs ctxt fact_refs
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   221
  in
36378
f32c567dbcaa remove some bloat
blanchet
parents: 36376
diff changeset
   222
    priority (#2 (minimize_theorems (get_params thy override_params) i state
f32c567dbcaa remove some bloat
blanchet
parents: 36376
diff changeset
   223
                                    name_thms_pairs))
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   224
  end
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   225
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   226
val sledgehammerN = "sledgehammer"
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   227
val sledgehammer_paramsN = "sledgehammer_params"
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   228
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   229
val runN = "run"
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   230
val minimizeN = "minimize"
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   231
val messagesN = "messages"
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   232
val available_atpsN = "available_atps"
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   233
val running_atpsN = "running_atps"
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   234
val kill_atpsN = "kill_atps"
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   235
val refresh_tptpN = "refresh_tptp"
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   236
val helpN = "help"
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   237
36141
c31602d268be make Sledgehammer's "timeout" option work for "minimize"
blanchet
parents: 36140
diff changeset
   238
fun minimizize_raw_param_name "timeout" = "minimize_timeout"
c31602d268be make Sledgehammer's "timeout" option work for "minimize"
blanchet
parents: 36140
diff changeset
   239
  | minimizize_raw_param_name name = name
c31602d268be make Sledgehammer's "timeout" option work for "minimize"
blanchet
parents: 36140
diff changeset
   240
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   241
val is_raw_param_relevant_for_minimize =
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   242
  member (op =) params_for_minimize o fst o unalias_raw_param
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   243
fun string_for_raw_param (key, values) =
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   244
  key ^ (case space_implode " " values of
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   245
           "" => ""
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   246
         | value => " = " ^ value)
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   247
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   248
fun minimize_command override_params i atp_name facts =
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   249
  sledgehammerN ^ " " ^ minimizeN ^ " [atp = " ^ atp_name ^
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   250
  (override_params |> filter is_raw_param_relevant_for_minimize
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   251
                   |> implode o map (prefix ", " o string_for_raw_param)) ^
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   252
  "] (" ^ space_implode " " facts ^ ")" ^
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   253
  (if i = 1 then "" else " " ^ string_of_int i)
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   254
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   255
fun hammer_away override_params subcommand opt_i relevance_override state =
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   256
  let
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   257
    val thy = Proof.theory_of state
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   258
    val _ = List.app check_raw_param override_params
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   259
  in
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   260
    if subcommand = runN then
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   261
      let val i = the_default 1 opt_i in
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   262
        run (get_params thy override_params) i relevance_override
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   263
            (minimize_command override_params i) state
36281
dbbf4d5d584d pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents: 36235
diff changeset
   264
      end
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   265
    else if subcommand = minimizeN then
36378
f32c567dbcaa remove some bloat
blanchet
parents: 36376
diff changeset
   266
      minimize (map (apfst minimizize_raw_param_name) override_params)
36141
c31602d268be make Sledgehammer's "timeout" option work for "minimize"
blanchet
parents: 36140
diff changeset
   267
               (the_default 1 opt_i) (#add relevance_override) state
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   268
    else if subcommand = messagesN then
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   269
      messages opt_i
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   270
    else if subcommand = available_atpsN then
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   271
      available_atps thy
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   272
    else if subcommand = running_atpsN then
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   273
      running_atps ()
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   274
    else if subcommand = kill_atpsN then
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   275
      kill_atps ()
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   276
    else if subcommand = refresh_tptpN then
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   277
      refresh_systems_on_tptp ()
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   278
    else
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   279
      error ("Unknown subcommand: " ^ quote subcommand ^ ".")
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   280
  end
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   281
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   282
fun sledgehammer_trans (((subcommand, params), relevance_override), opt_i) =
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   283
  Toplevel.keep (hammer_away params subcommand opt_i relevance_override
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   284
                 o Toplevel.proof_of)
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   285
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   286
fun string_for_raw_param (name, value) = name ^ " = " ^ space_implode " " value
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   287
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   288
fun sledgehammer_params_trans params =
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   289
  Toplevel.theory
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   290
      (fold set_default_raw_param params
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   291
       #> tap (fn thy => 
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   292
                  writeln ("Default parameters for Sledgehammer:\n" ^
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   293
                           (case rev (default_raw_params thy) of
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   294
                              [] => "none"
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   295
                            | params =>
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   296
                              (map check_raw_param params;
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   297
                               params |> map string_for_raw_param
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   298
                                      |> sort_strings |> cat_lines)))))
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   299
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   300
val parse_key = Scan.repeat1 P.typ_group >> space_implode " "
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   301
val parse_value = Scan.repeat1 P.xname
35965
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   302
val parse_param = parse_key -- Scan.optional (P.$$$ "=" |-- parse_value) []
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   303
val parse_params = Scan.optional (Args.bracks (P.list parse_param)) []
0fce6db7babd added a syntax for specifying facts to Sledgehammer;
blanchet
parents: 35963
diff changeset
   304
val parse_fact_refs =
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   305
  Scan.repeat1 (Scan.unless (P.name -- Args.colon)
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   306
                            (P.xname -- Scan.option Attrib.thm_sel)
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   307
                >> (fn (name, interval) =>
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   308
                       Facts.Named ((name, Position.none), interval)))
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   309
val parse_relevance_chunk =
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   310
  (Args.add |-- Args.colon |-- parse_fact_refs >> add_to_relevance_override)
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   311
  || (Args.del |-- Args.colon |-- parse_fact_refs
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   312
      >> del_from_relevance_override)
36188
35b9f0db49a0 fiddle with Sledgehammer option syntax
blanchet
parents: 36183
diff changeset
   313
  || (parse_fact_refs >> only_relevance_override)
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   314
val parse_relevance_override =
36188
35b9f0db49a0 fiddle with Sledgehammer option syntax
blanchet
parents: 36183
diff changeset
   315
  Scan.optional (Args.parens (Scan.repeat parse_relevance_chunk
35b9f0db49a0 fiddle with Sledgehammer option syntax
blanchet
parents: 36183
diff changeset
   316
                              >> merge_relevance_overrides))
35b9f0db49a0 fiddle with Sledgehammer option syntax
blanchet
parents: 36183
diff changeset
   317
                (add_to_relevance_override [])
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   318
val parse_sledgehammer_command =
35966
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   319
  (Scan.optional P.short_ident runN -- parse_params -- parse_relevance_override
f8c738abaed8 honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents: 35965
diff changeset
   320
   -- Scan.option P.nat) #>> sledgehammer_trans
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   321
val parse_sledgehammer_params_command =
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   322
  parse_params #>> sledgehammer_params_trans
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   323
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   324
val _ =
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   325
  OuterSyntax.improper_command sledgehammerN
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   326
    "search for first-order proof using automatic theorem provers" K.diag
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   327
    parse_sledgehammer_command
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   328
val _ =
36373
66af0a49de39 move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents: 36371
diff changeset
   329
  OuterSyntax.command sledgehammer_paramsN
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   330
    "set and display the default parameters for Sledgehammer" K.thy_decl
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35962
diff changeset
   331
    parse_sledgehammer_params_command
35866
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   332
513074557e06 move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff changeset
   333
end;