equal
deleted
inserted
replaced
44 else Symtab.update (d, (make_node d "", [])) tab)) entries0 entries0; |
44 else Symtab.update (d, (make_node d "", [])) tab)) entries0 entries0; |
45 in |
45 in |
46 Symtab.fold (fn (name, (node, deps)) => cons ((name, node), deps)) entries1 [] |
46 Symtab.fold (fn (name, (node, deps)) => cons ((name, node), deps)) entries1 [] |
47 |> Graph_Display.display_graph_old |
47 |> Graph_Display.display_graph_old |
48 end; |
48 end; |
49 |
|
50 val _ = |
|
51 Outer_Syntax.command @{command_keyword thm_deps} "visualize theorem dependencies" |
|
52 (Parse.xthms1 >> (fn args => |
|
53 Toplevel.keep (fn st => |
|
54 thm_deps (Toplevel.theory_of st) (Attrib.eval_thms (Toplevel.context_of st) args)))); |
|
55 |
49 |
56 |
50 |
57 (* unused_thms *) |
51 (* unused_thms *) |
58 |
52 |
59 fun unused_thms (base_thys, thys) = |
53 fun unused_thms (base_thys, thys) = |
105 Inttab.defined seen_groups grp then q |
99 Inttab.defined seen_groups grp then q |
106 else ((a, th) :: thms, Inttab.update (grp, ()) seen_groups)) |
100 else ((a, th) :: thms, Inttab.update (grp, ()) seen_groups)) |
107 else q) new_thms ([], Inttab.empty); |
101 else q) new_thms ([], Inttab.empty); |
108 in rev thms' end; |
102 in rev thms' end; |
109 |
103 |
110 val thy_names = |
|
111 Scan.repeat1 (Scan.unless Parse.minus (Parse.position Parse.theory_xname)); |
|
112 |
|
113 val _ = |
|
114 Outer_Syntax.command @{command_keyword unused_thms} "find unused theorems" |
|
115 (Scan.option ((thy_names --| Parse.minus) -- Scan.option thy_names) >> (fn opt_range => |
|
116 Toplevel.keep (fn st => |
|
117 let |
|
118 val thy = Toplevel.theory_of st; |
|
119 val ctxt = Toplevel.context_of st; |
|
120 fun pretty_thm (a, th) = Proof_Context.pretty_fact ctxt (a, [th]); |
|
121 val check = Theory.check ctxt; |
|
122 in |
|
123 unused_thms |
|
124 (case opt_range of |
|
125 NONE => (Theory.parents_of thy, [thy]) |
|
126 | SOME (xs, NONE) => (map check xs, [thy]) |
|
127 | SOME (xs, SOME ys) => (map check xs, map check ys)) |
|
128 |> map pretty_thm |> Pretty.writeln_chunks |
|
129 end))); |
|
130 |
|
131 end; |
104 end; |