src/HOL/Tools/try.ML
author bulwahn
Wed, 30 Mar 2011 11:32:52 +0200
changeset 42163 392fd6c4669c
parent 41999 3c029ef9e0f2
child 42179 24662b614fd4
permissions -rw-r--r--
renewing specifications in HOL: replacing types by type_synonym
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     1
(*  Title:      HOL/Tools/try.ML
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
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
     7
signature TRY =
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
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    10
  val invoke_try :
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    11
    Time.time option -> string list * string list * string list -> Proof.state
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    12
    -> 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
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    16
structure Try : TRY =
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
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
    23
      (Preferences.bool_pref auto "auto-try" "Try standard proof methods.")
39333
c277c79fb9db add Proof General option
blanchet
parents: 39332
diff changeset
    24
40301
bf39a257b3d3 simplified some time constants;
wenzelm
parents: 40222
diff changeset
    25
val default_timeout = seconds 5.0
38944
827c98e8ba8b fiddling with "try"
blanchet
parents: 38942
diff changeset
    26
39336
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    27
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
    28
  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
    29
    case (case timeout_opt of
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    30
            SOME timeout => TimeLimit.timeLimit timeout
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    31
          | 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
    32
      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
    33
    | NONE => false
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    34
  end
40113
1f61f0826e8a handle timeouts (to prevent failure from other threads);
blanchet
parents: 39719
diff changeset
    35
  handle TimeLimit.TimeOut => false
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    36
39336
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    37
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
    38
  let val timer = Timer.startRealTimer () in
39336
1899349a5026 change signature of "Try.invoke_try" to make it more flexible
blanchet
parents: 39334
diff changeset
    39
    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
    40
      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
    41
    else
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    42
      NONE
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    43
  end
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    44
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    45
val parse_method =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    46
  enclose "(" ")"
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    47
  #> Outer_Syntax.scan Position.start
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    48
  #> filter Token.is_proper
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    49
  #> Scan.read Token.stopper Method.parse
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    50
  #> (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
    51
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    52
fun apply_named_method_on_first_goal method thy =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    53
  method |> parse_method
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    54
         |> Method.method thy
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    55
         |> Method.Basic
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    56
         |> curry Method.SelectGoals 1
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    57
         |> 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
    58
  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
    59
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    60
fun add_attr_text (NONE, _) s = s
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    61
  | add_attr_text (_, []) s = s
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    62
  | add_attr_text (SOME x, fs) s =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    63
    s ^ " " ^ (if x = "" then "" else x ^ ": ") ^ space_implode " " fs
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    64
fun attrs_text (sx, ix, ex) (ss, is, es) =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    65
  "" |> fold add_attr_text [(sx, ss), (ix, is), (ex, es)]
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    66
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    67
fun do_named_method (name, ((all_goals, run_if_auto), attrs)) auto timeout_opt
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    68
                    triple 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
    69
  if not auto orelse run_if_auto then
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    70
    let val attrs = attrs_text attrs triple in
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    71
      do_generic timeout_opt
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    72
                 (name ^ (if all_goals andalso
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    73
                             nprems_of (#goal (Proof.goal st)) > 1 then
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    74
                            "[1]"
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    75
                          else
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    76
                            "") ^
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    77
                  attrs) I (#goal o Proof.goal)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    78
                 (apply_named_method_on_first_goal (name ^ attrs)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    79
                                                   (Proof.theory_of st)) st
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    80
    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
    81
  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
    82
    NONE
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
    83
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    84
val full_attrs = (SOME "simp", SOME "intro", SOME "elim")
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    85
val clas_attrs = (NONE, SOME "intro", SOME "elim")
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    86
val simp_attrs = (SOME "add", NONE, NONE)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    87
val metis_attrs = (SOME "", SOME "", SOME "")
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    88
val no_attrs = (NONE, NONE, NONE)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    89
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    90
(* name * ((all_goals, run_if_auto), (simp, intro, elim) *)
39547
5df45da44bfb reorder proof methods and take out "best";
blanchet
parents: 39336
diff changeset
    91
val named_methods =
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    92
  [("simp", ((false, true), simp_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    93
   ("auto", ((true, true), full_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    94
   ("fast", ((false, false), clas_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    95
   ("fastsimp", ((false, false), full_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    96
   ("force", ((false, false), full_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    97
   ("blast", ((false, true), clas_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    98
   ("metis", ((false, true), metis_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
    99
   ("linarith", ((false, true), no_attrs)),
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   100
   ("presburger", ((false, true), no_attrs))]
39547
5df45da44bfb reorder proof methods and take out "best";
blanchet
parents: 39336
diff changeset
   101
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
   102
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   103
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
   104
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   105
fun do_try auto timeout_opt triple st =
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   106
  let
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   107
    val st = st |> Proof.map_context (Config.put Metis_Tactics.verbose false)
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   108
  in
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   109
    case do_methods |> Par_List.map (fn f => f auto timeout_opt triple st)
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   110
                    |> map_filter I |> sort (int_ord o pairself snd) of
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   111
      [] => (if auto then () else writeln "No proof found."; (false, st))
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   112
    | xs as (s, _) :: _ =>
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   113
      let
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   114
        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
   115
                    |> AList.coalesce (op =)
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   116
                    |> map (swap o apsnd commas)
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   117
        val need_parens = exists_string (curry (op =) " ") s
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   118
        val message =
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   119
          (if auto then "Auto Try found a proof" else "Try this command") ^
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   120
          ": " ^
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   121
          Markup.markup Markup.sendback
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   122
              ((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
   123
                else "apply") ^ " " ^ (s |> need_parens ? enclose "(" ")")) ^
41038
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   124
          "\n(" ^ space_implode "; " (map time_string xs) ^ ").\n"
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   125
      in
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   126
        (true, st |> (if auto then
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   127
                        Proof.goal_message
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   128
                            (fn () => Pretty.chunks [Pretty.str "",
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   129
                                      Pretty.markup Markup.hilite
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   130
                                                    [Pretty.str message]])
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   131
                      else
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   132
                        tap (fn _ => Output.urgent_message message)))
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   133
      end
9592334001d5 quiet Metis in "try"
blanchet
parents: 40931
diff changeset
   134
  end
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
   135
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   136
fun invoke_try timeout_opt = fst oo do_try false timeout_opt
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   137
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   138
val tryN = "try"
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   139
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   140
fun try_trans triple =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   141
  Toplevel.keep (K () o do_try false (SOME default_timeout) triple
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   142
                 o Toplevel.proof_of)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   143
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   144
fun merge_attrs (s1, i1, e1) (s2, i2, e2) = (s1 @ s2, i1 @ i2, e1 @ e2)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   145
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   146
fun string_of_xthm (xref, args) =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   147
  Facts.string_of_ref xref ^
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   148
  implode (map (enclose "[" "]" o Pretty.str_of
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   149
                o Args.pretty_src @{context}) args)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   150
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   151
val parse_fact_refs =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   152
  Scan.repeat1 (Scan.unless (Parse.name -- Args.colon)
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   153
                            (Parse_Spec.xthm >> string_of_xthm))
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   154
val parse_attr =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   155
     Args.$$$ "simp" |-- Args.colon |-- parse_fact_refs
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   156
     >> (fn ss => (ss, [], []))
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   157
  || Args.$$$ "intro" |-- Args.colon |-- parse_fact_refs
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   158
     >> (fn is => ([], is, []))
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   159
  || Args.$$$ "elim" |-- Args.colon |-- parse_fact_refs
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   160
     >> (fn es => ([], [], es))
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   161
fun parse_attrs x =
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   162
    (Args.parens parse_attrs
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   163
  || Scan.repeat parse_attr
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   164
     >> (fn triple => fold merge_attrs triple ([], [], []))) x
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   165
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   166
val parse_try_command = Scan.optional parse_attrs ([], [], []) #>> try_trans
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   167
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   168
val _ =
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   169
  Outer_Syntax.improper_command tryN
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   170
      "try a combination of proof methods" Keyword.diag parse_try_command
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   171
41999
3c029ef9e0f2 added "simp:", "intro:", and "elim:" to "try" command
blanchet
parents: 41038
diff changeset
   172
val auto_try = do_try true NONE ([], [], [])
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
   173
40931
061b8257ab9f run synchronous Auto Tools in parallel
blanchet
parents: 40301
diff changeset
   174
val setup = Auto_Tools.register_tool (auto, auto_try)
39331
8b1969d603c0 added Auto Try to the mix of automatic tools
blanchet
parents: 39222
diff changeset
   175
38942
e10c11971fa7 "try" -- a new diagnosis tool that tries to apply several methods in parallel
blanchet
parents:
diff changeset
   176
end;