X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fcommon%2Fentity.ml;h=5bef9ff3347524351d62eac91e5cd4c340a5afa1;hb=2e451dca46e509fd7e7772f3d2e438c189ce10a1;hp=4a16c77e73c68dcf849637c35c8eb669442d9e21;hpb=ece36f3adcdf55739b4686168b49506439bff2ba;p=helm.git diff --git a/helm/software/lambda-delta/common/entity.ml b/helm/software/lambda-delta/common/entity.ml index 4a16c77e7..5bef9ff33 100644 --- a/helm/software/lambda-delta/common/entity.ml +++ b/helm/software/lambda-delta/common/entity.ml @@ -21,18 +21,48 @@ type attrs = attr list (* attributes *) type 'term bind = Abst of 'term (* declaration: domain *) | Abbr of 'term (* definition: body *) + | Void (* exclusion *) type 'term entity = attrs * uri * 'term bind (* attrs, name, binder *) -type uri_generator = string -> string (* this could be in CPS *) +type uri_generator = string -> string + +type status = { + delta: bool; (* global delta-expansion *) + rt: bool; (* reference typing *) + si: bool (* sort inclusion *) +} (* helpers ******************************************************************) +let common f (a, u, _) = f a u + let rec name err f = function | Name (n, r) :: _ -> f n r | _ :: tl -> name err f tl | [] -> err () +let names f map l a = + let rec aux f i a = function + | [] -> f a + | Name (n, r) :: tl -> aux (map f i n r) false a tl + | _ :: tl -> aux f i a tl + in + aux f true a l + +let rec get_name err f j = function + | [] -> err () + | Name (n, r) :: _ when j = 0 -> f n r + | Name _ :: tl -> get_name err f (pred j) tl + | _ :: tl -> get_name err f j tl + +let rec get_names f = function + | [] -> f [] [] + | Name _ as n :: tl -> + let f a ns = f a (n :: ns) in get_names f tl + | e :: tl -> + let f a = f (e :: a) in get_names f tl + let rec apix err f = function | Apix i :: _ -> f i | _ :: tl -> apix err f tl @@ -61,3 +91,9 @@ let xlate f xlate_term = function let f t = f (a, uri, Abst t) in xlate_term f t | a, uri, Abbr t -> let f t = f (a, uri, Abbr t) in xlate_term f t + | _, _, Void -> + assert false + +let initial_status si = { + delta = false; rt = false; si = si +}