X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fdual_rg%2Fdrg.ml;h=d4402961545511105cbbc3c7aa11af45ffd10f3a;hb=3d23faf2969e2591db93f8bacc61952f3b66e2ca;hp=1d94a26437708f409a98f2a5520097554471fd0a;hpb=a9f15ca61aac8089fb4b599af72533c4a432ba7b;p=helm.git diff --git a/helm/software/lambda-delta/dual_rg/drg.ml b/helm/software/lambda-delta/dual_rg/drg.ml index 1d94a2643..d44029615 100644 --- a/helm/software/lambda-delta/dual_rg/drg.ml +++ b/helm/software/lambda-delta/dual_rg/drg.ml @@ -14,52 +14,43 @@ type uri = Entity.uri type id = Entity.id +type attrs = Entity.attrs -type attr = Name of id * bool (* name, real? *) - | Priv (* private global definition *) +type bind = Abst of term list (* domains *) + | Abbr of term list (* bodies *) + | Void of int (* number of exclusions *) -type attrs = attr list (* attributes *) +and term = TSort of attrs * int (* attrs, hierarchy index *) + | TLRef of attrs * int * int (* attrs, position indexes *) + | TGRef of attrs * uri (* attrs, reference *) + | TCast of attrs * term * term (* attrs, domain, element *) + | TAppl of attrs * term list * term (* attrs, arguments, function *) + | TProj of attrs * lenv * term (* attrs, closure, member *) + | TBind of attrs * bind * term (* attrs, binder, scope *) -type bind = Abst of attrs * term (* attrs, domain *) - | Abbr of attrs * term (* attrs, body *) - | Void of attrs (* attrs *) +and lenv = ESort (* top *) + | EProj of lenv * attrs * lenv (* environment, attrs, closure *) + | EBind of lenv * attrs * bind (* environment, attrs, binder *) -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, domain, element *) - | Proj of attrs * lenv * term (* attrs, closure, scope *) - | Appl of attrs * term list * term (* attrs, arguments, function *) - | Bind of bind * term (* binder, scope *) - -and lenv = bind list (* local environment *) - -type entry = bind Entity.entry (* age, uri, binder *) - -type entity = bind Entity.entity +type entity = term Entity.entity (* helpers ******************************************************************) -let mk_uri root f s = - let str = String.concat "/" ["ld:"; "drg"; root; s ^ ".ld"] in - f str +let mk_uri root s = + String.concat "/" ["ld:"; "drg"; root; s ^ ".ld"] -let rec name_of err f = function - | Name (n, r) :: _ -> f n r - | _ :: tl -> name_of err f tl - | [] -> err () +let empty_lenv = ESort -let name_of_binder err f = function - | Abst (a, _) -> name_of err f a - | Abbr (a, _) -> name_of err f a - | Void a -> name_of err f a +let push f lenv a b = f (EBind (lenv, a, b)) +(* this id not tail recursive *) let resolve_lref err f id lenv = - let rec aux f i = function - | [] -> err () - | b :: tl -> - let err () = aux f (succ i) tl in - let f name _ = if name = id then f i else err () in - name_of_binder err f b + let rec aux f i k = function + | ESort -> err () + | EBind (tl, a, _) -> + let err kk = aux f (succ i) (k + kk) tl in + let f j = f i j k in + Entity.resolve err f id a + | EProj _ -> assert false (* TODO *) in - aux f 0 lenv + aux f 0 0 lenv