]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/automath/autOutput.ml
we tranlate an Automath book in an itermediate format where:
[helm.git] / helm / software / lambda-delta / automath / autOutput.ml
diff --git a/helm/software/lambda-delta/automath/autOutput.ml b/helm/software/lambda-delta/automath/autOutput.ml
new file mode 100644 (file)
index 0000000..1acb075
--- /dev/null
@@ -0,0 +1,98 @@
+(* Copyright (C) 2000, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+module A = Aut
+
+type counters = {
+   sections: int;
+   contexts: int;
+   blocks:   int;
+   decls:    int;
+   defs:     int;
+   sorts:    int;
+   grefs:    int;
+   appls:    int;
+   absts:    int;
+   pars:     int
+}
+
+let initial_counters = {
+   sections = 0; contexts = 0; blocks = 0; decls = 0; defs = 0;
+   sorts = 0; grefs = 0; appls = 0; absts = 0; pars = 0
+}
+
+let rec count_term f c = function
+   | A.Sort _         -> 
+      f {c with sorts = succ c.sorts}
+   | A.GRef (_, ts)   -> 
+      let c = {c with grefs = succ c.grefs} in
+      let c = {c with pars = c.pars + List.length ts} in
+      Cps.list_fold_left f count_term c ts
+   | A.Appl (v, t)    -> 
+      let c = {c with appls = succ c.appls} in
+      let f c = count_term f c t in
+      count_term f c v
+   | A.Abst (_, w, t) -> 
+      let c = {c with absts = succ c.absts} in
+      let f c = count_term f c t in
+      count_term f c w
+
+let count_item f c = function
+   | A.Section _        ->
+      f {c with sections = succ c.sections}
+   | A.Context _        ->
+      f {c with contexts = succ c.contexts}
+   | A.Block (_, w)     -> 
+      let c = {c with blocks = succ c.blocks} in
+      count_term f c w
+   | A.Decl (_, w)      -> 
+      let c = {c with decls = succ c.decls} in
+      count_term f c w
+   | A.Def (_, w, _, t) -> 
+      let c = {c with defs = succ c.defs} in
+      let f c = count_term f c t in
+      count_term f c w
+
+let count f c b =
+   Cps.list_fold_left f count_item c b
+
+let print_counters f c =
+   let terms = c.sorts + c.grefs + c.appls + c.absts in
+   let items = c.sections + c.contexts + c.blocks + c.decls + c.defs in
+   Printf.printf "  Automath representation summary\n";
+   Printf.printf "    Total book items:         %6u\n" items;
+   Printf.printf "      Section items:          %6u\n" c.sections;
+   Printf.printf "      Context items:          %6u\n" c.contexts;
+   Printf.printf "      Block items:            %6u\n" c.blocks;
+   Printf.printf "      Declaration items:      %6u\n" c.decls;
+   Printf.printf "      Definition items:       %6u\n" c.defs;
+   Printf.printf "    Total Parameter items:    %6u\n" c.pars;
+   Printf.printf "      Application items:      %6u\n" c.pars;
+   Printf.printf "    Total term items:         %6u\n" terms;
+   Printf.printf "      Sort items:             %6u\n" c.sorts;
+   Printf.printf "      Reference items:        %6u\n" c.grefs;
+   Printf.printf "      Application items:      %6u\n" c.appls;
+   Printf.printf "      Abstraction items:      %6u\n" c.absts;
+   flush stdout; f ()