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_______________________________________________________________ *)
33 let initial_counters = {
34 eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0;
35 tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0
38 let rec count_term_binder f c = function
40 let c = {c with tabsts = succ c.tabsts} in
43 let c = {c with tabbrs = succ c.tabbrs} in
47 and count_term f c = function
49 f {c with tsorts = succ c.tsorts}
51 f {c with tlrefs = succ c.tlrefs}
53 f {c with tgrefs = succ c.tgrefs}
55 let c = {c with tcasts = succ c.tcasts} in
56 let f c = count_term f c t in
59 let c = {c with tappls = succ c.tappls} in
60 let f c = count_term f c t in
62 | B.Bind (_, _, b, t) ->
63 let f c = count_term_binder f c b in
66 let count_entity f c = function
68 let c = {c with eabsts = succ c.eabsts} in
71 let c = {c with eabbrs = succ c.eabbrs} in
74 let print_counters f c =
76 c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
79 let items = c.eabsts + c.eabbrs in
80 let locations = B.locations () in
81 L.warn (P.sprintf " Kernel representation summary (basic_ag)");
82 L.warn (P.sprintf " Total entry items: %7u" items);
83 L.warn (P.sprintf " Declaration items: %7u" c.eabsts);
84 L.warn (P.sprintf " Definition items: %7u" c.eabbrs);
85 L.warn (P.sprintf " Total term items: %7u" terms);
86 L.warn (P.sprintf " Sort items: %7u" c.tsorts);
87 L.warn (P.sprintf " Local reference items: %7u" c.tlrefs);
88 L.warn (P.sprintf " Global reference items: %7u" c.tgrefs);
89 L.warn (P.sprintf " Explicit Cast items: %7u" c.tcasts);
90 L.warn (P.sprintf " Application items: %7u" c.tappls);
91 L.warn (P.sprintf " Abstraction items: %7u" c.tabsts);
92 L.warn (P.sprintf " Abbreviation items: %7u" c.tabbrs);
93 L.warn (P.sprintf " Total binder locations: %7u" locations);
97 if !O.indexes then P.sprintf "#%u" l else id
99 let rec pp_term c frm = function
101 let err () = F.fprintf frm "@[*%u@]" h in
102 let f s = F.fprintf frm "@[%s@]" s in
106 | Some (id, _) -> F.fprintf frm "@[%s@]" id
107 | None -> F.fprintf frm "@[#%u@]" i
109 if !O.indexes then f None else B.get f c i
110 | B.GRef s -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
112 F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t
114 F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t
115 | B.Bind (l, id, B.Abst w, t) ->
117 F.fprintf frm "@[[%s:%a].%a@]" (res l id) (pp_term c) w (pp_term cc) t
119 B.push "output abst" f c l id (B.Abst w)
120 | B.Bind (l, id, B.Abbr v, t) ->
122 F.fprintf frm "@[[%s=%a].%a@]" (res l id) (pp_term c) v (pp_term cc) t
124 B.push "output abbr" f c l id (B.Abbr v)
125 | B.Bind (l, id, B.Void, t) ->
126 let f cc = F.fprintf frm "@[[%s].%a@]" (res l id) (pp_term cc) t in
127 B.push "output void" f c l id B.Void
130 let pp_entry frm = function
132 F.fprintf frm "@,@[%s : %a@]" (res l id) (pp_term c) w
134 F.fprintf frm "@,@[%s = %a@]" (res l id) (pp_term c) v
136 F.fprintf frm "@,%s" (res l id)
138 let iter map frm l = List.iter (map frm) l in
139 let f es = F.fprintf frm "%a" (iter pp_entry) (List.rev es) in
143 L.pp_term = pp_term; L.pp_lenv = pp_lenv