4 Try a combination of proof methods. |
4 Try a combination of proof methods. |
5 *) |
5 *) |
6 |
6 |
7 signature TRY_METHODS = |
7 signature TRY_METHODS = |
8 sig |
8 sig |
|
9 val try_methodsN : string |
|
10 val noneN : string |
9 val auto : bool Unsynchronized.ref |
11 val auto : bool Unsynchronized.ref |
10 val try_methods : |
12 val try_methods : |
11 Time.time option -> string list * string list * string list * string list |
13 Time.time option -> string list * string list * string list * string list |
12 -> Proof.state -> bool |
14 -> Proof.state -> bool |
13 val setup : theory -> theory |
15 val setup : theory -> theory |
14 end; |
16 end; |
15 |
17 |
16 structure Try_Methods : TRY_METHODS = |
18 structure Try_Methods : TRY_METHODS = |
17 struct |
19 struct |
|
20 |
|
21 val try_methodsN = "try_methods" |
|
22 |
|
23 val noneN = "none" |
18 |
24 |
19 val auto = Unsynchronized.ref false |
25 val auto = Unsynchronized.ref false |
20 |
26 |
21 val _ = |
27 val _ = |
22 ProofGeneralPgip.add_preference Preferences.category_tracing |
28 ProofGeneralPgip.add_preference Preferences.category_tracing |
107 let |
113 let |
108 val st = st |> Proof.map_context (Config.put Metis_Tactics.verbose false) |
114 val st = st |> Proof.map_context (Config.put Metis_Tactics.verbose false) |
109 in |
115 in |
110 case do_methods |> Par_List.map (fn f => f auto timeout_opt quad st) |
116 case do_methods |> Par_List.map (fn f => f auto timeout_opt quad st) |
111 |> map_filter I |> sort (int_ord o pairself snd) of |
117 |> map_filter I |> sort (int_ord o pairself snd) of |
112 [] => (if auto then () else writeln "No proof found."; (false, st)) |
118 [] => (if auto then () else writeln "No proof found."; |
|
119 (false, (noneN, st))) |
113 | xs as (s, _) :: _ => |
120 | xs as (s, _) :: _ => |
114 let |
121 let |
115 val xs = xs |> map (fn (s, n) => (n, hd (space_explode " " s))) |
122 val xs = xs |> map (fn (s, n) => (n, hd (space_explode " " s))) |
116 |> AList.coalesce (op =) |
123 |> AList.coalesce (op =) |
117 |> map (swap o apsnd commas) |
124 |> map (swap o apsnd commas) |
122 Markup.markup Markup.sendback |
129 Markup.markup Markup.sendback |
123 ((if nprems_of (#goal (Proof.goal st)) = 1 then "by" |
130 ((if nprems_of (#goal (Proof.goal st)) = 1 then "by" |
124 else "apply") ^ " " ^ (s |> need_parens ? enclose "(" ")")) ^ |
131 else "apply") ^ " " ^ (s |> need_parens ? enclose "(" ")")) ^ |
125 "\n(" ^ space_implode "; " (map time_string xs) ^ ").\n" |
132 "\n(" ^ space_implode "; " (map time_string xs) ^ ").\n" |
126 in |
133 in |
127 (true, st |> (if auto then |
134 (true, (s, st |> (if auto then |
128 Proof.goal_message |
135 Proof.goal_message |
129 (fn () => Pretty.chunks [Pretty.str "", |
136 (fn () => Pretty.chunks [Pretty.str "", |
130 Pretty.markup Markup.hilite |
137 Pretty.markup Markup.hilite |
131 [Pretty.str message]]) |
138 [Pretty.str message]]) |
132 else |
139 else |
133 tap (fn _ => Output.urgent_message message))) |
140 tap (fn _ => Output.urgent_message message)))) |
134 end |
141 end |
135 end |
142 end |
136 |
143 |
137 fun try_methods timeout_opt = fst oo do_try_methods false timeout_opt |
144 fun try_methods timeout_opt = fst oo do_try_methods false timeout_opt |
138 |
|
139 val try_methodsN = "try_methods" |
|
140 |
145 |
141 fun try_methods_trans quad = |
146 fun try_methods_trans quad = |
142 Toplevel.keep (K () o do_try_methods false (SOME default_timeout) quad |
147 Toplevel.keep (K () o do_try_methods false (SOME default_timeout) quad |
143 o Toplevel.proof_of) |
148 o Toplevel.proof_of) |
144 |
149 |
173 val _ = |
178 val _ = |
174 Outer_Syntax.improper_command try_methodsN |
179 Outer_Syntax.improper_command try_methodsN |
175 "try a combination of proof methods" Keyword.diag |
180 "try a combination of proof methods" Keyword.diag |
176 parse_try_methods_command |
181 parse_try_methods_command |
177 |
182 |
178 val auto_try_methods = do_try_methods true NONE ([], [], [], []) |
183 fun try_try_methods auto = do_try_methods auto NONE ([], [], [], []) |
179 |
184 |
180 val setup = Try.register_tool (auto, auto_try_methods) |
185 val setup = Try.register_tool (try_methodsN, (auto, try_try_methods)) |
181 |
186 |
182 end; |
187 end; |