1 (* Title: Pure/Isar/proof_display.ML |
1 (* Title: Pure/Isar/proof_display.ML |
2 ID: $Id$ |
2 ID: $Id$ |
3 Author: Makarius |
3 Author: Makarius |
4 |
4 |
5 Printing of Isar proof configurations etc. |
5 Printing of theorems, goals, results etc. |
6 *) |
6 *) |
|
7 |
|
8 signature BASIC_PROOF_DISPLAY = |
|
9 sig |
|
10 val print_theorems: theory -> unit |
|
11 val print_theory: theory -> unit |
|
12 end |
7 |
13 |
8 signature PROOF_DISPLAY = |
14 signature PROOF_DISPLAY = |
9 sig |
15 sig |
|
16 include BASIC_PROOF_DISPLAY |
|
17 val print_theorems_diff: theory -> theory -> unit |
10 val string_of_rule: ProofContext.context -> string -> thm -> string |
18 val string_of_rule: ProofContext.context -> string -> thm -> string |
11 val print_results: bool -> ProofContext.context -> |
19 val print_results: bool -> ProofContext.context -> |
12 ((string * string) * (string * thm list) list) -> unit |
20 ((string * string) * (string * thm list) list) -> unit |
13 val present_results: ProofContext.context -> |
21 val present_results: ProofContext.context -> |
14 ((string * string) * (string * thm list) list) -> unit |
22 ((string * string) * (string * thm list) list) -> unit |
15 end |
23 end |
16 |
24 |
17 structure ProofDisplay: PROOF_DISPLAY = |
25 structure ProofDisplay: PROOF_DISPLAY = |
18 struct |
26 struct |
|
27 |
|
28 |
|
29 (* theorems and theory *) |
|
30 |
|
31 fun pretty_theorems_diff prev_thms thy = |
|
32 let |
|
33 val ctxt = ProofContext.init thy; |
|
34 val (space, thms) = PureThy.theorems_of thy; |
|
35 val diff_thmss = Symtab.fold (fn fact => |
|
36 if not (Symtab.member Thm.eq_thms prev_thms fact) then cons fact else I) thms []; |
|
37 val thmss = diff_thmss |> map (apfst (NameSpace.extern space)) |> Library.sort_wrt #1; |
|
38 in Pretty.big_list "theorems:" (map (ProofContext.pretty_fact ctxt) thmss) end; |
|
39 |
|
40 fun print_theorems_diff prev_thy thy = |
|
41 Pretty.writeln (pretty_theorems_diff (#2 (PureThy.theorems_of prev_thy)) thy); |
|
42 |
|
43 fun pretty_theorems thy = pretty_theorems_diff Symtab.empty thy; |
|
44 |
|
45 val print_theorems = Pretty.writeln o pretty_theorems; |
|
46 |
|
47 fun print_theory thy = |
|
48 Pretty.writeln (Pretty.chunks (Display.pretty_full_theory thy @ [pretty_theorems thy])); |
|
49 |
19 |
50 |
20 (* refinement rule *) |
51 (* refinement rule *) |
21 |
52 |
22 fun pretty_rule ctxt s thm = |
53 fun pretty_rule ctxt s thm = |
23 Pretty.block [Pretty.str (s ^ " attempt to solve goal by exported rule:"), |
54 Pretty.block [Pretty.str (s ^ " attempt to solve goal by exported rule:"), |