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, absolute, global *)
13 (* note : experimental *)
18 type bind = Void (* exclusion *)
19 | Abst of term (* abstraction *)
20 | Abbr of term (* abbreviation *)
22 and term = Sort of int (* hierarchy index *)
23 | LRef of int (* location *)
24 | GRef of uri (* reference *)
25 | Cast of term * term (* type, term *)
26 | Appl of term * term (* argument, function *)
27 | Bind of int * id * bind * term (* location, name, binder, scope *)
29 type obj = int * uri * bind (* age, uri, binder, contents *)
31 type item = obj option
33 type context = (int * id * bind) list (* location, name, binder *)
35 type message = (context, term) Log.item list
37 (* Currified constructors ***************************************************)
45 let cast u t = Cast (u, t)
47 let appl u t = Appl (u, t)
49 let bind l id b t = Bind (l, id, b, t)
51 let bind_abst l id u t = Bind (l, id, Abst u, t)
53 let bind_abbr l id v t = Bind (l, id, Abbr v, t)
55 (* location handling functions **********************************************)
59 let new_location () = let loc = !location in incr location; loc
61 let locations () = !location
63 (* context handling functions ***********************************************)
65 let empty_context = []
67 let push msg f es l id b =
68 let rec does_not_occur loc = function
70 | (l, _, _) :: _ when l = loc -> false
71 | _ :: es -> does_not_occur l es
73 if not (does_not_occur l es) then failwith msg else
74 let c = (l, id, b) :: es in f c
76 let append f es1 es2 =
77 f (List.append es2 es1)
82 let contents f es = f es
85 let rec aux = function
87 | (l, id, b) :: tl -> if l = i then f (Some (id, b)) else aux tl