| author | wenzelm | 
| Thu, 18 Jul 2013 20:53:22 +0200 | |
| changeset 52697 | 6fb98a20c349 | 
| parent 52643 | 34c29356930e | 
| child 52717 | da7bf8b3d24a | 
| permissions | -rw-r--r-- | 
| 46641 | 1 | (* Title: HOL/Tools/try0.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 | |
| 46641 | 7 | signature TRY0 = | 
| 38942 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 8 | sig | 
| 46641 | 9 | val try0N : string | 
| 43020 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 blanchet parents: 
43018diff
changeset | 10 | val noneN : string | 
| 46641 | 11 | val try0 : | 
| 42179 | 12 | Time.time option -> string list * string list * string list * string list | 
| 13 | -> Proof.state -> bool | |
| 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 | |
| 46641 | 16 | structure Try0 : TRY0 = | 
| 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 | |
| 43026 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 19 | datatype mode = Auto_Try | Try | Normal | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 20 | |
| 46641 | 21 | val try0N = "try0" | 
| 43020 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 blanchet parents: 
43018diff
changeset | 22 | |
| 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 blanchet parents: 
43018diff
changeset | 23 | val noneN = "none" | 
| 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 blanchet parents: 
43018diff
changeset | 24 | |
| 39333 | 25 | val _ = | 
| 52639 | 26 | ProofGeneral.preference_option ProofGeneral.category_tracing | 
| 52017 
bc0238c1f73a
clarified preferences: "override" re-initialized on prover startup, and "default" sent to PG -- thus recover typical defaults like auto-quickcheck in PG 4.x;
 wenzelm parents: 
52007diff
changeset | 27 | NONE | 
| 52639 | 28 |     @{option auto_try0}
 | 
| 52017 
bc0238c1f73a
clarified preferences: "override" re-initialized on prover startup, and "default" sent to PG -- thus recover typical defaults like auto-quickcheck in PG 4.x;
 wenzelm parents: 
52007diff
changeset | 29 | "auto-try0" | 
| 
bc0238c1f73a
clarified preferences: "override" re-initialized on prover startup, and "default" sent to PG -- thus recover typical defaults like auto-quickcheck in PG 4.x;
 wenzelm parents: 
52007diff
changeset | 30 | "Try standard proof methods" | 
| 39333 | 31 | |
| 40301 | 32 | val default_timeout = seconds 5.0 | 
| 38944 | 33 | |
| 39336 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 blanchet parents: 
39334diff
changeset | 34 | 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 | 35 |   let val {goal, ...} = Proof.goal st in
 | 
| 39336 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 blanchet parents: 
39334diff
changeset | 36 | case (case timeout_opt of | 
| 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 blanchet parents: 
39334diff
changeset | 37 | SOME timeout => TimeLimit.timeLimit timeout | 
| 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 blanchet parents: 
39334diff
changeset | 38 | | 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 | 39 | 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 | 40 | | NONE => false | 
| 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 41 | end | 
| 40113 
1f61f0826e8a
handle timeouts (to prevent failure from other threads);
 blanchet parents: 
39719diff
changeset | 42 | handle TimeLimit.TimeOut => false | 
| 38942 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 43 | |
| 39336 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 blanchet parents: 
39334diff
changeset | 44 | 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 | 45 | let val timer = Timer.startRealTimer () in | 
| 39336 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 blanchet parents: 
39334diff
changeset | 46 | 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 | 47 | 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 | 48 | else | 
| 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 49 | NONE | 
| 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 50 | end | 
| 
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: 
41038diff
changeset | 52 | val parse_method = | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 53 |   enclose "(" ")"
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 54 | #> Outer_Syntax.scan Position.start | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 55 | #> filter Token.is_proper | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 56 | #> Scan.read Token.stopper Method.parse | 
| 49866 | 57 | #> (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 | 58 | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 59 | fun apply_named_method_on_first_goal method thy = | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 60 | method |> parse_method | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 61 | |> Method.method thy | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 62 | |> Method.Basic | 
| 51383 | 63 | |> curry Method.Select_Goals 1 | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 64 | |> 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: 
40132diff
changeset | 65 | 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 | 66 | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 67 | fun add_attr_text (NONE, _) s = s | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 68 | | add_attr_text (_, []) s = s | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 69 | | add_attr_text (SOME x, fs) s = | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 70 | s ^ " " ^ (if x = "" then "" else x ^ ": ") ^ space_implode " " fs | 
| 42179 | 71 | fun attrs_text (sx, ix, ex, dx) (ss, is, es, ds) = | 
| 72 | "" |> fold add_attr_text [(sx, ss), (ix, is), (ex, es), (dx, ds)] | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 73 | |
| 43026 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 74 | fun do_named_method (name, ((all_goals, run_if_auto_try), attrs)) mode | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 75 | timeout_opt quad st = | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 76 | if mode <> Auto_Try orelse run_if_auto_try then | 
| 42179 | 77 | let val attrs = attrs_text attrs quad in | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 78 | do_generic timeout_opt | 
| 48535 | 79 | (name ^ attrs ^ | 
| 80 | (if all_goals andalso | |
| 81 | nprems_of (#goal (Proof.goal st)) > 1 then | |
| 82 | " [1]" | |
| 83 | else | |
| 84 | "")) | |
| 85 | I (#goal o Proof.goal) | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 86 | (apply_named_method_on_first_goal (name ^ attrs) | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 87 | (Proof.theory_of st)) st | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 88 | 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: 
40132diff
changeset | 89 | 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: 
40132diff
changeset | 90 | NONE | 
| 38942 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 91 | |
| 42179 | 92 | val full_attrs = (SOME "simp", SOME "intro", SOME "elim", SOME "dest") | 
| 93 | val clas_attrs = (NONE, SOME "intro", SOME "elim", SOME "dest") | |
| 94 | val simp_attrs = (SOME "add", NONE, NONE, NONE) | |
| 95 | val metis_attrs = (SOME "", SOME "", SOME "", SOME "") | |
| 96 | val no_attrs = (NONE, NONE, NONE, NONE) | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 97 | |
| 43026 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 98 | (* name * ((all_goals, run_if_auto_try), (simp, intro, elim, dest) *) | 
| 39547 | 99 | val named_methods = | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 100 |   [("simp", ((false, true), simp_attrs)),
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 101 |    ("auto", ((true, true), full_attrs)),
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 102 |    ("fast", ((false, false), clas_attrs)),
 | 
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44651diff
changeset | 103 |    ("fastforce", ((false, false), full_attrs)),
 | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 104 |    ("force", ((false, false), full_attrs)),
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 105 |    ("blast", ((false, true), clas_attrs)),
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 106 |    ("metis", ((false, true), metis_attrs)),
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 107 |    ("linarith", ((false, true), no_attrs)),
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 108 |    ("presburger", ((false, true), no_attrs))]
 | 
| 39547 | 109 | 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 | 110 | |
| 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 111 | 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 | 112 | |
| 46641 | 113 | fun do_try0 mode timeout_opt quad st = | 
| 41038 | 114 | let | 
| 44651 
5d6a11e166cf
renamed "Metis_Tactics" to "Metis_Tactic", now that there is only one Metis tactic ("metisFT" is legacy)
 blanchet parents: 
43607diff
changeset | 115 | val st = st |> Proof.map_context (Config.put Metis_Tactic.verbose false #> | 
| 43607 
119767e1ccb4
linarith counterexamples now provide only valuations for variables (which should restrict the number of linarith trace messages);
 boehmes parents: 
43031diff
changeset | 116 | Config.put Lin_Arith.verbose false) | 
| 41038 | 117 | in | 
| 43026 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 118 | if mode = Normal then | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 119 | "Trying " ^ space_implode " " (Try.serial_commas "and" | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 120 | (map (quote o fst) named_methods)) ^ "..." | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 121 | |> Output.urgent_message | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 122 | else | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 123 | (); | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 124 | case do_methods |> Par_List.map (fn f => f mode timeout_opt quad st) | 
| 41038 | 125 | |> map_filter I |> sort (int_ord o pairself snd) of | 
| 43026 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 126 | [] => | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 127 | (if mode = Normal then Output.urgent_message "No proof found." else (); | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 128 | (false, (noneN, st))) | 
| 41038 | 129 | | xs as (s, _) :: _ => | 
| 130 | let | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 131 | val xs = xs |> map (fn (s, n) => (n, hd (space_explode " " s))) | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 132 | |> AList.coalesce (op =) | 
| 41038 | 133 | |> map (swap o apsnd commas) | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 134 | val need_parens = exists_string (curry (op =) " ") s | 
| 41038 | 135 | val message = | 
| 43026 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 136 | (case mode of | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 137 | Auto_Try => "Auto Try Methods found a proof" | 
| 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 138 | | Try => "Try Methods found a proof" | 
| 43031 | 139 | | Normal => "Try this") ^ ": " ^ | 
| 52697 
6fb98a20c349
explicit padding on command boundary for "auto" generated sendback -- do not replace the corresponding goal command, but append to it;
 wenzelm parents: 
52643diff
changeset | 140 | Active.sendback_markup (if mode = Auto_Try then [Markup.padding_command] else []) | 
| 41038 | 141 | ((if nprems_of (#goal (Proof.goal st)) = 1 then "by" | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 142 |                 else "apply") ^ " " ^ (s |> need_parens ? enclose "(" ")")) ^
 | 
| 52643 
34c29356930e
more explicit Markup.information for messages produced by "auto" tools;
 wenzelm parents: 
52641diff
changeset | 143 |           "\n(" ^ space_implode "; " (map time_string xs) ^ ")."
 | 
| 41038 | 144 | in | 
| 43026 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 blanchet parents: 
43024diff
changeset | 145 | (true, (s, st |> (if mode = Auto_Try then | 
| 43020 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 blanchet parents: 
43018diff
changeset | 146 | Proof.goal_message | 
| 52643 
34c29356930e
more explicit Markup.information for messages produced by "auto" tools;
 wenzelm parents: 
52641diff
changeset | 147 | (fn () => Pretty.markup Markup.information | 
| 
34c29356930e
more explicit Markup.information for messages produced by "auto" tools;
 wenzelm parents: 
52641diff
changeset | 148 | [Pretty.str message]) | 
| 43020 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 blanchet parents: 
43018diff
changeset | 149 | else | 
| 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 blanchet parents: 
43018diff
changeset | 150 | tap (fn _ => Output.urgent_message message)))) | 
| 41038 | 151 | end | 
| 152 | end | |
| 39331 | 153 | |
| 46641 | 154 | fun try0 timeout_opt = fst oo do_try0 Normal timeout_opt | 
| 38942 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 155 | |
| 46641 | 156 | fun try0_trans quad = | 
| 51557 
4e4b56b7a3a5
more robust access Toplevel.proof_of -- prefer warning via Toplevel.unknown_proof over hard crash (notably for skipped proofs);
 wenzelm parents: 
51383diff
changeset | 157 | Toplevel.unknown_proof o | 
| 46641 | 158 | Toplevel.keep (K () o do_try0 Normal (SOME default_timeout) quad | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 159 | o Toplevel.proof_of) | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 160 | |
| 42179 | 161 | fun merge_attrs (s1, i1, e1, d1) (s2, i2, e2, d2) = | 
| 162 | (s1 @ s2, i1 @ i2, e1 @ e2, d1 @ d2) | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 163 | |
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 164 | fun string_of_xthm (xref, args) = | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 165 | Facts.string_of_ref xref ^ | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 166 | implode (map (enclose "[" "]" o Pretty.str_of | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 167 |                 o Args.pretty_src @{context}) args)
 | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 168 | |
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 169 | val parse_fact_refs = | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 170 | Scan.repeat1 (Scan.unless (Parse.name -- Args.colon) | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 171 | (Parse_Spec.xthm >> string_of_xthm)) | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 172 | val parse_attr = | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 173 | Args.$$$ "simp" |-- Args.colon |-- parse_fact_refs | 
| 42179 | 174 | >> (fn ss => (ss, [], [], [])) | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 175 | || Args.$$$ "intro" |-- Args.colon |-- parse_fact_refs | 
| 42179 | 176 | >> (fn is => ([], is, [], [])) | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 177 | || Args.$$$ "elim" |-- Args.colon |-- parse_fact_refs | 
| 42179 | 178 | >> (fn es => ([], [], es, [])) | 
| 179 | || Args.$$$ "dest" |-- Args.colon |-- parse_fact_refs | |
| 180 | >> (fn ds => ([], [], [], ds)) | |
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 181 | fun parse_attrs x = | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 182 | (Args.parens parse_attrs | 
| 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 183 | || Scan.repeat parse_attr | 
| 42179 | 184 | >> (fn quad => fold merge_attrs quad ([], [], [], []))) x | 
| 41999 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 blanchet parents: 
41038diff
changeset | 185 | |
| 38942 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 186 | val _ = | 
| 46961 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46641diff
changeset | 187 |   Outer_Syntax.improper_command @{command_spec "try0"}
 | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46641diff
changeset | 188 | "try a combination of proof methods" | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46641diff
changeset | 189 | (Scan.optional parse_attrs ([], [], [], []) #>> try0_trans) | 
| 38942 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 190 | |
| 46641 | 191 | fun try_try0 auto = | 
| 192 | do_try0 (if auto then Auto_Try else Try) NONE ([], [], [], []) | |
| 39331 | 193 | |
| 52641 
c56b6fa636e8
hybrid "auto" tool setup, for TTY (within theory) and PIDE (global print function);
 wenzelm parents: 
52639diff
changeset | 194 | val _ = Try.tool_setup (try0N, (30, @{option auto_try0}, try_try0))
 | 
| 39331 | 195 | |
| 38942 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 blanchet parents: diff
changeset | 196 | end; |