| author | wenzelm | 
| Mon, 10 Mar 2014 18:06:23 +0100 | |
| changeset 56032 | b034b9f0fa2a | 
| parent 56027 | 25889f5c39a8 | 
| child 56467 | 8d7d6f17c6a7 | 
| 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: 
43018 
diff
changeset
 | 
10  | 
val noneN : string  | 
| 55177 | 11  | 
|
12  | 
val silence_methods : bool -> Proof.context -> Proof.context  | 
|
| 55179 | 13  | 
val try0 : Time.time option -> string list * string list * string list * string list ->  | 
14  | 
Proof.state -> bool  | 
|
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
15  | 
end;  | 
| 
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
16  | 
|
| 46641 | 17  | 
structure Try0 : TRY0 =  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
18  | 
struct  | 
| 
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
19  | 
|
| 55179 | 20  | 
val try0N = "try0";  | 
21  | 
val noneN = "none";  | 
|
| 
43026
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
22  | 
|
| 55179 | 23  | 
datatype mode = Auto_Try | Try | Normal;  | 
| 
43020
 
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
 
blanchet 
parents: 
43018 
diff
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: 
52007 
diff
changeset
 | 
27  | 
NONE  | 
| 
52717
 
da7bf8b3d24a
clarified option name, with improved sort order wrt. "time" options;
 
wenzelm 
parents: 
52697 
diff
changeset
 | 
28  | 
    @{option auto_methods}
 | 
| 
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: 
52007 
diff
changeset
 | 
29  | 
"auto-try0"  | 
| 55179 | 30  | 
"Try standard proof methods";  | 
| 39333 | 31  | 
|
| 55179 | 32  | 
val default_timeout = seconds 5.0;  | 
| 38944 | 33  | 
|
| 
39336
 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 
blanchet 
parents: 
39334 
diff
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
 | 
| 
55182
 
dd1e95e67b30
more robust w.r.t. exceptions raised by proof methods
 
blanchet 
parents: 
55181 
diff
changeset
 | 
