src/HOL/Tools/try_methods.ML
author blanchet
Fri, 27 May 2011 10:30:08 +0200
changeset 43016 42330f25142c
parent 42179 src/HOL/Tools/try.ML@24662b614fd4
child 43018 121aa59b4d17
permissions -rw-r--r--
renamed "try" "try_methods"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
     1
(*  Title:      HOL/Tools/try_methods.ML
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     2
    Author:     Jasmin Blanchette, TU Muenchen
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     3
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     4
Try a combination of proof methods.
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     5
*)
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     6
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
     7
signature TRY_METHODS =
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     8
sig
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
     9
  val auto : bool Unsynchronized.ref
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
    10
  val try_methods :
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    11
    Time.time option -> string list * string list * string list * string list
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    12
    -> Proof.state -> bool
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
    13
  val setup : theory -> theory
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    14
end;
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    15
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
    16
structure Try_Methods : TRY_METHODS =
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    17
struct
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    18
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
    19
val auto = Unsynchronized.ref false
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
    20
39333
c277c79fb9db add Proof General option
blanchet
parents: 39332
diff changeset
    21
val _ =
c277c79fb9db add Proof General option
blanchet
parents: 39332
diff changeset
    22
  ProofGeneralPgip.add_preference Preferences.category_tracing
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
    23
      (Preferences.bool_pref auto "auto-try-methods"
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
    24
                             "Try standard proof methods.")
39333
c277c79fb9db add Proof General option
blanchet
parents: 39332
diff changeset
    25
40301
bf39a257b3d3 simplified some time constants;
wenzelm
parents: 40222
diff changeset
    26
val default_timeout = seconds 5.0
38944
827c98e8ba8b fiddling with "try"
blanchet
parents: 38942
diff changeset
    27
39336
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    28
fun can_apply timeout_opt pre post tac st =
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    29
  let val {goal, ...} = Proof.goal st in
39336
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    30
    case (case timeout_opt of
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    31
            SOME timeout => TimeLimit.timeLimit timeout
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    32
          | NONE => fn f => fn x => f x) (Seq.pull o tac) (pre st) of
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    33
      SOME (x, _) => nprems_of (post x) < nprems_of goal
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    34
    | NONE => false
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    35
  end
40113
1f61f0826e8a handle timeouts (to prevent failure from other threads);
blanchet
parents: 39719
diff changeset
    36
  handle TimeLimit.TimeOut => false
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    37
39336
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    38
fun do_generic timeout_opt command pre post apply st =
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    39
  let val timer = Timer.startRealTimer () in
39336
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    40
    if can_apply timeout_opt pre post apply st then
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    41
      SOME (command, Time.toMilliseconds (Timer.checkRealTimer timer))
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    42
    else
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    43
      NONE
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    44
  end
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    45
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    46
val parse_method =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    47
  enclose "(" ")"
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    48
  #> Outer_Syntax.scan Position.start
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    49
  #> filter Token.is_proper
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    50
  #> Scan.read Token.stopper Method.parse
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    51
  #> (fn SOME (Method.Source src) => src | _ => raise Fail "expected Source")
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    52
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    53
fun apply_named_method_on_first_goal method thy =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    54
  method |> parse_method
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    55
         |> Method.method thy
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    56
         |> Method.Basic
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    57
         |> curry Method.SelectGoals 1
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    58
         |> Proof.refine
