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
43 let rec count_term_binder f c = function
45 let c = {c with tabsts = succ c.tabsts} in
48 let c = {c with tabbrs = succ c.tabbrs} in
52 and count_term f c = function
54 f {c with tsorts = succ c.tsorts}
56 f {c with tlrefs = succ c.tlrefs}
58 f {c with tgrefs = succ c.tgrefs}
60 let c = {c with tcasts = succ c.tcasts} in
61 let f c = count_term f c t in
64 let c = {c with tappls = succ c.tappls} in
65 let f c = count_term f c t in
67 | Z.Bind (_, _, b, t) ->
68 let f c = count_term_binder f c b in
71 let count_entity f c = function
72 | _, _, _, E.Abst w ->
73 let c = {c with eabsts = succ c.eabsts} in
75 | _, _, _, E.Abbr v ->
76 let c = {c with eabbrs = succ c.eabbrs} in
78 | _, _, _, E.Void -> assert false
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 let locations = P.marks () in
87 L.warn level (KP.sprintf "Kernel representation summary (basic_ag)");
88 L.warn level (KP.sprintf " Total entry items: %7u" items);
89 L.warn level (KP.sprintf " Declaration items: %7u" c.eabsts);
90 L.warn level (KP.sprintf " Definition items: %7u" c.eabbrs);
91 L.warn level (KP.sprintf " Total term items: %7u" terms);
92 L.warn level (KP.sprintf " Sort items: %7u" c.tsorts);
93 L.warn level (KP.sprintf " Local reference items: %7u" c.tlrefs);
94 L.warn level (KP.sprintf " Global reference items: %7u" c.tgrefs);
95 L.warn level (KP.sprintf " Explicit Cast items: %7u" c.tcasts);
96 L.warn level (KP.sprintf " Application items: %7u" c.tappls);
97 L.warn level (KP.sprintf " Abstraction items: %7u" c.tabsts);
98 L.warn level (KP.sprintf " Abbreviation items: %7u" c.tabbrs);
99 L.warn level (KP.sprintf " Total binder locations: %7u" locations);
104 | true -> KP.fprintf och "%s" n
105 | false -> KP.fprintf och "-%s" n
110 let err () = KP.fprintf och "#%s" (P.string_of_mark l) in
111 if !G.indexes then err () else name err och a
113 let rec pp_term st c och = function
115 let err () = KP.fprintf och "*%u" h in
116 let f s = KP.fprintf och "%s" s in
117 H.string_of_sort err f h
119 let err () = KP.fprintf och "#%s" (P.string_of_mark i) in
120 let f a _ = name err och a in
121 if !G.indexes then err () else Z.get err f c i
122 | Z.GRef s -> KP.fprintf och "$%s" (U.string_of_uri s)
124 KP.fprintf och "{%a}.%a" (pp_term st c) u (pp_term st c) t
126 KP.fprintf och "(%a).%a" (pp_term st c) v (pp_term st c) t
127 | Z.Bind (a, l, Z.Abst w, t) ->
129 KP.fprintf och "[%t:%a].%a" (res a l) (pp_term st c) w (pp_term st cc) t
131 Z.push "output abst" f c a l (Z.Abst w)
132 | Z.Bind (a, l, Z.Abbr v, t) ->
134 KP.fprintf och "[%t=%a].%a" (res a l) (pp_term st c) v (pp_term st cc) t
136 Z.push "output abbr" f c a l (Z.Abbr v)
137 | Z.Bind (a, l, Z.Void, t) ->
138 let f cc = KP.fprintf och "[%t].%a" (res a l) (pp_term st cc) t in
139 Z.push "output void" f c a l Z.Void
141 let pp_lenv st och c =
142 let pp_entry och = function
144 KP.fprintf och "%t : %a\n" (res a l) (pp_term st c) w
146 KP.fprintf och "%t = %a\n" (res a l) (pp_term st c) v
148 KP.fprintf och "%t\n" (res a l)
150 let iter map och l = List.iter (map och) l in
151 let f es = KP.fprintf och "%a" (iter pp_entry) (List.rev es) in
155 L.pp_term = pp_term; L.pp_lenv = pp_lenv
158 (* term xml printing ********************************************************)
161 ZD.crg_of_bag (XD.export_term st)