]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/basic_rg/brgOutput.ml
refactoring: helena sources are now in a dedicated directory
[helm.git] / helm / software / lambda-delta / basic_rg / brgOutput.ml
diff --git a/helm/software/lambda-delta/basic_rg/brgOutput.ml b/helm/software/lambda-delta/basic_rg/brgOutput.ml
deleted file mode 100644 (file)
index 186349a..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-(*
-    ||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_______________________________________________________________ *)
-
-module P = Printf
-module F = Format
-module C = Cps
-module U = NUri
-module L = Log
-module O = Options
-module Y = Entity
-module X = Library
-module H = Hierarchy
-module B = Brg
-
-(* nodes count **************************************************************)
-
-type counters = {
-   eabsts: int;
-   eabbrs: int;
-   evoids: int;
-   tsorts: int;
-   tlrefs: int;
-   tgrefs: int;
-   tcasts: int;
-   tappls: int;
-   tabsts: int;
-   tabbrs: int;
-   tvoids: int;
-   uris  : B.uri list;
-   nodes : int;
-   xnodes: int
-}
-
-let initial_counters = {
-   eabsts = 0; eabbrs = 0; evoids = 0; 
-   tsorts = 0; tlrefs = 0; tgrefs = 0; tcasts = 0; tappls = 0;
-   tabsts = 0; tabbrs = 0; tvoids = 0;
-   uris = []; nodes = 0; xnodes = 0
-}
-
-let rec count_term_binder f c e = function
-   | B.Abst w ->
-      let c = {c with tabsts = succ c.tabsts; nodes = succ c.nodes} in
-      count_term f c e w
-   | B.Abbr v -> 
-      let c = {c with tabbrs = succ c.tabbrs; xnodes = succ c.xnodes} in
-      count_term f c e v
-   | B.Void   ->
-      let c = {c with tvoids = succ c.tvoids; xnodes = succ c.xnodes} in   
-      f c
-
-and count_term f c e = function
-   | B.Sort _         -> 
-      f {c with tsorts = succ c.tsorts; nodes = succ c.nodes}
-   | B.LRef (_, i)    -> 
-      begin match B.get e i with
-        | _, _, _, B.Abst _
-        | _, _, _, B.Void   ->
-           f {c with tlrefs = succ c.tlrefs; nodes = succ c.nodes}
-        | _, _, _, B.Abbr _ ->
-           f {c with tlrefs = succ c.tlrefs; xnodes = succ c.xnodes}
-      end      
-   | B.GRef (_, u)    -> 
-      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
-      f {c with tgrefs = succ c.tgrefs}
-   | B.Cast (_, v, t) -> 
-      let c = {c with tcasts = succ c.tcasts} in
-      let f c = count_term f c e t in
-      count_term f c e v
-   | B.Appl (_, v, t) -> 
-      let c = {c with tappls = succ c.tappls; nodes = succ c.nodes} in
-      let f c = count_term f c e t in
-      count_term f c e v
-   | B.Bind (a, b, t) -> 
-      let f c = count_term f c (B.push e B.empty a b) t in
-      count_term_binder f c e b
-
-let count_entity f c = function
-   | _, u, Y.Abst w -> 
-      let c = {c with
-         eabsts = succ c.eabsts; nodes = succ c.nodes; uris = u :: c.uris
-      } in
-      count_term f c B.empty w
-   | _, _, Y.Abbr v ->  
-      let c = {c with eabbrs = succ c.eabbrs; xnodes = succ c.xnodes} in
-      count_term f c B.empty v
-   | _, _, Y.Void   -> assert false
-
-let print_counters f c =
-   let terms =
-      c.tsorts + c.tgrefs + c.tgrefs + c.tcasts + c.tappls + c.tabsts +
-      c.tabbrs
-   in
-   let items = c.eabsts + c.eabbrs in
-   let nodes = c.nodes + c.xnodes in
-   L.warn (P.sprintf "  Kernel representation summary (basic_rg)");
-   L.warn (P.sprintf "    Total entry items:        %7u" items);
-   L.warn (P.sprintf "      Declaration items:      %7u" c.eabsts);
-   L.warn (P.sprintf "      Definition items:       %7u" c.eabbrs);
-   L.warn (P.sprintf "    Total term items:         %7u" terms);
-   L.warn (P.sprintf "      Sort items:             %7u" c.tsorts);
-   L.warn (P.sprintf "      Local reference items:  %7u" c.tlrefs);
-   L.warn (P.sprintf "      Global reference items: %7u" c.tgrefs);
-   L.warn (P.sprintf "      Explicit Cast items:    %7u" c.tcasts);
-   L.warn (P.sprintf "      Application items:      %7u" c.tappls);
-   L.warn (P.sprintf "      Abstraction items:      %7u" c.tabsts);
-   L.warn (P.sprintf "      Abbreviation items:     %7u" c.tabbrs);
-   L.warn (P.sprintf "    Global Int. Complexity:   %7u" c.nodes);
-   L.warn (P.sprintf "      + Abbreviation nodes:   %7u" nodes);
-   f ()
-
-(* supplementary annotation *************************************************)
-
-let rec does_not_occur f n r = function
-   | B.Null              -> f true
-   | B.Cons (e, _, a, _) ->
-      let f n1 r1 =
-         if n1 = n && r1 = r then f false else does_not_occur f n r e
-      in
-      Y.name C.err f a 
-
-let rename f e a =
-   let rec aux f e n r =
-      let f = function
-         | true  -> f n r
-        | false -> aux f e (n ^ "_") r
-      in
-      does_not_occur f n r e
-   in
-   let f n0 r0 =
-      let f n r = if n = n0 && r = r0 then f a else f (Y.Name (n, r) :: a) in
-      aux f e n0 r0 
-   in
-   Y.name C.err f a
-
-(* lenv/term pretty printing ************************************************)
-
-let name err frm a =
-   let f n = function 
-      | true  -> F.fprintf frm "%s" n
-      | false -> F.fprintf frm "^%s" n
-   in      
-   Y.name err f a
-
-let rec pp_term e frm = function
-   | B.Sort (_, h)           -> 
-      let err _ = F.fprintf frm "@[*%u@]" h in
-      let f s = F.fprintf frm "@[%s@]" s in
-      H.string_of_sort err f h 
-   | B.LRef (_, i)           -> 
-      let err _ = F.fprintf frm "@[#%u@]" i in
-      if !O.indexes then err () else      
-      let _, _, a, b = B.get e i in
-      F.fprintf frm "@[%a@]" (name err) a
-   | B.GRef (_, s)           ->
-      F.fprintf frm "@[$%s@]" (U.string_of_uri s)
-   | B.Cast (_, u, t)        ->
-      F.fprintf frm "@[{%a}.%a@]" (pp_term e) u (pp_term e) t
-   | B.Appl (_, v, t)        ->
-      F.fprintf frm "@[(%a).%a@]" (pp_term e) v (pp_term e) t
-   | B.Bind (a, B.Abst w, t) ->
-      let f a =
-         let ee = B.push e B.empty a (B.abst w) in
-        F.fprintf frm "@[[%a:%a].%a@]" (name C.err) a (pp_term e) w (pp_term ee) t
-      in
-      rename f e a
-   | B.Bind (a, B.Abbr v, t) ->
-      let f a = 
-         let ee = B.push e B.empty a (B.abbr v) in
-        F.fprintf frm "@[[%a=%a].%a@]" (name C.err) a (pp_term e) v (pp_term ee) t
-      in
-      rename f e a
-   | B.Bind (a, B.Void, t)   ->
-      let f a = 
-         let ee = B.push e B.empty a B.Void in
-         F.fprintf frm "@[[%a].%a@]" (name C.err) a (pp_term ee) t
-      in
-      rename f e a
-
-let pp_lenv frm e =
-   let pp_entry f e c a b x = f x (*match b with
-      | B.Abst (a, w) -> 
-         let f a = F.fprintf frm "@,@[%a : %a@]" (name C.err) a (pp_term e) w; f a in
-         rename f x a
-      | B.Abbr (a, v) -> 
-         let f a = F.fprintf frm "@,@[%a = %a@]" (name C.err) a (pp_term e) v; f a in
-        rename f c a
-      | B.Void a      -> 
-         let f a = F.fprintf frm "@,%a" (name C.err) a; f a in
-        rename f c a
-*)   in
-   B.fold_right ignore pp_entry e B.empty
-
-let specs = {
-   L.pp_term = pp_term; L.pp_lenv = pp_lenv
-}
-
-(* term xml printing ********************************************************)
-
-let rec exp_term e t out tab = match t with
-   | B.Sort (a, l)    ->
-      let a =
-         let err _ = a in
-         let f s = Y.Name (s, true) :: a in
-        H.string_of_sort err f l
-      in
-      let attrs = [X.position l; X.name a] in
-      X.tag X.sort attrs out tab
-   | B.LRef (a, i)    ->
-      let a = 
-        let err _ = a in
-        let f n r = Y.Name (n, r) :: a in
-         let _, _, a, b = B.get e i in
-        Y.name err f a
-      in
-      let attrs = [X.position i; X.name a] in
-      X.tag X.lref attrs out tab
-   | B.GRef (a, n)    ->
-      let a = Y.Name (U.name_of_uri n, true) :: a in
-      let attrs = [X.uri n; X.name a] in
-      X.tag X.gref attrs out tab
-   | B.Cast (a, u, t) ->
-      let attrs = [] in
-      X.tag X.cast attrs ~contents:(exp_term e u) out tab;
-      exp_term e t out tab
-   | B.Appl (a, v, t) ->
-      let attrs = [] in
-      X.tag X.appl attrs ~contents:(exp_term e v) out tab;
-      exp_term e t out tab
-   | B.Bind (a, b, t)    ->
-      let a = rename C.start e a in
-      exp_bind e a b out tab; 
-      exp_term (B.push e B.empty a b) t out tab 
-
-and exp_bind e a b out tab = match b with
-   | B.Abst w ->
-      let attrs = [X.name a; X.mark a] in
-      X.tag X.abst attrs ~contents:(exp_term e w) out tab
-   | B.Abbr v ->
-      let attrs = [X.name a; X.mark a] in
-      X.tag X.abbr attrs ~contents:(exp_term e v) out tab
-   | B.Void   ->
-      let attrs = [X.name a; X.mark a] in
-      X.tag X.void attrs out tab
-
-let export_term = exp_term B.empty