40222
cd6d2b0a4096 reintroduced Auto Try, but this time really off by default -- and leave some classical+simp reasoners out for Auto Try (but keep them for Try)
blanchet
parents: 40132
diff changeset
    59
  handle ERROR _ => K Seq.empty (* e.g., the method isn't available yet *)
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    60
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    61
fun add_attr_text (NONE, _) s = s
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    62
  | add_attr_text (_, []) s = s
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    63
  | add_attr_text (SOME x, fs) s =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    64
    s ^ " " ^ (if x = "" then "" else x ^ ": ") ^ space_implode " " fs
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    65
fun attrs_text (sx, ix, ex, dx) (ss, is, es, ds) =
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    66
  "" |> fold add_attr_text [(sx, ss), (ix, is), (ex, es), (dx, ds)]
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    67
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    68
fun do_named_method (name, ((all_goals, run_if_auto), attrs)) auto timeout_opt
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    69
                    quad st =
40222
cd6d2b0a4096 reintroduced Auto Try, but this time really off by default -- and leave some classical+simp reasoners out for Auto Try (but keep them for Try)
blanchet
parents: 40132
diff changeset
    70
  if not auto orelse run_if_auto then
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    71
    let val attrs = attrs_text attrs quad in
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    72
      do_generic timeout_opt
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    73
                 (name ^ (if all_goals andalso
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    74
                             nprems_of (#goal (Proof.goal st)) > 1 then
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    75
                            "[1]"
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    76
                          else
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    77
                            "") ^
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    78
                  attrs) I (#goal o Proof.goal)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    79
                 (apply_named_method_on_first_goal (name ^ attrs)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    80
                                                   (Proof.theory_of st)) st
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    81
    end
40222
cd6d2b0a4096 reintroduced Auto Try, but this time really off by default -- and leave some classical+simp reasoners out for Auto Try (but keep them for Try)
blanchet
parents: 40132
diff changeset
    82
  else
cd6d2b0a4096 reintroduced Auto Try, but this time really off by default -- and leave some classical+simp reasoners out for Auto Try (but keep them for Try)
blanchet
parents: 40132
diff changeset
    83
    NONE
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    84
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    85
val full_attrs = (SOME "simp", SOME "intro", SOME "elim", SOME "dest")
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    86
val clas_attrs = (NONE, SOME "intro", SOME "elim", SOME "dest")
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    87
val simp_attrs = (SOME "add", NONE, NONE, NONE)
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    88
val metis_attrs = (SOME "", SOME "", SOME "", SOME "")
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    89
val no_attrs = (NONE, NONE, NONE, NONE)
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    90
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
    91
(* name * ((all_goals, run_if_auto), (simp, intro, elim, dest) *)
39547
5df45da44bfb reorder proof methods and take out "best";
blanchet
parents: 39336
diff changeset
    92
val named_methods =
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    93
  [("simp", ((false, true), simp_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    94
   ("auto", ((true, true), full_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    95
   ("fast", ((false, false), clas_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    96
   ("fastsimp", ((false, false), full_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    97
   ("force", ((false, false), full_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    98
   ("blast", ((false, true), clas_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    99
   ("metis", ((false, true), metis_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   100
   ("linarith", ((false, true), no_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   101
   ("presburger", ((false, true), no_attrs))]
39547
5df45da44bfb reorder proof methods and take out "best";
blanchet
parents: 39336
diff changeset
   102
val do_methods = map do_named_method named_methods
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   103
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   104
fun time_string (s, ms) = s ^ ": " ^ string_of_int ms ^ " ms"
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   105
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   106
fun do_try_methods auto timeout_opt quad st =
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   107
  let
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   108
    val st = st |> Proof.map_context (Config.put Metis_Tactics.verbose false)
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   109
  in
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   110
    case do_methods |> Par_List.map (fn f => f auto timeout_opt quad st)
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   111
                    |> map_filter I |> sort (int_ord o pairself snd) of
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   112
      [] => (if auto then () else writeln "No proof found."; (false, st))
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   113
    | xs as (s, _) :: _ =>
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   114
      let
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   115
        val xs = xs |> map (fn (s, n) => (n, hd (space_explode " " s)))
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   116
                    |> AList.coalesce (op =)
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   117
                    |> map (swap o apsnd commas)
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   118
        val need_parens = exists_string (curry (op =) " ") s
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   119
        val message =
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   120
          (if auto then "Auto Try Methods found a proof"
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   121
           else "Try this command") ^ ": " ^
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   122
          Markup.markup Markup.sendback
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   123
              ((if nprems_of (#goal (Proof.goal st)) = 1 then "by"
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   124
                else "apply") ^ " " ^ (s |> need_parens ? enclose "(" ")")) ^
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   125
          "\n(" ^ space_implode "; " (map time_string xs) ^ ").\n"
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   126
      in
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   127
        (true, st |> (if auto then
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   128
                        Proof.goal_message
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   129
                            (fn () => Pretty.chunks [Pretty.str "",
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   130
                                      Pretty.markup Markup.hilite
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   131
                                                    [Pretty.str message]])
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   132
                      else
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   133
                        tap (fn _ => Output.urgent_message message)))
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   134
      end
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   135
  end
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
   136
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   137
fun try_methods timeout_opt = fst oo do_try_methods false timeout_opt
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   138
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   139
val try_methodsN = "try_methods"
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   140
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   141
fun try_methods_trans quad =
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   142
  Toplevel.keep (K () o do_try_methods false (SOME default_timeout) quad
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   143
                 o Toplevel.proof_of)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   144
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   145
fun merge_attrs (s1, i1, e1, d1) (s2, i2, e2, d2) =
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   146
  (s1 @ s2, i1 @ i2, e1 @ e2, d1 @ d2)
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   147
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   148
fun string_of_xthm (xref, args) =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   149
  Facts.string_of_ref xref ^
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   150
  implode (map (enclose "[" "]" o Pretty.str_of
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   151
                o Args.pretty_src @{context}) args)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   152
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   153
val parse_fact_refs =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   154
  Scan.repeat1 (Scan.unless (Parse.name -- Args.colon)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   155
                            (Parse_Spec.xthm >> string_of_xthm))
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   156
val parse_attr =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   157
     Args.$$$ "simp" |-- Args.colon |-- parse_fact_refs
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   158
     >> (fn ss => (ss, [], [], []))
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   159
  || Args.$$$ "intro" |-- Args.colon |-- parse_fact_refs
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   160
     >> (fn is => ([], is, [], []))
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   161
  || Args.$$$ "elim" |-- Args.colon |-- parse_fact_refs
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   162
     >> (fn es => ([], [], es, []))
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   163
  || Args.$$$ "dest" |-- Args.colon |-- parse_fact_refs
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   164
     >> (fn ds => ([], [], [], ds))
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   165
fun parse_attrs x =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   166
    (Args.parens parse_attrs
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   167
  || Scan.repeat parse_attr
42179
24662b614fd4 added support for "dest:" to "try"
blanchet
parents: 41999
diff changeset
   168
     >> (fn quad => fold merge_attrs quad ([], [], [], []))) x
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   169
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   170
val parse_try_methods_command =
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   171
  Scan.optional parse_attrs ([], [], [], []) #>> try_methods_trans
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   172
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   173
val _ =
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   174
  Outer_Syntax.improper_command try_methodsN
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   175
      "try a combination of proof methods" Keyword.diag
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   176
      parse_try_methods_command
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   177
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   178
val auto_try_methods = do_try_methods true NONE ([], [], [], [])
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
   179
43016
42330f25142c renamed "try" "try_methods"
blanchet
parents: 42179
diff changeset
   180
val setup = Auto_Tools.register_tool (auto, auto_try_methods)
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
   181
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   182
end;