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 attrs = E.node_attrs
21 (* x-reduced abstractions are output by RTM only *)
22 type bind = Void (* *)
23 | Abst of bool * N.layer * term (* x-reduced?, layer, type *)
24 | Abbr of term (* body *)
26 and term = Sort of attrs * int (* attrs, hierarchy index *)
27 | LRef of attrs * int (* attrs, position index *)
28 | GRef of attrs * uri (* attrs, reference *)
29 | Cast of attrs * term * term (* attrs, type, term *)
30 | Appl of attrs * bool * term * term (* attrs, extended?, argument, function *)
31 | Bind of attrs * bind * term (* attrs, binder, scope *)
33 type entity = term E.entity (* attrs, uri, binder *)
36 (* Cons: tail, relative local environment, attrs, binder *)
37 | Cons of lenv * lenv * attrs * bind
39 type manager = (N.status -> entity -> bool) * (unit -> unit)
41 (* Currified constructors ***************************************************)
43 let abst r n w = Abst (r, n, w)
47 let lref a i = LRef (a, i)
49 let gref a u = GRef (a, u)
51 let cast a u t = Cast (a, u, t)
53 let appl a x u t = Appl (a, x, u, t)
55 let bind a b t = Bind (a, b, t)
57 let bind_abst r n a u t = Bind (a, Abst (r, n, u), t)
59 let bind_abbr a u t = Bind (a, Abbr u, t)
61 let bind_void a t = Bind (a, Void, t)
63 (* local environment handling functions *************************************)
67 let push e c a b = Cons (e, c, a, b)
69 let rec get i = function
70 | Null -> empty, empty, E.empty_node, Void
71 | Cons (e, c, a, b) when i = 0 -> e, c, a, b
72 | Cons (e, _, _, _) -> get (pred i) e
76 (* used in BrgOutput.pp_lenv *)
77 let rec fold_right f map e x = match e with
79 | Cons (e, c, a, b) -> fold_right (map f c a b) map e x
81 let rec mem err f e b = match e with
83 | Cons (e, _, a, _) ->
84 if a.E.n_name = b.E.n_name then f () else mem err f e b