12 signature GOALS = |
12 signature GOALS = |
13 sig |
13 sig |
14 val premises: unit -> thm list |
14 val premises: unit -> thm list |
15 val prove_goal: theory -> string -> (thm list -> tactic list) -> thm |
15 val prove_goal: theory -> string -> (thm list -> tactic list) -> thm |
16 val prove_goalw: theory -> thm list -> string -> (thm list -> tactic list) -> thm |
16 val prove_goalw: theory -> thm list -> string -> (thm list -> tactic list) -> thm |
17 val disable_pr: unit -> unit |
|
18 val enable_pr: unit -> unit |
|
19 val topthm: unit -> thm |
17 val topthm: unit -> thm |
20 val result: unit -> thm |
18 val result: unit -> thm |
21 val uresult: unit -> thm |
19 val uresult: unit -> thm |
22 val getgoal: int -> term |
20 val getgoal: int -> term |
23 val gethyps: int -> thm list |
21 val gethyps: int -> thm list |
269 (*Pops the given goal stack*) |
267 (*Pops the given goal stack*) |
270 fun pop [] = error"Cannot go back past the beginning of the proof!" |
268 fun pop [] = error"Cannot go back past the beginning of the proof!" |
271 | pop (pair::pairs) = (pair,pairs); |
269 | pop (pair::pairs) = (pair,pairs); |
272 |
270 |
273 |
271 |
274 (* Print a level of the goal stack -- subject to quiet mode *) |
272 (* Print a level of the goal stack *) |
275 |
|
276 val quiet = ref false; |
|
277 fun disable_pr () = quiet := true; |
|
278 fun enable_pr () = quiet := false; |
|
279 |
273 |
280 fun print_top ((th, _), pairs) = |
274 fun print_top ((th, _), pairs) = |
281 if ! quiet then () |
275 let |
282 else ! Display.print_current_goals_fn (length pairs) (! goals_limit) th; |
276 val n = length pairs; |
|
277 val m = (! goals_limit); |
|
278 val ngoals = nprems_of th; |
|
279 in |
|
280 [Pretty.str ("Level " ^ string_of_int n ^ |
|
281 (if ngoals > 0 then " (" ^ string_of_int ngoals ^ " subgoal" ^ |
|
282 (if ngoals <> 1 then "s" else "") ^ ")" |
|
283 else ""))] @ |
|
284 Display.pretty_goals m th |
|
285 end |> Pretty.chunks |> Pretty.writeln; |
283 |
286 |
284 (*Printing can raise exceptions, so the assignment occurs last. |
287 (*Printing can raise exceptions, so the assignment occurs last. |
285 Can do setstate[(st,Seq.empty)] to set st as the state. *) |
288 Can do setstate[(st,Seq.empty)] to set st as the state. *) |
286 fun setstate newgoals = |
289 fun setstate newgoals = |
287 (print_top (pop newgoals); undo_list := newgoals :: !undo_list); |
290 (print_top (pop newgoals); undo_list := newgoals :: !undo_list); |
332 else error ("Level number must lie between 0 and " ^ |
335 else error ("Level number must lie between 0 and " ^ |
333 string_of_int level) |
336 string_of_int level) |
334 end; |
337 end; |
335 |
338 |
336 (*Print the given level of the proof; prlev ~1 prints previous level*) |
339 (*Print the given level of the proof; prlev ~1 prints previous level*) |
337 fun prlev n = (enable_pr (); apply_fun (print_top o pop o (chop_level n))); |
340 fun prlev n = apply_fun (print_top o pop o (chop_level n)); |
338 fun pr () = (enable_pr (); apply_fun print_top); |
341 fun pr () = apply_fun print_top; |
339 |
342 |
340 (*Set goals_limit and print again*) |
343 (*Set goals_limit and print again*) |
341 fun prlim n = (goals_limit:=n; pr()); |
344 fun prlim n = (goals_limit:=n; pr()); |
342 |
345 |
343 (** the goal.... commands |
346 (** the goal.... commands |