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_______________________________________________________________ *)
20 (* nodes count **************************************************************)
34 let initial_counters = {
35 eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0;
36 tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0
39 let rec count_term_binder f c = function
41 let c = {c with tabsts = succ c.tabsts} in
44 let c = {c with tabbrs = succ c.tabbrs} in
48 and count_term f c = function
50 f {c with tsorts = succ c.tsorts}
52 f {c with tlrefs = succ c.tlrefs}
54 f {c with tgrefs = succ c.tgrefs}
56 let c = {c with tcasts = succ c.tcasts} in
57 let f c = count_term f c t in
60 let c = {c with tappls = succ c.tappls} in
61 let f c = count_term f c t in
64 let f c = count_term_binder f c b in
67 let count_obj_binder f c = function
69 let c = {c with eabsts = succ c.eabsts} in
72 let c = {c with eabbrs = succ c.eabbrs} in
76 let count_obj f c (_, _, b) =
77 count_obj_binder f c b
79 let count_item f c = function
80 | Some obj -> count_obj f c obj
83 let print_counters f c =
85 c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
88 let items = c.eabsts + c.eabbrs in
89 L.warn (P.sprintf " Kernel representation summary (basic_rg)");
90 L.warn (P.sprintf " Total entry items: %7u" items);
91 L.warn (P.sprintf " Declaration items: %7u" c.eabsts);
92 L.warn (P.sprintf " Definition items: %7u" c.eabbrs);
93 L.warn (P.sprintf " Total term items: %7u" terms);
94 L.warn (P.sprintf " Sort items: %7u" c.tsorts);
95 L.warn (P.sprintf " Local reference items: %7u" c.tlrefs);
96 L.warn (P.sprintf " Global reference items: %7u" c.tgrefs);
97 L.warn (P.sprintf " Explicit Cast items: %7u" c.tcasts);
98 L.warn (P.sprintf " Application items: %7u" c.tappls);
99 L.warn (P.sprintf " Abstraction items: %7u" c.tabsts);
100 L.warn (P.sprintf " Abbreviation items: %7u" c.tabbrs);
103 (* context/term pretty printing *********************************************)
107 | None -> assert false
108 | Some (true, n) -> F.fprintf frm "%s" n
109 | Some (false, n) -> F.fprintf frm "^%s" n
113 let rec pp_term c frm = function
116 | Some s -> F.fprintf frm "@[%s@]" s
117 | None -> F.fprintf frm "@[*%u@]" h
122 | Some (a, _) -> F.fprintf frm "@[%a@]" id a
123 | None -> F.fprintf frm "@[#%u@]" i
125 if !O.indexes then f 0 None else B.get f c i
126 | B.GRef (_, s) -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
127 | B.Cast (_, u, t) ->
128 F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t
129 | B.Appl (_, v, t) ->
130 F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t
131 | B.Bind (a, B.Abst w, t) ->
133 F.fprintf frm "@[[%a:%a].%a@]" id a (pp_term c) w (pp_term cc) t
135 B.push f c a (B.Abst w)
136 | B.Bind (a, B.Abbr v, t) ->
138 F.fprintf frm "@[[%a=%a].%a@]" id a (pp_term c) v (pp_term cc) t
140 B.push f c a (B.Abbr v)
141 | B.Bind (a, B.Void, t) ->
142 let f cc = F.fprintf frm "@[[%a].%a@]" id a (pp_term cc) t in
145 let pp_context frm c =
146 let pp_entry frm = function
148 F.fprintf frm "@,@[%a : %a@]" id a (pp_term c) w
150 F.fprintf frm "@,@[%a = %a@]" id a (pp_term c) v
152 F.fprintf frm "@,%a" id a
154 let iter map frm l = List.iter (map frm) l in
155 let f es = F.fprintf frm "%a" (iter pp_entry) (List.rev es) in
159 L.pp_term = pp_term; L.pp_context = pp_context