2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
32 let initial_counters = {
33 eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0;
34 tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0
37 let rec count_term_binder f c = function
39 let c = {c with tabsts = succ c.tabsts} in
42 let c = {c with tabbrs = succ c.tabbrs} in
46 and count_term f c = function
48 f {c with tsorts = succ c.tsorts}
50 f {c with tlrefs = succ c.tlrefs}
52 f {c with tgrefs = succ c.tgrefs}
54 let c = {c with tcasts = succ c.tcasts} in
55 let f c = count_term f c t in
58 let c = {c with tappls = succ c.tappls} in
59 let f c = count_term f c t in
62 let f c = count_term_binder f c b in
65 let count_obj_binder f c = function
67 let c = {c with eabsts = succ c.eabsts} in
70 let c = {c with eabbrs = succ c.eabbrs} in
74 let count_obj f c (_, _, b) =
75 count_obj_binder f c b
77 let count_item f c = function
78 | Some obj -> count_obj f c obj
81 let print_counters f c =
83 c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
86 let items = c.eabsts + c.eabbrs in
87 L.warn (P.sprintf " Kernel representation summary (basic_rg)");
88 L.warn (P.sprintf " Total entry items: %6u" items);
89 L.warn (P.sprintf " Declaration items: %6u" c.eabsts);
90 L.warn (P.sprintf " Definition items: %6u" c.eabbrs);
91 L.warn (P.sprintf " Total term items: %6u" terms);
92 L.warn (P.sprintf " Sort items: %6u" c.tsorts);
93 L.warn (P.sprintf " Local reference items: %6u" c.tlrefs);
94 L.warn (P.sprintf " Global reference items: %6u" c.tgrefs);
95 L.warn (P.sprintf " Explicit Cast items: %6u" c.tcasts);
96 L.warn (P.sprintf " Application items: %6u" c.tappls);
97 L.warn (P.sprintf " Abstraction items: %6u" c.tabsts);
98 L.warn (P.sprintf " Abbreviation items: %6u" c.tabbrs);
101 let rec pp_term c frm = function
104 | Some s -> F.fprintf frm "@[%s@]" s
105 | None -> F.fprintf frm "@[*%u@]" h
110 | Some (id, _) -> F.fprintf frm "@[%s@]" id
111 | None -> F.fprintf frm "@[#%u@]" i
114 | B.GRef s -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
116 F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t
118 F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t
119 | B.Bind (id, B.Abst w, t) ->
121 F.fprintf frm "@[[%s:%a].%a@]" id (pp_term c) w (pp_term cc) t
123 B.push f c id (B.Abst w)
124 | B.Bind (id, B.Abbr v, t) ->
126 F.fprintf frm "@[[%s=%a].%a@]" id (pp_term c) v (pp_term cc) t
128 B.push f c id (B.Abbr v)
129 | B.Bind (id, B.Void, t) ->
130 let f cc = F.fprintf frm "@[[%s].%a@]" id (pp_term cc) t in
133 let pp_context frm c =
134 let pp_entry f = function
136 F.fprintf frm "%s : %a\n%!" id (pp_term c) w; f ()
138 F.fprintf frm "%s = %a\n%!" id (pp_term c) v; f ()
140 F.fprintf frm "%s\n%!" id; f ()
142 let f _ es = C.list_iter C.start pp_entry (List.rev es) in
145 let pp_term frm c t =
146 F.fprintf frm "%a\n%!" (pp_term c) t
149 L.pp_term = pp_term; L.pp_context = pp_context