36  | 
(case (case timeout_opt of  | 
| 
39336
 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 
blanchet 
parents: 
39334 
diff
changeset
 | 
37  | 
SOME timeout => TimeLimit.timeLimit timeout  | 
| 
 
1899349a5026
change signature of "Try.invoke_try" to make it more flexible
 
blanchet 
parents: 
39334 
diff
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  | 
| 
55182
 
dd1e95e67b30
more robust w.r.t. exceptions raised by proof methods
 
blanchet 
parents: 
55181 
diff
changeset
 | 
40  | 
| NONE => false)  | 
| 
 
dd1e95e67b30
more robust w.r.t. exceptions raised by proof methods
 
blanchet 
parents: 
55181 
diff
changeset
 | 
41  | 
end;  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
42  | 
|
| 55181 | 43  | 
fun apply_generic timeout_opt name command pre post apply st =  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
44  | 
let val timer = Timer.startRealTimer () in  | 
| 
55182
 
dd1e95e67b30
more robust w.r.t. exceptions raised by proof methods
 
blanchet 
parents: 
55181 
diff
changeset
 | 
45  | 
if try (can_apply timeout_opt pre post apply) st = SOME true then  | 
| 54291 | 46  | 
SOME (name, command, Time.toMilliseconds (Timer.checkRealTimer timer))  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
47  | 
else  | 
| 
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
48  | 
NONE  | 
| 55179 | 49  | 
end;  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
50  | 
|
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
51  | 
val parse_method =  | 
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
52  | 
  enclose "(" ")"
 | 
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
53  | 
#> Outer_Syntax.scan Position.start  | 
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
54  | 
#> filter Token.is_proper  | 
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
55  | 
#> Scan.read Token.stopper Method.parse  | 
| 55179 | 56  | 
#> (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
 | 
57  | 
|
| 
55742
 
a989bdaf8121
modernized Method.check_name/check_source (with reports) vs. strict Method.the_method (without interning nor reports), e.g. relevant for semantic completion;
 
wenzelm 
parents: 
55182 
diff
changeset
 | 
58  | 
fun apply_named_method_on_first_goal ctxt =  | 
| 
55182
 
dd1e95e67b30
more robust w.r.t. exceptions raised by proof methods
 
blanchet 
parents: 
55181 
diff
changeset
 | 
59  | 
parse_method  | 
| 
55997
 
9dc5ce83202c
modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
 
wenzelm 
parents: 
55765 
diff
changeset
 | 
60  | 
#> Method.method_cmd ctxt  | 
| 
55182
 
dd1e95e67b30
more robust w.r.t. exceptions raised by proof methods
 
blanchet 
parents: 
55181 
diff
changeset
 | 
61  | 
#> Method.Basic  | 
| 55765 | 62  | 
#> (fn m => Method.Select_Goals (Method.no_combinator_info, 1, m))  | 
| 
55182
 
dd1e95e67b30
more robust w.r.t. exceptions raised by proof methods
 
blanchet 
parents: 
55181 
diff
changeset
 | 
63  | 
#> Proof.refine;  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
64  | 
|
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
65  | 
fun add_attr_text (NONE, _) s = s  | 
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
66  | 
| add_attr_text (_, []) s = s  | 
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
67  | 
| add_attr_text (SOME x, fs) s =  | 
| 55179 | 68  | 
s ^ " " ^ (if x = "" then "" else x ^ ": ") ^ space_implode " " fs;  | 
69  | 
||
| 42179 | 70  | 
fun attrs_text (sx, ix, ex, dx) (ss, is, es, ds) =  | 
| 55179 | 71  | 
"" |> 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
 | 
72  | 
|
| 55181 | 73  | 
fun apply_named_method (name, ((all_goals, run_if_auto_try), attrs)) mode timeout_opt quad st =  | 
| 
43026
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
74  | 
if mode <> Auto_Try orelse run_if_auto_try then  | 
| 42179 | 75  | 
let val attrs = attrs_text attrs quad in  | 
| 55181 | 76  | 
apply_generic timeout_opt name  | 
| 54291 | 77  | 
        ((name ^ attrs |> attrs <> "" ? enclose "(" ")") ^
 | 
78  | 
(if all_goals andalso nprems_of (#goal (Proof.goal st)) > 1 then "[1]" else ""))  | 
|
79  | 
I (#goal o Proof.goal)  | 
|
| 
55742
 
a989bdaf8121
modernized Method.check_name/check_source (with reports) vs. strict Method.the_method (without interning nor reports), e.g. relevant for semantic completion;
 
wenzelm 
parents: 
55182 
diff
changeset
 | 
80  | 
(apply_named_method_on_first_goal (Proof.context_of st) (name ^ attrs)) st  | 
| 
41999
 
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  | 
| 55179 | 83  | 
NONE;  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
84  | 
|
| 55179 | 85  | 
val full_attrs = (SOME "simp", SOME "intro", SOME "elim", SOME "dest");  | 
86  | 
val clas_attrs = (NONE, SOME "intro", SOME "elim", SOME "dest");  | 
|
87  | 
val simp_attrs = (SOME "add", NONE, NONE, NONE);  | 
|
88  | 
val metis_attrs = (SOME "", SOME "", SOME "", SOME "");  | 
|
89  | 
val no_attrs = (NONE, NONE, NONE, NONE);  | 
|
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
90  | 
|
| 
43026
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
91  | 
(* name * ((all_goals, run_if_auto_try), (simp, intro, elim, dest) *)  | 
| 39547 | 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)),
 | 
| 55178 | 95  | 
   ("blast", ((false, true), clas_attrs)),
 | 
96  | 
   ("metis", ((false, true), metis_attrs)),
 | 
|
97  | 
   ("linarith", ((false, true), no_attrs)),
 | 
|
98  | 
   ("presburger", ((false, true), no_attrs)),
 | 
|
99  | 
   ("algebra", ((false, true), no_attrs)),
 | 
|
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
100  | 
   ("fast", ((false, false), clas_attrs)),
 | 
| 
44890
 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 
nipkow 
parents: 
44651 
diff
changeset
 | 
101  | 
   ("fastforce", ((false, false), full_attrs)),
 | 
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
102  | 
   ("force", ((false, false), full_attrs)),
 | 
| 55178 | 103  | 
   ("meson", ((false, false), metis_attrs))]
 | 
| 55179 | 104  | 
|
| 55181 | 105  | 
val apply_methods = map apply_named_method named_methods;  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
106  | 
|
| 55179 | 107  | 
fun time_string ms = string_of_int ms ^ " ms";  | 
108  | 
fun tool_time_string (s, ms) = s ^ ": " ^ time_string ms;  | 
|
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
109  | 
|
| 55177 | 110  | 
(* Makes reconstructor tools as silent as possible. The "set_visible" calls suppresses "Unification  | 
111  | 
bound exceeded" warnings and the like. *)  | 
|
112  | 
fun silence_methods debug =  | 
|
113  | 
Config.put Metis_Tactic.verbose debug  | 
|
114  | 
#> Config.put Lin_Arith.verbose debug  | 
|
115  | 
#> (not debug ?  | 
|
116  | 
(Context_Position.set_visible false  | 
|
117  | 
#> Proof_Context.background_theory (fn thy =>  | 
|
118  | 
thy  | 
|
119  | 
|> Context_Position.set_visible_global false  | 
|
| 55179 | 120  | 
|> Config.put_global Unify.trace_bound (Config.get_global thy Unify.search_bound))));  | 
| 55177 | 121  | 
|
| 55181 | 122  | 
fun generic_try0 mode timeout_opt quad st =  | 
| 41038 | 123  | 
let  | 
| 55179 | 124  | 
val st = st |> Proof.map_context (silence_methods false);  | 
125  | 
fun trd (_, _, t) = t;  | 
|
| 
54248
 
c7af3d651658
make 'try0' return faster when invoked as part of 'try'
 
blanchet 
parents: 
53052 
diff
changeset
 | 
126  | 
fun par_map f =  | 
| 54431 | 127  | 
if mode = Normal then Par_List.map f #> map_filter I #> sort (int_ord o pairself trd)  | 
| 55179 | 128  | 
else Par_List.get_some f #> the_list;  | 
| 41038 | 129  | 
in  | 
| 
43026
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
130  | 
if mode = Normal then  | 
| 55179 | 131  | 
"Trying " ^ space_implode " " (Try.serial_commas "and" (map (quote o fst) named_methods)) ^  | 
132  | 
"..."  | 
|
| 
43026
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
133  | 
|> Output.urgent_message  | 
| 
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
134  | 
else  | 
| 
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
135  | 
();  | 
| 55181 | 136  | 
(case par_map (fn f => f mode timeout_opt quad st) apply_methods of  | 
| 
43026
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
137  | 
[] =>  | 
| 55179 | 138  | 
(if mode = Normal then Output.urgent_message "No proof found." else (); (false, (noneN, st)))  | 
| 54291 | 139  | 
| xs as (name, command, _) :: _ =>  | 
| 41038 | 140  | 
let  | 
| 54291 | 141  | 
val xs = xs |> map (fn (name, _, n) => (n, name))  | 
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
142  | 
|> AList.coalesce (op =)  | 
| 41038 | 143  | 
|> map (swap o apsnd commas)  | 
144  | 
val message =  | 
|
| 
43026
 
0f15575a6465
handle non-auto try cases gracefully in Try Methods
 
blanchet 
parents: 
43024 
diff
changeset
 | 
145  | 
(case mode of  | 
| 52970 | 146  | 
Auto_Try => "Auto Try0 found a proof"  | 
147  | 
| Try => "Try0 found a proof"  | 
|
| 43031 | 148  | 
| Normal => "Try this") ^ ": " ^  | 
| 
53052
 
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
 
wenzelm 
parents: 
52970 
diff
changeset
 | 
149  | 
Active.sendback_markup [Markup.padding_command]  | 
| 41038 | 150  | 
((if nprems_of (#goal (Proof.goal st)) = 1 then "by"  | 
| 54291 | 151  | 
else "apply") ^ " " ^ command) ^  | 
| 
54248
 
c7af3d651658
make 'try0' return faster when invoked as part of 'try'
 
blanchet 
parents: 
53052 
diff
changeset
 | 
152  | 
(case xs of  | 
| 
 
c7af3d651658
make 'try0' return faster when invoked as part of 'try'
 
blanchet 
parents: 
53052 
diff
changeset
 | 
153  | 
            [(_, ms)] => " (" ^ time_string ms ^ ")."
 | 
| 
 
c7af3d651658
make 'try0' return faster when invoked as part of 'try'
 
blanchet 
parents: 
53052 
diff
changeset
 | 
154  | 
          | xs => "\n(" ^ space_implode "; " (map tool_time_string xs) ^ ").")
 | 
| 41038 | 155  | 
in  | 
| 54291 | 156  | 
(true, (name,  | 
| 55179 | 157  | 
st  | 
158  | 
|> (if mode = Auto_Try then  | 
|
159  | 
Proof.goal_message (fn () => Pretty.markup Markup.information [Pretty.str message])  | 
|
160  | 
else  | 
|
161  | 
tap (fn _ => Output.urgent_message message))))  | 
|
| 54291 | 162  | 
end)  | 
| 55179 | 163  | 
end;  | 
| 39331 | 164  | 
|
| 55181 | 165  | 
fun try0 timeout_opt = fst oo generic_try0 Normal timeout_opt;  | 
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
166  | 
|
| 46641 | 167  | 
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: 
51383 
diff
changeset
 | 
168  | 
Toplevel.unknown_proof o  | 
| 55181 | 169  | 
Toplevel.keep (K () o generic_try0 Normal (SOME default_timeout) quad o Toplevel.proof_of);  | 
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
170  | 
|
| 55179 | 171  | 
fun merge_attrs (s1, i1, e1, d1) (s2, i2, e2, d2) = (s1 @ s2, i1 @ i2, e1 @ e2, d1 @ d2);  | 
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
172  | 
|
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
173  | 
fun string_of_xthm (xref, args) =  | 
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
174  | 
Facts.string_of_ref xref ^  | 
| 
56032
 
b034b9f0fa2a
clarified Args.check_src: retain name space information for error output;
 
wenzelm 
parents: 
56027 
diff
changeset
 | 
175  | 
  implode (map (enclose "[" "]" o Pretty.str_of o Args.pretty_src @{context}) args);
 | 
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
176  | 
|
| 
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
177  | 
val parse_fact_refs =  | 
| 55179 | 178  | 
Scan.repeat1 (Scan.unless (Parse.name -- Args.colon) (Parse_Spec.xthm >> string_of_xthm));  | 
179  | 
||
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
180  | 
val parse_attr =  | 
| 55179 | 181  | 
Args.$$$ "simp" |-- Args.colon |-- parse_fact_refs >> (fn ss => (ss, [], [], []))  | 
182  | 
|| Args.$$$ "intro" |-- Args.colon |-- parse_fact_refs >> (fn is => ([], is, [], []))  | 
|
183  | 
|| Args.$$$ "elim" |-- Args.colon |-- parse_fact_refs >> (fn es => ([], [], es, []))  | 
|
184  | 
|| Args.$$$ "dest" |-- Args.colon |-- parse_fact_refs >> (fn ds => ([], [], [], ds));  | 
|
185  | 
||
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
186  | 
fun parse_attrs x =  | 
| 55179 | 187  | 
(Args.parens parse_attrs  | 
188  | 
|| Scan.repeat parse_attr >> (fn quad => fold merge_attrs quad ([], [], [], []))) x;  | 
|
| 
41999
 
3c029ef9e0f2
added "simp:", "intro:", and "elim:" to "try" command
 
blanchet 
parents: 
41038 
diff
changeset
 | 
189  | 
|
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
190  | 
val _ =  | 
| 55179 | 191  | 
  Outer_Syntax.improper_command @{command_spec "try0"} "try a combination of proof methods"
 | 
192  | 
(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
 | 
193  | 
|
| 55181 | 194  | 
fun try_try0 auto = generic_try0 (if auto then Auto_Try else Try) NONE ([], [], [], []);  | 
| 39331 | 195  | 
|
| 55179 | 196  | 
val _ = Try.tool_setup (try0N, (30, @{option auto_methods}, try_try0));
 | 
| 39331 | 197  | 
|
| 
38942
 
e10c11971fa7
"try" -- a new diagnosis tool that tries to apply several methods in parallel
 
blanchet 
parents:  
diff
changeset
 | 
198  | 
end;  |