2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
12 (* kernel version: basic, relative, global *)
13 (* note : ufficial basic \lambda\delta version 3 *)
19 type n_attrs = E.node_attrs
20 type b_attrs = E.bind_attrs
22 (* x-reduced abstractions are output by RTM only *)
23 type bind = Void (* *)
24 | Abst of bool * N.layer * term (* x-reduced?, layer, type *)
25 | Abbr of term (* body *)
27 and term = Sort of int (* hierarchy index *)
28 | LRef of n_attrs * int (* attrs, position index *)
29 | GRef of n_attrs * uri (* attrs, reference *)
30 | Cast of term * term (* type, term *)
31 | Appl of bool * term * term (* extended?, argument, function *)
32 | Bind of b_attrs * bind * term (* attrs, binder, scope *)
34 type entity = term E.entity (* attrs, uri, binder *)
37 (* Cons: tail, relative local environment, attrs, binder *)
38 | Cons of lenv * lenv * n_attrs * b_attrs * bind
40 type manager = (N.status -> entity -> bool) * (unit -> unit)
42 (* Currified constructors ***************************************************)
44 let abst r n w = Abst (r, n, w)
48 let lref a i = LRef (a, i)
50 let gref a u = GRef (a, u)
52 let cast u t = Cast (u, t)
54 let appl x u t = Appl (x, u, t)
56 let bind y b t = Bind (y, b, t)
58 let bind_abst r n y u t = Bind (y, Abst (r, n, u), t)
60 let bind_abbr y u t = Bind (y, Abbr u, t)
62 let bind_void y t = Bind (y, Void, t)
64 (* local environment handling functions *************************************)
68 let push e c a y b = Cons (e, c, a, y, b)
70 let rec get e i = match e with
71 | Null -> empty, empty, E.empty_node, E.empty_bind, Void
72 | Cons (e, c, a, y, b) when i = 0 -> e, c, a, y, b
73 | Cons (e, _, _, _, _) -> get e (pred i)
75 (* used in BrgOutput.pp_lenv *)
76 let rec fold_right f map e x = match e with
78 | Cons (e, c, a, y, b) -> fold_right (map f c a y b) map e x
80 let rec mem err f e y0 = match e with
82 | Cons (e, _, _, y, _) ->
83 if y.E.b_name = y0.E.b_name then f () else mem err f e y0