walther@59971
|
1 |
(* Title: Test_Code/test-tool.sml
|
walther@59971
|
2 |
Author: Walther Neuper 110226
|
walther@59971
|
3 |
(c) due to copyright terms
|
walther@59971
|
4 |
*)
|
walther@59971
|
5 |
signature TEST_TOOL =
|
walther@59971
|
6 |
sig
|
walther@59971
|
7 |
val show_ptyps : unit -> unit
|
walther@59971
|
8 |
val show_mets : unit -> unit
|
walther@59971
|
9 |
|
walther@59971
|
10 |
val show_pblguhs : unit -> unit
|
walther@59971
|
11 |
val sort_pblguhs : unit -> unit
|
walther@59971
|
12 |
val show_metguhs : unit -> unit
|
walther@59971
|
13 |
val sort_metguhs : unit -> unit
|
walther@59971
|
14 |
|
walther@59983
|
15 |
val show_pt : Ctree.ctree -> unit
|
walther@59983
|
16 |
val show_pt_tac : Ctree.ctree -> unit
|
Walther@60596
|
17 |
val write_rules: Proof.context -> int -> Rule.rule list -> unit
|
Walther@60596
|
18 |
|
wenzelm@60223
|
19 |
\<^isac_test>\<open>
|
Walther@60595
|
20 |
val posterms2str: Proof.context -> (Pos.pos' * term * 'a) list -> string
|
Walther@60595
|
21 |
val postermtacs2str: Proof.context -> (Pos.pos' * term * Tactic.input option) list -> string
|
wenzelm@60223
|
22 |
\<close>
|
walther@59971
|
23 |
end
|
walther@59971
|
24 |
|
walther@59971
|
25 |
(**)
|
walther@59971
|
26 |
structure Test_Tool(**) : TEST_TOOL(**) =
|
walther@59971
|
27 |
struct
|
walther@59971
|
28 |
(**)
|
walther@59971
|
29 |
|
walther@59971
|
30 |
fun format_pblID strl = enclose " [" "]" (commas_quote strl);
|
walther@59971
|
31 |
fun format_pblIDl strll = enclose "[\n" "\n]\n" (space_implode ",\n" (map format_pblID strll));
|
walther@59971
|
32 |
|
Walther@60495
|
33 |
fun show_ptyps () = (writeln o format_pblIDl o (Store.scan [])) (get_pbls ()); (* for tests *)
|
Walther@60495
|
34 |
fun show_mets () = (writeln o format_pblIDl o (Store.scan [])) (get_pbls ()); (* for tests *)
|
walther@59971
|
35 |
|
walther@59971
|
36 |
fun show_pblguhs () =
|
walther@59971
|
37 |
(tracing o strs2str o (map linefeed))
|
Walther@60495
|
38 |
(Check_Unique.collect (#guh : Probl_Def.T -> Check_Unique.id) (get_pbls ()))
|
walther@59971
|
39 |
fun sort_pblguhs () =
|
walther@59971
|
40 |
(tracing o strs2str o (map linefeed))
|
walther@59971
|
41 |
(((sort string_ord) o (Check_Unique.collect (#guh : Probl_Def.T -> Check_Unique.id)))
|
Walther@60495
|
42 |
(get_pbls ()))
|
walther@59971
|
43 |
|
walther@59971
|
44 |
fun show_metguhs () =
|
walther@59971
|
45 |
(tracing o strs2str o (map linefeed))
|
walther@59971
|
46 |
(Check_Unique.collect (#guh : Meth_Def.T -> Check_Unique.id) (get_mets ()))
|
walther@59971
|
47 |
fun sort_metguhs () =
|
walther@59971
|
48 |
(tracing o strs2str o (map linefeed))
|
walther@59971
|
49 |
(((sort string_ord) o (Check_Unique.collect (#guh : Meth_Def.T -> Check_Unique.id)))
|
walther@59971
|
50 |
(get_mets ()))
|
walther@59971
|
51 |
|
walther@59983
|
52 |
|
walther@59983
|
53 |
(** show a whole Calc.T **)
|
walther@59983
|
54 |
|
Walther@60595
|
55 |
fun posterm2str ctxt (pos, t, _) = "(" ^ Pos.pos'2str pos ^ ", " ^ UnparseC.term_in_ctxt ctxt t ^ ")"
|
Walther@60595
|
56 |
fun posterms2str ctxt pfs = (strs2str' o (map (curry op ^ "\n")) o (map (posterm2str ctxt))) pfs
|
walther@59983
|
57 |
|
Walther@60595
|
58 |
fun postermtac2str ctxt (pos, t, SOME tac) =
|
Walther@60595
|
59 |
Pos.pos'2str pos ^ ", " ^ UnparseC.term_in_ctxt ctxt t ^ "\n" ^
|
Walther@60628
|
60 |
indent 10 ^ Tactic.input_to_string ctxt tac
|
Walther@60595
|
61 |
| postermtac2str ctxt (pos, t, NONE) =
|
Walther@60595
|
62 |
Pos.pos'2str pos ^ ", " ^ UnparseC.term_in_ctxt ctxt t
|
Walther@60595
|
63 |
fun postermtacs2str ctxt pfts =
|
Walther@60595
|
64 |
(strs2str' o (map (curry op ^ "\n")) o (map (postermtac2str ctxt))) pfts
|
walther@59983
|
65 |
|
Walther@60595
|
66 |
(* WN050225 shows a WRONG last step, if pt is incomplete *)
|
Walther@60576
|
67 |
fun show_pt pt =
|
Walther@60576
|
68 |
let
|
Walther@60576
|
69 |
val ctxt = Ctree.get_ctxt pt ([], Pos.Pbl) (*for coarse approximation*)
|
Walther@60576
|
70 |
in
|
Walther@60595
|
71 |
tracing (posterms2str ctxt (ME_Misc.get_interval ctxt ([], Pos.Frm) ([], Pos.Res) 99999 pt))
|
Walther@60576
|
72 |
end
|
Walther@60576
|
73 |
fun show_pt_tac pt =
|
Walther@60576
|
74 |
let
|
Walther@60576
|
75 |
val ctxt = Ctree.get_ctxt pt ([], Pos.Pbl) (*for coarse approximation*)
|
Walther@60576
|
76 |
in
|
Walther@60595
|
77 |
tracing (postermtacs2str ctxt (ME_Misc.get_interval ctxt ([], Pos.Frm) ([], Pos.Res) 99999 pt))
|
Walther@60576
|
78 |
end
|
walther@59983
|
79 |
|
Walther@60595
|
80 |
(** for finding a culprit in a (usually lengthy) list of Rule.T **)
|
Walther@60595
|
81 |
fun write_rules _ _ [] = writeln ""
|
Walther@60595
|
82 |
| write_rules ctxt i (r :: rs) =
|
Walther@60595
|
83 |
let val _ =
|
Walther@60595
|
84 |
case r of
|
Walther@60595
|
85 |
Rule.Thm (thmid, thm) =>
|
Walther@60648
|
86 |
writeln (string_of_int i ^ " Thm (" ^ thmid ^ ", " ^ ThmC.string_of_thm ctxt thm ^ ")")
|
Walther@60595
|
87 |
| Rule.Eval (op_, _) =>
|
Walther@60595
|
88 |
writeln (string_of_int i ^ " Eval (" ^ op_ ^ ", _)")
|
Walther@60595
|
89 |
| Rule.Cal1 (op_, _) =>
|
Walther@60595
|
90 |
writeln (string_of_int i ^ " Cal1 (" ^ op_ ^ ", _)")
|
Walther@60595
|
91 |
| Rule.Rls_ rls =>
|
Walther@60595
|
92 |
writeln (string_of_int i ^ " Rls_ {id = " ^ (Rule_Set.rep rls |> #id) ^ ", ...}")
|
Walther@60595
|
93 |
in
|
Walther@60595
|
94 |
write_rules ctxt (i + 1) rs
|
Walther@60595
|
95 |
end
|
Walther@60595
|
96 |
|
Walther@60595
|
97 |
(**)end(*sruct*)
|