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_______________________________________________________________ *)
38 let initial_counters = {
39 eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0;
40 tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0
45 let rec count_term_binder f c = function
47 let c = {c with tabsts = succ c.tabsts} in
50 let c = {c with tabbrs = succ c.tabbrs} in
54 and count_term f c = function
56 f {c with tsorts = succ c.tsorts}
58 f {c with tlrefs = succ c.tlrefs}
60 f {c with tgrefs = succ c.tgrefs}
62 let c = {c with tcasts = succ c.tcasts} in
63 let f c = count_term f c t in
66 let c = {c with tappls = succ c.tappls} in
67 let f c = count_term f c t in
69 | Z.Bind (_, _, b, t) ->
70 let f c = count_term_binder f c b in
73 let count_entity f c = function
74 | _, _, _, E.Abst w ->
75 let c = {c with eabsts = succ c.eabsts} in
77 | _, _, _, E.Abbr v ->
78 let c = {c with eabbrs = succ c.eabbrs} in
80 | _, _, _, E.Void -> assert false
82 let print_counters f c =
84 c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
87 let items = c.eabsts + c.eabbrs in
88 let locations = P.marks () in
89 L.warn level (KP.sprintf "Kernel representation summary (basic_ag)");
90 L.warn level (KP.sprintf " Total entry items: %7u" items);
91 L.warn level (KP.sprintf " Declaration items: %7u" c.eabsts);
92 L.warn level (KP.sprintf " Definition items: %7u" c.eabbrs);
93 L.warn level (KP.sprintf " Total term items: %7u" terms);
94 L.warn level (KP.sprintf " Sort items: %7u" c.tsorts);
95 L.warn level (KP.sprintf " Local reference items: %7u" c.tlrefs);
96 L.warn level (KP.sprintf " Global reference items: %7u" c.tgrefs);
97 L.warn level (KP.sprintf " Explicit Cast items: %7u" c.tcasts);
98 L.warn level (KP.sprintf " Application items: %7u" c.tappls);
99 L.warn level (KP.sprintf " Abstraction items: %7u" c.tabsts);
100 L.warn level (KP.sprintf " Abbreviation items: %7u" c.tabbrs);
101 L.warn level (KP.sprintf " Total binder locations: %7u" locations);
108 | true -> KP.fprintf och "%s" n
109 | false -> KP.fprintf och "-%s" n
114 let err () = KP.fprintf och "#%s" (P.string_of_mark l) in
115 if !G.indexes then err () else name err och a
117 let rec pp_term st c och = function
119 let err () = KP.fprintf och "*%u" h in
120 let f s = KP.fprintf och "%s" s in
121 H.string_of_sort err f h
123 let err () = KP.fprintf och "#%s" (P.string_of_mark i) in
124 let f a _ = name err och a in
125 if !G.indexes then err () else Z.get err f c i
126 | Z.GRef s -> KP.fprintf och "$%s" (U.string_of_uri s)
128 KP.fprintf och "{%a}.%a" (pp_term st c) u (pp_term st c) t
130 KP.fprintf och "(%a).%a" (pp_term st c) v (pp_term st c) t
131 | Z.Bind (y, l, Z.Abst w, t) ->
133 KP.fprintf och "[%t:%a].%a" (res y l) (pp_term st c) w (pp_term st cc) t
135 Z.push "output abst" f c y l (Z.Abst w)
136 | Z.Bind (y, l, Z.Abbr v, t) ->
138 KP.fprintf och "[%t=%a].%a" (res y l) (pp_term st c) v (pp_term st cc) t
140 Z.push "output abbr" f c y l (Z.Abbr v)
141 | Z.Bind (y, l, Z.Void, t) ->
142 let f cc = KP.fprintf och "[%t].%a" (res y l) (pp_term st cc) t in
143 Z.push "output void" f c y l Z.Void
145 let pp_lenv st och c =
146 let pp_entry och = function
148 KP.fprintf och "%t : %a\n" (res y l) (pp_term st c) w
150 KP.fprintf och "%t = %a\n" (res y l) (pp_term st c) v
152 KP.fprintf och "%t\n" (res y l)
154 let iter map och l = List.iter (map och) l in
155 let f es = KP.fprintf och "%a" (iter pp_entry) (List.rev es) in
159 L.pp_term = pp_term; L.pp_lenv = pp_lenv
164 (* term xml printing ********************************************************)
167 ZD.crg_of_bag (XD.export_term st)