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 a_attrs = E.appl_attrs
21 type b_attrs = E.bind_attrs
23 (* x-reduced abstractions are output by RTM only *)
24 type bind = Void (* *)
25 | Abst of bool * N.layer * term (* x-reduced?, layer, type *)
26 | Abbr of term (* body *)
28 and term = Sort of int (* hierarchy index *)
29 | LRef of n_attrs * int (* attrs, position index *)
30 | GRef of n_attrs * uri (* attrs, reference *)
31 | Cast of term * term (* type, term *)
32 | Appl of a_attrs * term * term (* attrs, argument, function *)
33 | Bind of b_attrs * bind * term (* attrs, binder, scope *)
35 type entity = term E.entity (* attrs, uri, binder *)
38 (* Cons: tail, relative local environment, attrs, binder *)
39 | Cons of lenv * lenv * n_attrs * b_attrs * bind
41 type manager = (N.status -> entity -> bool) * (unit -> unit)
43 (* Currified constructors ***************************************************)
45 let abst r n w = Abst (r, n, w)
49 let lref a i = LRef (a, i)
51 let gref a u = GRef (a, u)
53 let cast u t = Cast (u, t)
55 let appl a u t = Appl (a, u, t)
57 let bind y b t = Bind (y, b, t)
59 let bind_abst r n y u t = Bind (y, Abst (r, n, u), t)
61 let bind_abbr y u t = Bind (y, Abbr u, t)
63 let bind_void y t = Bind (y, Void, t)
65 (* local environment handling functions *************************************)
69 let push e c a y b = Cons (e, c, a, y, b)
71 let rec get e i = match e with
72 | Null -> empty, empty, E.empty_node, E.empty_bind, Void
73 | Cons (e, c, a, y, b) when i = 0 -> e, c, a, y, b
74 | Cons (e, _, _, _, _) -> get e (pred i)
76 let rec mem err f e y0 = match e with
78 | Cons (e, _, _, y, _) ->
79 if y.E.b_name = y0.E.b_name then f () else mem err f e y0
81 (* used in BrgOutput.pp_lenv *)
82 let rec fold_right f map e x = match e with
84 | Cons (e, c, a, y, b) -> fold_right (map f c a y b) map e x
86 (* used in BrgCC.output_entity_cc0 *)
87 let rec fold_left map x e = match e with
89 | Cons (e, c, a, y, b) -> fold_left map (map x c a y b) e