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_______________________________________________________________ *)
18 type id = string (* identifier *)
20 type name = id * bool (* token, real? *)
22 type names = name list
24 type attr = Name of name (* name *)
25 | Apix of int (* additional position index *)
26 | Mark of int (* node marker *)
27 | Meta of string (* metaliguistic annotation *)
28 | Priv (* private global definition *)
30 type attrs = attr list (* attributes *)
32 type 'term bind = Abst of N.level * 'term (* declaration: level, domain *)
33 | Abbr of 'term (* definition: body *)
34 | Void (* exclusion *)
36 type 'term entity = attrs * uri * 'term bind (* attrs, name, binder *)
39 delta: bool; (* global delta-expansion *)
40 rt: bool; (* reference typing *)
41 si: bool; (* sort inclusion *)
42 expand: bool (* always expand global definitions *)
45 (* helpers ******************************************************************)
47 let common f (a, u, _) = f a u
49 let rec name err f = function
50 | Name (n, r) :: _ -> f n r
51 | _ :: tl -> name err f tl
55 let rec aux f i a = function
57 | Name (n, r) :: tl -> aux (map f i n r) false a tl
58 | _ :: tl -> aux f i a tl
62 let rec get_name err f j = function
64 | Name (n, r) :: _ when j = 0 -> f n r
65 | Name _ :: tl -> get_name err f (pred j) tl
66 | _ :: tl -> get_name err f j tl
68 let rec get_names f = function
70 | Name _ as n :: tl ->
71 let f a ns = f a (n :: ns) in get_names f tl
73 let f a = f (e :: a) in get_names f tl
76 let rec aux k = function
78 | Name _ :: tl -> aux (succ k) tl
83 let rec apix err f = function
85 | _ :: tl -> apix err f tl
88 let rec mark err f = function
90 | _ :: tl -> mark err f tl
93 let rec priv err f = function
95 | _ :: tl -> priv err f tl
98 let rec meta err f = function
100 | _ :: tl -> meta err f tl
103 let resolve err f name a =
104 let rec aux i = function
105 | Name (n, true) :: _ when n = name -> f i
106 | _ :: tl -> aux (succ i) tl
111 let rec rev_append_names ns = function
113 | Name n :: tl -> rev_append_names (n :: ns) tl
114 | _ :: tl -> rev_append_names ns tl
116 let xlate f xlate_term = function
117 | a, uri, Abst (n, t) ->
118 let f t = f (a, uri, Abst (n, t)) in xlate_term f t
120 let f t = f (a, uri, Abbr t) in xlate_term f t
124 let initial_status () = {
125 delta = false; rt = false; si = !G.si; expand = !G.expand
128 let refresh_status st = {st with
129 si = !G.si; expand = !G.expand