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 *)
18 type bind = Void (* exclusion *)
19 | Abst of term (* abstraction *)
20 | Abbr of term (* abbreviation *)
22 and term = Sort of attrs * int (* attrs, hierarchy index *)
23 | LRef of attrs * int (* attrs, position index *)
24 | GRef of attrs * uri (* attrs, reference *)
25 | Cast of attrs * term * term (* attrs, type, term *)
26 | Appl of attrs * term * term (* attrs, argument, function *)
27 | Bind of attrs * bind * term (* attrs, binder, scope *)
29 and attr = Name of bool * id (* real?, name *)
30 | Entry of int * bind (* age, binder *)
34 type obj = int * uri * bind (* age, uri, binder, contents *)
36 type item = obj option
38 type context = (attrs * bind) list (* attrs, binder *)
40 type message = (context, term) Log.item list
42 (* Currified constructors ***************************************************)
48 let lref a i = LRef (a, i)
50 let cast a u t = Cast (a, u, t)
52 let appl a u t = Appl (a, u, t)
54 let bind a b t = Bind (a, b, t)
56 let bind_abst a u t = Bind (a, Abst u, t)
58 let bind_abbr a v t = Bind (a, Abbr v, t)
60 (* context handling functions ***********************************************)
62 let empty_context = []
65 let c = (a, b) :: es in f c
67 let append f es1 es2 =
68 f (List.append es2 es1)
73 let contents f es = f es
76 let rec aux e i = function
79 if i = 0 then f e (Some hd) else
80 let e = match hd with _, Abst _ -> succ e | _ -> e in
85 let rec name f = function
87 | Name (r, n) :: _ -> f (Some (r, n))
88 | _ :: tl -> name f tl