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_______________________________________________________________ *)
37 let initial_counters = {
38 eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0;
39 tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0
42 let rec count_term_binder f c = function
44 let c = {c with tabsts = succ c.tabsts} in
47 let c = {c with tabbrs = succ c.tabbrs} in
51 and count_term f c = function
53 f {c with tsorts = succ c.tsorts}
55 f {c with tlrefs = succ c.tlrefs}
57 f {c with tgrefs = succ c.tgrefs}
59 let c = {c with tcasts = succ c.tcasts} in
60 let f c = count_term f c t in
63 let c = {c with tappls = succ c.tappls} in
64 let f c = count_term f c t in
66 | Z.Bind (_, _, b, t) ->
67 let f c = count_term_binder f c b in
70 let count_entity f c = function
71 | _, _, _, E.Abst w ->
72 let c = {c with eabsts = succ c.eabsts} in
74 | _, _, _, E.Abbr v ->
75 let c = {c with eabbrs = succ c.eabbrs} in
77 | _, _, _, E.Void -> assert false
79 let print_counters f c =
81 c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
84 let items = c.eabsts + c.eabbrs in
85 let locations = J.marks () in
86 L.warn level (P.sprintf "Kernel representation summary (basic_ag)");
87 L.warn level (P.sprintf " Total entry items: %7u" items);
88 L.warn level (P.sprintf " Declaration items: %7u" c.eabsts);
89 L.warn level (P.sprintf " Definition items: %7u" c.eabbrs);
90 L.warn level (P.sprintf " Total term items: %7u" terms);
91 L.warn level (P.sprintf " Sort items: %7u" c.tsorts);
92 L.warn level (P.sprintf " Local reference items: %7u" c.tlrefs);
93 L.warn level (P.sprintf " Global reference items: %7u" c.tgrefs);
94 L.warn level (P.sprintf " Explicit Cast items: %7u" c.tcasts);
95 L.warn level (P.sprintf " Application items: %7u" c.tappls);
96 L.warn level (P.sprintf " Abstraction items: %7u" c.tabsts);
97 L.warn level (P.sprintf " Abbreviation items: %7u" c.tabbrs);
98 L.warn level (P.sprintf " Total binder locations: %7u" locations);
103 | true -> P.fprintf och "%s" n
104 | false -> P.fprintf och "-%s" n
109 let err () = P.fprintf och "#%s" (J.to_string l) in
110 if !G.indexes then err () else name err och a
112 let rec pp_term c och = function
114 let err () = P.fprintf och "*%u" h in
115 let f s = P.fprintf och "%s" s in
116 H.string_of_sort err f h
118 let err () = P.fprintf och "#%s" (J.to_string i) in
119 let f a _ = name err och a in
120 if !G.indexes then err () else Z.get err f c i
121 | Z.GRef s -> P.fprintf och "$%s" (U.string_of_uri s)
123 P.fprintf och "{%a}.%a" (pp_term c) u (pp_term c) t
125 P.fprintf och "(%a).%a" (pp_term c) v (pp_term c) t
126 | Z.Bind (a, l, Z.Abst w, t) ->
128 P.fprintf och "[%t:%a].%a" (res a l) (pp_term c) w (pp_term cc) t
130 Z.push "output abst" f c a l (Z.Abst w)
131 | Z.Bind (a, l, Z.Abbr v, t) ->
133 P.fprintf och "[%t=%a].%a" (res a l) (pp_term c) v (pp_term cc) t
135 Z.push "output abbr" f c a l (Z.Abbr v)
136 | Z.Bind (a, l, Z.Void, t) ->
137 let f cc = P.fprintf och "[%t].%a" (res a l) (pp_term cc) t in
138 Z.push "output void" f c a l Z.Void
141 let pp_entry och = function
143 P.fprintf och "%t : %a\n" (res a l) (pp_term c) w
145 P.fprintf och "%t = %a\n" (res a l) (pp_term c) v
147 P.fprintf och "%t\n" (res a l)
149 let iter map och l = List.iter (map och) l in
150 let f es = P.fprintf och "%a" (iter pp_entry) (List.rev es) in
154 L.pp_term = pp_term; L.pp_lenv = pp_lenv
157 (* term xml printing ********************************************************)
160 ZD.crg_of_bag XD.export_term