From 960ed22a5a6c415e2cf0ec9e8f5680d75c3ca0cd Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Mon, 22 Jun 2009 22:53:12 +0000 Subject: [PATCH] - nodes count is now working for aut and meta - bugfix in autLexer - comment fix in aut --- helm/software/lambda-delta/automath/aut.ml | 36 ++++++------------- .../lambda-delta/automath/autLexer.mll | 3 +- .../lambda-delta/automath/autOutput.ml | 20 ++++++----- helm/software/lambda-delta/lib/cps.ml | 5 +++ .../lambda-delta/toplevel/metaOutput.ml | 35 +++++++++++++----- 5 files changed, 55 insertions(+), 44 deletions(-) diff --git a/helm/software/lambda-delta/automath/aut.ml b/helm/software/lambda-delta/automath/aut.ml index 66c252d5e..dc938821e 100644 --- a/helm/software/lambda-delta/automath/aut.ml +++ b/helm/software/lambda-delta/automath/aut.ml @@ -1,31 +1,17 @@ -(* 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/. - *) +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department, University of Bologna, Italy. + ||I|| + ||T|| HELM is free software; you can redistribute it and/or + ||A|| modify it under the terms of the GNU General Public License + \ / version 2 or (at your option) any later version. + \ / This software is distributed as is, NO WARRANTY. + V_______________________________________________________________ *) type id = string (* identifier *) -type qid = id * bool * id list (* qualified identifier: name, is local?, qualifiers *) +type qid = id * bool * id list (* qualified identifier: name, local?, path *) type term = Sort of bool (* sorts: true = TYPE, false = PROP *) | GRef of qid * term list (* reference: name, arguments *) diff --git a/helm/software/lambda-delta/automath/autLexer.mll b/helm/software/lambda-delta/automath/autLexer.mll index fa385bca4..006c056b9 100644 --- a/helm/software/lambda-delta/automath/autLexer.mll +++ b/helm/software/lambda-delta/automath/autLexer.mll @@ -28,13 +28,12 @@ rule line_comment = parse | NL { () } | OC { block_comment lexbuf; line_comment lexbuf } | _ { line_comment lexbuf } - | eof { () } + | eof { () } and block_comment = parse | CC { () } | OC { block_comment lexbuf; block_comment lexbuf } | LC { line_comment lexbuf; block_comment lexbuf } | _ { block_comment lexbuf } - | eof { () } and token = parse | SPC { token lexbuf } | LC { line_comment lexbuf; token lexbuf } diff --git a/helm/software/lambda-delta/automath/autOutput.ml b/helm/software/lambda-delta/automath/autOutput.ml index 26a2d7b16..ffbdfdb20 100644 --- a/helm/software/lambda-delta/automath/autOutput.ml +++ b/helm/software/lambda-delta/automath/autOutput.ml @@ -23,27 +23,29 @@ type counters = { grefs: int; appls: int; absts: int; - pars: int + pars: int; + xnodes: int } let initial_counters = { sections = 0; contexts = 0; blocks = 0; decls = 0; defs = 0; - sorts = 0; grefs = 0; appls = 0; absts = 0; pars = 0 + sorts = 0; grefs = 0; appls = 0; absts = 0; pars = 0; xnodes = 0 } let rec count_term f c = function | A.Sort _ -> - f {c with sorts = succ c.sorts} + f {c with sorts = succ c.sorts; xnodes = succ c.xnodes} | A.GRef (_, ts) -> let c = {c with grefs = succ c.grefs} in let c = {c with pars = c.pars + List.length ts} in + let c = {c with xnodes = succ c.xnodes + 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 c = {c with appls = succ c.appls; xnodes = succ c.xnodes} 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 c = {c with absts = succ c.absts; xnodes = succ c.xnodes} in let f c = count_term f c t in count_term f c w @@ -53,13 +55,13 @@ let count_item f c = function | A.Context _ -> f {c with contexts = succ c.contexts} | A.Block (_, w) -> - let c = {c with blocks = succ c.blocks} in + let c = {c with blocks = succ c.blocks; xnodes = succ c.xnodes} in count_term f c w | A.Decl (_, w) -> - let c = {c with decls = succ c.decls} in + let c = {c with decls = succ c.decls; xnodes = succ c.xnodes} in count_term f c w | A.Def (_, w, _, t) -> - let c = {c with defs = succ c.defs} in + let c = {c with defs = succ c.defs; xnodes = succ c.xnodes} in let f c = count_term f c t in count_term f c w @@ -80,4 +82,6 @@ let print_counters f c = L.warn (P.sprintf " Reference items: %7u" c.grefs); L.warn (P.sprintf " Application items: %7u" c.appls); L.warn (P.sprintf " Abstraction items: %7u" c.absts); + L.warn (P.sprintf " Global Int. Complexity: unknown"); + L.warn (P.sprintf " + Abbreviation nodes: %7u" c.xnodes); f () diff --git a/helm/software/lambda-delta/lib/cps.ml b/helm/software/lambda-delta/lib/cps.ml index 3875d88fa..38b249030 100644 --- a/helm/software/lambda-delta/lib/cps.ml +++ b/helm/software/lambda-delta/lib/cps.ml @@ -63,3 +63,8 @@ let rec list_fold_left2 f map a l1 l2 = match l1, l2 with let f a = list_fold_left2 f map a tl1 tl2 in map f a hd1 hd2 | _ -> assert false + +let rec list_mem ?(eq=(=)) a = function + | [] -> false + | hd :: _ when eq a hd -> true + | _ :: tl -> list_mem ~eq a tl diff --git a/helm/software/lambda-delta/toplevel/metaOutput.ml b/helm/software/lambda-delta/toplevel/metaOutput.ml index 5fe20f0f4..7349fa573 100644 --- a/helm/software/lambda-delta/toplevel/metaOutput.ml +++ b/helm/software/lambda-delta/toplevel/metaOutput.ml @@ -25,42 +25,56 @@ type counters = { pappls: int; tappls: int; tabsts: int; + uris : U.uri list; + nodes : int; + xnodes: int } let initial_counters = { eabsts = 0; eabbrs = 0; pabsts = 0; pappls = 0; - tsorts = 0; tlrefs = 0; tgrefs = 0; tappls = 0; tabsts = 0 + tsorts = 0; tlrefs = 0; tgrefs = 0; tappls = 0; tabsts = 0; + uris = []; nodes = 0; xnodes = 0 } let rec count_term f c = function | M.Sort _ -> - f {c with tsorts = succ c.tsorts} + f {c with tsorts = succ c.tsorts; nodes = succ c.nodes} | M.LRef _ -> - f {c with tlrefs = succ c.tlrefs} - | M.GRef (_, _, ts) -> + f {c with tlrefs = succ c.tlrefs; nodes = succ c.nodes} + | M.GRef (_, u, ts) -> let c = {c with tgrefs = succ c.tgrefs} in let c = {c with pappls = c.pappls + List.length ts} in + let c = {c with nodes = c.nodes + List.length ts} in + let c = + if Cps.list_mem ~eq:U.eq u c.uris + then {c with nodes = succ c.nodes} + else {c with xnodes = succ c.xnodes} + in Cps.list_fold_left f count_term c ts | M.Appl (v, t) -> - let c = {c with tappls = succ c.tappls} in + let c = {c with tappls = succ c.tappls; nodes = succ c.nodes} in let f c = count_term f c t in count_term f c v | M.Abst (_, w, t) -> - let c = {c with tabsts = succ c.tabsts} in + let c = {c with tabsts = succ c.tabsts; nodes = succ c.nodes} in let f c = count_term f c t in count_term f c w -let count_par f c (_, w) = count_term f c w +let count_par f c (_, w) = + let c = {c with nodes = succ c.nodes} in + count_term f c w let count_entry f c = function - | _, pars, _, w, None -> + | _, pars, u, w, None -> let c = {c with eabsts = succ c.eabsts} in let c = {c with pabsts = c.pabsts + List.length pars} in + let c = {c with uris = u :: c.uris; nodes = succ c.nodes + List.length pars} in let f c = count_term f c w in Cps.list_fold_left f count_par c pars | _, pars, _, w, Some (_, v) -> - let c = {c with eabbrs = succ c.eabbrs} in + let c = {c with eabbrs = succ c.eabbrs; xnodes = succ c.xnodes} in let c = {c with pabsts = c.pabsts + List.length pars} in + let c = {c with nodes = c.nodes + List.length pars} in let f c = count_term f c v in let f c = count_term f c w in Cps.list_fold_left f count_par c pars @@ -73,6 +87,7 @@ let print_counters f c = let terms = c.tsorts + c.tgrefs + c.tgrefs + c.tappls + c.tabsts in let pars = c.pabsts + c.pappls in let items = c.eabsts + c.eabbrs in + let nodes = c.nodes + c.xnodes in L.warn (P.sprintf " Intermediate representation summary"); L.warn (P.sprintf " Total entry items: %7u" items); L.warn (P.sprintf " Declaration items: %7u" c.eabsts); @@ -86,6 +101,8 @@ let print_counters f c = L.warn (P.sprintf " Global reference items: %7u" c.tgrefs); L.warn (P.sprintf " Application items: %7u" c.tappls); L.warn (P.sprintf " Abstraction items: %7u" c.tabsts); + L.warn (P.sprintf " Global Int. Complexity: %7u" c.nodes); + L.warn (P.sprintf " + Abbreviation nodes: %7u" nodes); f () let string_of_sort = function -- 2.39.2