]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/helena/src/basic_rg/brg.ml
update in helena
[helm.git] / helm / software / helena / src / basic_rg / brg.ml
index 7be7dc939fb41834136e4b31b02ef08946dbcce8..fcf503c6fb78bf7dea41ffc709cacaeea79298fa 100644 (file)
@@ -16,67 +16,74 @@ module N = Layer
 module E = Entity
 
 type uri = E.uri
-type attrs = E.node_attrs
+type n_attrs = E.node_attrs
+type a_attrs = E.appl_attrs
+type b_attrs = E.bind_attrs
 
 (* x-reduced abstractions are output by RTM only *)
 type bind = Void                          (*                         *)
           | Abst of bool * N.layer * term (* x-reduced?, layer, type *)
           | Abbr of term                  (* body                    *)
 
-and term = Sort of attrs * int         (* attrs, hierarchy index *)
-         | LRef of attrs * int         (* attrs, position index *)
-         | GRef of attrs * uri         (* attrs, reference *)
-         | Cast of attrs * term * term (* attrs, type, term *)
-         | Appl of attrs * term * term (* attrs, argument, function *)
-         | Bind of attrs * bind * term (* attrs, binder, scope *)
+and term = Sort of int                    (* hierarchy index *)
+         | LRef of n_attrs * int          (* attrs, position index *)
+         | GRef of n_attrs * uri          (* attrs, reference *)
+         | Cast of term * term            (* type, term *)
+         | Appl of a_attrs * term * term  (* attrs, argument, function *)
+         | Bind of b_attrs * bind * term  (* attrs, binder, scope *)
 
 type entity = term E.entity (* attrs, uri, binder *)
 
 type lenv = Null
 (* Cons: tail, relative local environment, attrs, binder *) 
-          | Cons of lenv * lenv * attrs * bind 
+          | Cons of lenv * lenv * n_attrs * b_attrs * bind 
 
 type manager = (N.status -> entity -> bool) * (unit -> unit)
 
 (* Currified constructors ***************************************************)
 
-let abst x n w = Abst (x, n, w)
+let abst r n w = Abst (r, n, w)
 
 let abbr v = Abbr v
 
 let lref a i = LRef (a, i)
 
-let cast a u t = Cast (a, u, t)
+let gref a u = GRef (a, u)
+
+let cast u t = Cast (u, t)
 
 let appl a u t = Appl (a, u, t)
 
-let bind a b t = Bind (a, b, t)
+let bind y b t = Bind (y, b, t)
 
-let bind_abst x n a u t = Bind (a, Abst (x, n, u), t)
+let bind_abst r n y u t = Bind (y, Abst (r, n, u), t)
 
-let bind_abbr a u t = Bind (a, Abbr u, t)
+let bind_abbr y u t = Bind (y, Abbr u, t)
 
-let bind_void a t = Bind (a, Void, t)
+let bind_void y t = Bind (y, Void, t)
 
 (* local environment handling functions *************************************)
 
 let empty = Null
 
-let push e c a b = Cons (e, c, a, b)
+let push e c a y b = Cons (e, c, a, y, b)
 
-let rec get i = function
-   | Null                         -> empty, empty, E.empty_node, Void
-   | Cons (e, c, a, b) when i = 0 -> e, c, a, b
-   | Cons (e, _, _, _)            -> get (pred i) e
+let rec get e i = match e with
+   | Null                            -> empty, empty, E.empty_node, E.empty_bind, Void
+   | Cons (e, c, a, y, b) when i = 0 -> e, c, a, y, b
+   | Cons (e, _, _, _, _)            -> get e (pred i)
 
-let get e i = get i e
+let rec mem err f e y0 = match e with
+   | Null                 -> err ()
+   | Cons (e, _, _, y, _) ->
+      if y.E.b_name = y0.E.b_name then f () else mem err f e y0
 
 (* used in BrgOutput.pp_lenv *)
 let rec fold_right f map e x = match e with   
-   | Null              -> f x
-   | Cons (e, c, a, b) -> fold_right (map f c a b) map e x
+   | Null                 -> f x
+   | Cons (e, c, a, y, b) -> fold_right (map f c a y b) map e x
 
-let rec mem err f e b = match e with
-   | Null              -> err ()
-   | Cons (e, _, a, _) ->
-      if a.E.n_name = b.E.n_name then f () else mem err f e b
+(* used in BrgCC.output_entity_cc0 *)
+let rec fold_left map x e = match e with   
+   | Null                 -> x
+   | Cons (e, c, a, y, b) -> fold_left map (map x c a y b) e