]> matita.cs.unibo.it Git - helm.git/blob - helm/software/lambda-delta/automath/autOutput.ml
- we now use a streaming architecture (run time gain: 11 secs)
[helm.git] / helm / software / lambda-delta / automath / autOutput.ml
1 (* Copyright (C) 2000, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 module A = Aut
27
28 type counters = {
29    sections: int;
30    contexts: int;
31    blocks:   int;
32    decls:    int;
33    defs:     int;
34    sorts:    int;
35    grefs:    int;
36    appls:    int;
37    absts:    int;
38    pars:     int
39 }
40
41 let initial_counters = {
42    sections = 0; contexts = 0; blocks = 0; decls = 0; defs = 0;
43    sorts = 0; grefs = 0; appls = 0; absts = 0; pars = 0
44 }
45
46 let rec count_term f c = function
47    | A.Sort _         -> 
48       f {c with sorts = succ c.sorts}
49    | A.GRef (_, ts)   -> 
50       let c = {c with grefs = succ c.grefs} in
51       let c = {c with pars = c.pars + List.length ts} in
52       Cps.list_fold_left f count_term c ts
53    | A.Appl (v, t)    -> 
54       let c = {c with appls = succ c.appls} in
55       let f c = count_term f c t in
56       count_term f c v
57    | A.Abst (_, w, t) -> 
58       let c = {c with absts = succ c.absts} in
59       let f c = count_term f c t in
60       count_term f c w
61
62 let count_item f c = function
63    | A.Section _        ->
64       f {c with sections = succ c.sections}
65    | A.Context _        ->
66       f {c with contexts = succ c.contexts}
67    | A.Block (_, w)     -> 
68       let c = {c with blocks = succ c.blocks} in
69       count_term f c w
70    | A.Decl (_, w)      -> 
71       let c = {c with decls = succ c.decls} in
72       count_term f c w
73    | A.Def (_, w, _, t) -> 
74       let c = {c with defs = succ c.defs} in
75       let f c = count_term f c t in
76       count_term f c w
77
78 let print_counters f c =
79    let terms = c.sorts + c.grefs + c.appls + c.absts in
80    let items = c.sections + c.contexts + c.blocks + c.decls + c.defs in
81    Printf.printf "  Automath representation summary\n";
82    Printf.printf "    Total book items:         %6u\n" items;
83    Printf.printf "      Section items:          %6u\n" c.sections;
84    Printf.printf "      Context items:          %6u\n" c.contexts;
85    Printf.printf "      Block items:            %6u\n" c.blocks;
86    Printf.printf "      Declaration items:      %6u\n" c.decls;
87    Printf.printf "      Definition items:       %6u\n" c.defs;
88    Printf.printf "    Total Parameter items:    %6u\n" c.pars;
89    Printf.printf "      Application items:      %6u\n" c.pars;
90    Printf.printf "    Total term items:         %6u\n" terms;
91    Printf.printf "      Sort items:             %6u\n" c.sorts;
92    Printf.printf "      Reference items:        %6u\n" c.grefs;
93    Printf.printf "      Application items:      %6u\n" c.appls;
94    Printf.printf "      Abstraction items:      %6u\n" c.absts;
95    flush stdout; f ()