X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fsoftware%2Flambda-delta%2Fbasic_rg%2Fbrg.ml;h=fd93f397af56bf450ce8ef1452697f004ce7b3e5;hb=a22628e5de37d3ffe9de056d7683f2ebdf7226fb;hp=36e4fefe811adb1228d84443c76b4302fb1b17ac;hpb=f3b4d265268a43ca98e6843b733109fdfe3f6b0b;p=helm.git diff --git a/helm/software/lambda-delta/basic_rg/brg.ml b/helm/software/lambda-delta/basic_rg/brg.ml index 36e4fefe8..fd93f397a 100644 --- a/helm/software/lambda-delta/basic_rg/brg.ml +++ b/helm/software/lambda-delta/basic_rg/brg.ml @@ -9,28 +9,74 @@ \ / This software is distributed as is, NO WARRANTY. V_______________________________________________________________ *) -type uri = NUri.uri -type id = Aut.id +(* kernel version: basic, relative, global *) +(* note : ufficial basic lambda-delta *) -type bind = Abst | Abbr (* abstraction, abbreviation *) +type uri = Entity.uri +type id = Entity.id +type attrs = Entity.attrs -type term = Sort of int (* hierarchy index *) - | LRef of int (* reverse de Bruijn index *) - | GRef of uri (* reference *) - | Cast of term * term (* type, term *) - | Appl of term * term (* argument, function *) - | Bind of id * bind * term * term (* name, binder, content, scope *) +type bind = Void (* *) + | Abst of term (* type *) + | Abbr of term (* body *) -type obj = int * uri * bind * term (* age, uri, binder, contents *) +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 *) -type item = obj option +type entity = term Entity.entity (* attrs, uri, binder *) -type hierarchy = int -> int +type lenv = Null +(* Cons: tail, relative local environment, attrs, binder *) + | Cons of lenv * lenv * attrs * bind + +(* helpers ******************************************************************) + +let mk_uri root s = + String.concat "/" ["ld:"; "brg"; root; s ^ ".ld"] (* Currified constructors ***************************************************) -let cast u t = Cast (u, t) +let abst w = Abst w + +let abbr v = Abbr v + +let lref a i = LRef (a, i) + +let cast a u t = Cast (a, u, t) + +let appl a u t = Appl (a, u, t) + +let bind a b t = Bind (a, b, t) + +let bind_abst a u t = Bind (a, Abst u, t) + +let bind_abbr a v t = Bind (a, Abbr v, t) + +let bind_void a t = Bind (a, Void, t) + +(* local environment handling functions *************************************) + +let empty = Null + +let push e c a b = Cons (e, c, a, b) + +let rec get i = function + | Null -> Null, Null, [], Void + | Cons (e, c, a, b) when i = 0 -> e, c, a, b + | Cons (e, _, _, _) -> get (pred i) e + +let get e i = get i e -let appl u t = Appl (u, t) +(* 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 e c a b) map e x -let bind id b u t = Bind (id, b, u, t) +(* used in MetaBrg.unwind_to_xlate_term *) +let rec fold_left map x = function + | Null -> x + | Cons (e, _, a, b) -> fold_left map (map x a b) e