(* ||M|| This file is part of HELM, an Hypertextual, Electronic ||A|| Library of Mathematics, developed at the Computer Science ||T|| Department, University of Bologna, Italy. ||I|| ||T|| HELM is free software; you can redistribute it and/or ||A|| modify it under the terms of the GNU General Public License \ / version 2 or (at your option) any later version. \ / This software is distributed as is, NO WARRANTY. V_______________________________________________________________ *) (* kernel version: basic, relative, global *) (* note : ufficial basic \lambda\delta version 3 *) module N = Layer module E = Entity type uri = E.uri type attrs = E.node_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 *) type entity = term E.entity (* attrs, uri, binder *) type lenv = Null (* Cons: tail, relative local environment, attrs, binder *) | Cons of lenv * lenv * attrs * bind type manager = (N.status -> entity -> bool) * (unit -> unit) (* Currified constructors ***************************************************) let abst x n w = Abst (x, n, 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 x n a u t = Bind (a, Abst (x, n, u), t) let bind_abbr a u t = Bind (a, Abbr u, 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 -> 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 get e i = get i e (* 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 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