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_______________________________________________________________ *)
31 let initial_counters = {
32 eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0;
33 tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0
36 let rec count_term_binder f c = function
38 let c = {c with tabsts = succ c.tabsts} in
41 let c = {c with tabbrs = succ c.tabbrs} in
45 and count_term f c = function
47 f {c with tsorts = succ c.tsorts}
49 f {c with tlrefs = succ c.tlrefs}
51 f {c with tgrefs = succ c.tgrefs}
53 let c = {c with tcasts = succ c.tcasts} in
54 let f c = count_term f c t in
57 let c = {c with tappls = succ c.tappls} in
58 let f c = count_term f c t in
61 let f c = count_term_binder f c b in
64 let count_obj_binder f c = function
66 let c = {c with eabsts = succ c.eabsts} in
69 let c = {c with eabbrs = succ c.eabbrs} in
73 let count_obj f c (_, _, b) =
74 count_obj_binder f c b
76 let count_item f c = function
77 | Some obj -> count_obj f c obj
80 let print_counters f c =
82 c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
85 let items = c.eabsts + c.eabbrs in
86 L.warn (P.sprintf " Kernel representation summary (basic_rg)");
87 L.warn (P.sprintf " Total entry items: %6u" items);
88 L.warn (P.sprintf " Declaration items: %6u" c.eabsts);
89 L.warn (P.sprintf " Definition items: %6u" c.eabbrs);
90 L.warn (P.sprintf " Total term items: %6u" terms);
91 L.warn (P.sprintf " Sort items: %6u" c.tsorts);
92 L.warn (P.sprintf " Local reference items: %6u" c.tlrefs);
93 L.warn (P.sprintf " Global reference items: %6u" c.tgrefs);
94 L.warn (P.sprintf " Explicit Cast items: %6u" c.tcasts);
95 L.warn (P.sprintf " Application items: %6u" c.tappls);
96 L.warn (P.sprintf " Abstraction items: %6u" c.tabsts);
97 L.warn (P.sprintf " Abbreviation items: %6u" c.tabbrs);
100 let rec pp_term c frm = function
101 | B.Sort h -> F.fprintf frm "@[*%u@]" h
104 | Some (id, _) -> F.fprintf frm "@[%s@]" id
105 | None -> F.fprintf frm "@[#%u@]" i
108 | B.GRef s -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
110 F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t
112 F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t
113 | B.Bind (id, B.Abst w, t) ->
115 F.fprintf frm "@[[%s:%a].%a@]" id (pp_term c) w (pp_term cc) t
117 B.push f c id (B.Abst w)
118 | B.Bind (id, B.Abbr v, t) ->
120 F.fprintf frm "@[[%s=%a].%a@]" id (pp_term c) v (pp_term cc) t
122 B.push f c id (B.Abbr v)
123 | B.Bind (id, B.Void, t) ->
124 let f cc = F.fprintf frm "@[[%s].%a@]" id (pp_term cc) t in
127 let pp_context frm c =
128 let pp_entry f = function
130 F.fprintf frm "%s : %a\n%!" id (pp_term c) w; f ()
132 F.fprintf frm "%s = %a\n%!" id (pp_term c) v; f ()
134 F.fprintf frm "%s\n%!" id; f ()
136 let f _ es = C.list_iter C.start pp_entry (List.rev es) in
139 let pp_term frm c t =
140 F.fprintf frm "%a\n%!" (pp_term c) t
143 L.pp_term = pp_term; L.pp_context = pp_context