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 *)
19 type b_attrs = E.bind_attrs
21 type bind = Void (* exclusion *)
22 | Abst of term (* abstraction *)
23 | Abbr of term (* abbreviation *)
25 and term = Sort of int (* hierarchy index *)
26 | LRef of P.mark (* location *)
27 | GRef of uri (* reference *)
28 | Cast of term * term (* domain, element *)
29 | Appl of term * term (* argument, function *)
30 | Bind of b_attrs * P.mark * bind * term (* name, location, binder, scope *)
32 type entity = term E.entity (* attrs, uri, binder *)
34 type lenv = (b_attrs * P.mark * bind) list (* name, location, binder *)
36 type message = (lenv, term) Log.item list
38 (* Currified constructors ***************************************************)
46 let cast u t = Cast (u, t)
48 let appl u t = Appl (u, t)
50 let bind y l b t = Bind (y, l, b, t)
52 let bind_abst y l u t = Bind (y, l, Abst u, t)
54 let bind_abbr y l v t = Bind (y, l, Abbr v, t)
56 (* local environment handling functions *************************************)
60 let push msg f es y l b =
61 let rec does_not_occur loc = function
63 | (_, l, _) :: _ when l = loc -> false
64 | _ :: es -> does_not_occur l es
66 if not (does_not_occur l es) then failwith msg else
67 let c = (y, l, b) :: es in f c
69 let append f es1 es2 =
70 f (List.append es2 es1)
75 let contents f es = f es
78 let rec aux = function
80 | (y, l, b) :: tl -> if l = i then f y b else aux tl
85 let rec aux n = function
87 | (_, l, _) :: _ when l = loc -> f n
88 | _ :: e -> aux (succ n) e