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_______________________________________________________________ *)
18 module R = BrgReduction
32 let initial_counters = {
33 eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0;
34 tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0
37 let rec count_term_binder f c = function
39 let c = {c with tabsts = succ c.tabsts} in
42 let c = {c with tabbrs = succ c.tabbrs} in
46 and count_term f c = function
48 f {c with tsorts = succ c.tsorts}
50 f {c with tlrefs = succ c.tlrefs}
52 f {c with tgrefs = succ c.tgrefs}
54 let c = {c with tcasts = succ c.tcasts} in
55 let f c = count_term f c t in
58 let c = {c with tappls = succ c.tappls} in
59 let f c = count_term f c t in
62 let f c = count_term_binder f c b in
65 let count_obj_binder f c = function
67 let c = {c with eabsts = succ c.eabsts} in
70 let c = {c with eabbrs = succ c.eabbrs} in
74 let count_obj f c (_, _, b) =
75 count_obj_binder f c b
77 let count_item f c = function
78 | Some obj -> count_obj f c obj
81 let print_counters f c =
83 c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
86 let items = c.eabsts + c.eabbrs in
87 L.warn (P.sprintf " Kernel representation summary (basic_rg)");
88 L.warn (P.sprintf " Total entry items: %6u" items);
89 L.warn (P.sprintf " Declaration items: %6u" c.eabsts);
90 L.warn (P.sprintf " Definition items: %6u" c.eabbrs);
91 L.warn (P.sprintf " Total term items: %6u" terms);
92 L.warn (P.sprintf " Sort items: %6u" c.tsorts);
93 L.warn (P.sprintf " Local reference items: %6u" c.tlrefs);
94 L.warn (P.sprintf " Global reference items: %6u" c.tgrefs);
95 L.warn (P.sprintf " Explicit Cast items: %6u" c.tcasts);
96 L.warn (P.sprintf " Application items: %6u" c.tappls);
97 L.warn (P.sprintf " Abstraction items: %6u" c.tabsts);
98 L.warn (P.sprintf " Abbreviation items: %6u" c.tabbrs);
101 let rec pp_term c frm = function
102 | B.Sort h -> F.fprintf frm "@[*%u@]" h
103 | B.LRef i -> F.fprintf frm "@[#%u@]" i
104 | B.GRef s -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
106 F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t
108 F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t
109 | B.Bind (id, B.Abst w, t) ->
110 F.fprintf frm "@[[%s:%a].%a@]" id (pp_term c) w (pp_term c) t
111 | B.Bind (id, B.Abbr v, t) ->
112 F.fprintf frm "@[[%s=%a].%a@]" id (pp_term c) v (pp_term c) t
113 | B.Bind (id, B.Void, t) ->
114 F.fprintf frm "@[[%s].%a@]" id (pp_term c) t
116 let pp_context frm c =
117 let pp_entry f = function
119 F.fprintf frm "%s %a\n%!" "\\decl" (pp_term c) w; f ()
121 F.fprintf frm "%s %a\n%!" "\\def " (pp_term c) v; f ()
123 F.fprintf frm "%s\n%!" "\\void"; f ()
125 R.iter C.start pp_entry c
127 let pp_term frm c t =
128 F.fprintf frm "%a\n%!" (pp_term c) t
131 L.pp_term = pp_term; L.pp_context = pp_context