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
61 | B.Bind (_, _, b, t) ->
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 let locations = B.locations () in
88 L.warn (P.sprintf " Kernel representation summary (basic_ag)");
89 L.warn (P.sprintf " Total entry items: %6u" items);
90 L.warn (P.sprintf " Declaration items: %6u" c.eabsts);
91 L.warn (P.sprintf " Definition items: %6u" c.eabbrs);
92 L.warn (P.sprintf " Total term items: %6u" terms);
93 L.warn (P.sprintf " Sort items: %6u" c.tsorts);
94 L.warn (P.sprintf " Local reference items: %6u" c.tlrefs);
95 L.warn (P.sprintf " Global reference items: %6u" c.tgrefs);
96 L.warn (P.sprintf " Explicit Cast items: %6u" c.tcasts);
97 L.warn (P.sprintf " Application items: %6u" c.tappls);
98 L.warn (P.sprintf " Abstraction items: %6u" c.tabsts);
99 L.warn (P.sprintf " Abbreviation items: %6u" c.tabbrs);
100 L.warn (P.sprintf " Total binder locations: %6u" locations);
103 let indexes = ref false
106 if !indexes then P.sprintf "#%u" l else id
108 let rec pp_term c frm = function
111 | Some s -> F.fprintf frm "@[%s@]" s
112 | None -> F.fprintf frm "@[*%u@]" h
117 | Some (id, _) -> F.fprintf frm "@[%s@]" id
118 | None -> F.fprintf frm "@[#%u@]" i
120 if !indexes then f None else B.get f c i
121 | B.GRef s -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
123 F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t
125 F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t
126 | B.Bind (l, id, B.Abst w, t) ->
128 F.fprintf frm "@[[%s:%a].%a@]" (res l id) (pp_term c) w (pp_term cc) t
130 B.push f c l id (B.Abst w)
131 | B.Bind (l, id, B.Abbr v, t) ->
133 F.fprintf frm "@[[%s=%a].%a@]" (res l id) (pp_term c) v (pp_term cc) t
135 B.push f c l id (B.Abbr v)
136 | B.Bind (l, id, B.Void, t) ->
137 let f cc = F.fprintf frm "@[[%s].%a@]" (res l id) (pp_term cc) t in
138 B.push f c l id B.Void
140 let pp_context frm c =
141 let pp_entry frm = function
143 F.fprintf frm "@,@[%s : %a@]" (res l id) (pp_term c) w
145 F.fprintf frm "@,@[%s = %a@]" (res l id) (pp_term c) v
147 F.fprintf frm "@,%s" (res l id)
149 let iter map frm l = List.iter (map frm) l in
150 let f es = F.fprintf frm "%a" (iter pp_entry) (List.rev es) in
154 L.pp_term = pp_term; L.pp_context = pp_context