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_______________________________________________________________ *)
17 type id = string (* identifier *)
19 type name = id * bool (* token, real? *)
21 type arity = int * int (* sort, degree *)
23 type meta = Main (* main object *)
24 | InProp (* inhabitant of a proposition *)
25 | Progress (* uncompleted object *)
26 | Private (* private global definition *)
29 n_apix: int; (* additional position index *)
33 b_name: name option; (* name *)
34 b_main: arity; (* main arity *)
35 b_side: arity; (* side arity *)
39 r_meta: meta list; (* metaliguistic classification *)
40 r_info: (string * string) option; (* metaliguistic annotation: language (defaults to "en-US"), text *)
43 type 'term bind = Abst of 'term (* declaration: domain *)
44 | Abbr of 'term (* definition: body *)
45 | Void (* exclusion *)
47 type 'term entity = root_attrs * node_attrs * uri * 'term bind (* attrs, uri, binder *)
49 (* helpers ******************************************************************)
51 let node_attrs ?(apix=0) () = {
55 let bind_attrs ?name ?(main=(0,0)) ?(side=(0,0)) () = {
56 b_name = name; b_main = main; b_side = side;
59 let root_attrs ?(meta=[]) ?info () = {
60 r_meta = meta; r_info = info;
63 let empty_node = node_attrs ()
65 let empty_bind = bind_attrs ()
67 let empty_root = root_attrs ()
69 let common f (ra, na, u, _) = f ra na u
71 let succ (sort, degr) = sort, succ degr
73 let compose av at = {av with b_main = at.b_main}
75 let shift av = {av with b_side = av.b_main}
77 let rec name err f a = match a.b_name with
78 | Some (n, r) -> f n r
81 let rec info err f a = match a.r_info with
82 | Some (lg, tx) -> f lg tx
85 let xlate f xlate_term = function
86 | ra, na, uri, Abst t ->
87 let f t = f (ra, na, uri, Abst t) in xlate_term f t
88 | ra, na, uri, Abbr t ->
89 let f t = f (ra, na, uri, Abbr t) in xlate_term f t