]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/helena/src/common/entity.ml
update in helena
[helm.git] / helm / software / helena / src / common / entity.ml
index c447190501854daee08e11455956be0ae1477105..039ed63a4cab12b5f15112130b13786ac7b27afd 100644 (file)
@@ -10,7 +10,7 @@
       V_______________________________________________________________ *)
 
 module U = NUri
-module N = Level
+module N = Layer
 
 type uri = U.uri
 
@@ -18,16 +18,27 @@ type id = string (* identifier *)
 
 type name = id * bool (* token, real? *)
 
+type arity = int * int (* sort, degree *)
+
 type meta = Main     (* main object *)
           | InProp   (* inhabitant of a proposition *)
           | Progress (* uncompleted object *)
          | Private  (* private global definition *)
 
 type node_attrs = {
-   n_name: name option; (* name *)
-   n_apix: int option;  (* additional position index *)
-   n_degr: int;         (* degree *)
-   n_real: bool;        (* real node? (not generated) *)
+   n_apix: int; (* additional position index *)
+}
+
+type appl_attrs = {
+   a_rest: bool;  (* restricted application? *)
+   a_main: arity; (* main arity *)
+   a_side: arity; (* side arity *)
+}
+
+type bind_attrs = {
+   b_name: name option; (* name *)
+   b_main: arity;       (* main arity *)
+   b_side: arity;       (* side arity *)
 }
 
 type root_attrs = {
@@ -35,44 +46,69 @@ type root_attrs = {
    r_info: (string * string) option; (* metaliguistic annotation: language (defaults to "en-US"), text *)
 }
 
-type 'term bind = Abst of 'term (* declaration: domain *)
-                | Abbr of 'term (* definition: body    *)
-               | Void          (* exclusion           *)
+type env_attrs = {
+   e_side: arity; (* arity *)
+}
 
-type 'term entity = root_attrs * node_attrs * uri * 'term bind (* attrs,  uri, binder *)
+
+type 'term bind = Abst of env_attrs * 'term (* declaration: attrs, domain *)
+                | Abbr of env_attrs * 'term (* definition: attrs, body    *)
+               | Void                      (* exclusion                  *)
+
+type 'term entity = root_attrs * node_attrs * uri * 'term bind (* attrs, uri, binder *)
 
 (* helpers ******************************************************************)
 
-let node_attrs ?(real=true) ?apix ?name ?(degr=0) () = {
-   n_real = real; n_apix = apix; n_name = name; n_degr = degr;
+let node_attrs ?(apix=0) () = {
+   n_apix = apix;
+}
+
+let appl_attrs ?(main=(0,0)) ?(side=(0,0)) rest = {
+   a_rest = rest; a_main = main; a_side = side;
+}
+
+let bind_attrs ?name ?(main=(0,0)) ?(side=(0,0)) () = {
+   b_name = name; b_main = main; b_side = side;
 }
 
 let root_attrs ?(meta=[]) ?info () = {
    r_meta = meta; r_info = info;
 }
 
+let env_attrs ?(side=(0,0)) () = {
+   e_side = side;
+}
+
 let empty_node = node_attrs ()
 
+let empty_bind = bind_attrs ()
+
 let empty_root = root_attrs ()
 
+let empty_env = env_attrs ()
+
+let abst a t = Abst (a, t)
+
+let abbr a t = Abbr (a, t)
+
 let common f (ra, na, u, _) = f ra na u
 
-let rec name err f a = match a.n_name with
+let succ (sort, degr) = sort, succ degr
+
+let compose av yt = {av with b_main = yt}
+
+let rec name err f a = match a.b_name with
    | Some (n, r) -> f n r
    | None        -> err ()
 
-let rec apix err f a = match a.n_apix with
-   | Some i -> f i
-   | None   -> err ()
-
 let rec info err f a = match a.r_info with
    | Some (lg, tx) -> f lg tx
    | None          -> err ()
 
 let xlate f xlate_term = function
-   | ra, na, uri, Abst t ->
-      let f t = f (ra, na, uri, Abst t) in xlate_term f t
-   | ra, na, uri, Abbr t ->
-      let f t = f (ra, na, uri, Abbr t) in xlate_term f t
-   | _, _, _, Void       ->
+   | ra, na, uri, Abst (a, t) ->
+      let f t = f (ra, na, uri, abst a t) in xlate_term f t
+   | ra, na, uri, Abbr (a, t) ->
+      let f t = f (ra, na, uri, abbr a t) in xlate_term f t
+   | _, _, _, Void            ->
       assert false