1 (* Copyright (C) 2000, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (*****************************************************************************)
30 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
33 (* This module defines the internal representation of the objects (variables,*)
34 (* blocks of (co)inductive definitions and constants) and the terms of cic *)
36 (*****************************************************************************)
40 (* STUFF TO MANAGE IDENTIFIERS *)
41 type id = string (* the abstract type of the (annotated) node identifiers *)
42 type 'term explicit_named_substitution = (UriManager.uri * 'term) list
44 type implicit_annotation = [ `Closed | `Type | `Hole ]
46 (* INTERNAL REPRESENTATION OF CIC OBJECTS AND TERMS *)
51 | Type of CicUniv.universe
52 | CProp of CicUniv.universe
70 [ `Elim of sort (** elimination principle; if sort is Type, the universe is
72 | `Record of (string * bool * int) list (**
73 inductive type that encodes a record; the arguments are
74 the record fields names and if they are coercions and
75 then the coercion arity *)
76 | `Projection (** record projection *)
77 | `InversionPrinciple (** inversion principle *)
81 [ `Class of object_class
82 | `Flavour of object_flavour
87 Rel of int (* DeBrujin index, 1 based*)
88 | Var of UriManager.uri * (* uri, *)
89 term explicit_named_substitution (* explicit named subst. *)
90 | Meta of int * (term option) list (* numeric id, *)
92 | Sort of sort (* sort *)
93 | Implicit of implicit_annotation option (* *)
94 | Cast of term * term (* value, type *)
95 | Prod of name * term * term (* binder, source, target *)
96 | Lambda of name * term * term (* binder, source, target *)
97 | LetIn of name * term * term * term (* binder, term, type, target *)
98 | Appl of term list (* arguments *)
99 | Const of UriManager.uri * (* uri, *)
100 term explicit_named_substitution (* explicit named subst. *)
101 | MutInd of UriManager.uri * int * (* uri, typeno, *)
102 term explicit_named_substitution (* explicit named subst. *)
103 (* typeno is 0 based *)
104 | MutConstruct of UriManager.uri * (* uri, *)
105 int * int * (* typeno, consno *)
106 term explicit_named_substitution (* explicit named subst. *)
107 (* typeno is 0 based *)
108 (* consno is 1 based *)
109 | MutCase of UriManager.uri * (* ind. uri, *)
110 int * (* ind. typeno, *)
111 term * term * (* outtype, ind. term *)
112 term list (* patterns *)
113 | Fix of int * inductiveFun list (* funno (0 based), funs *)
114 | CoFix of int * coInductiveFun list (* funno (0 based), funs *)
116 Constant of string * term option * term * (* id, body, type, *)
117 UriManager.uri list * attribute list (* parameters *)
118 | Variable of string * term option * term * (* name, body, type *)
119 UriManager.uri list * attribute list (* parameters *)
120 | CurrentProof of string * metasenv * term * (* name, conjectures, body, *)
121 term * UriManager.uri list * attribute list (* type, parameters *)
122 | InductiveDefinition of inductiveType list * (* inductive types, *)
123 UriManager.uri list * int * attribute list (* params, left params no *)
125 string * bool * term * (* typename, inductive, arity *)
126 constructor list (* constructors *)
128 string * term (* id, type *)
130 string * int * term * term (* name, ind. index, type, body *)
132 string * term * term (* name, type, body *)
134 (* a metasenv is a list of declarations of metas in declarations *)
135 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
136 (* depend on new ones. *)
137 and conjecture = int * context * term
138 and metasenv = conjecture list
139 and substitution = (int * (context * term * term)) list
143 (* a metasenv is a list of declarations of metas in declarations *)
144 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
145 (* depend on new ones. *)
146 and annconjecture = id * int * anncontext * annterm
147 and annmetasenv = annconjecture list
150 ARel of id * id * int * (* idref, DeBrujin index, *)
152 | AVar of id * UriManager.uri * (* uri, *)
153 annterm explicit_named_substitution (* explicit named subst. *)
154 | AMeta of id * int * (annterm option) list (* numeric id, *)
156 | ASort of id * sort (* sort *)
157 | AImplicit of id * implicit_annotation option (* *)
158 | ACast of id * annterm * annterm (* value, type *)
159 | AProd of id * name * annterm * annterm (* binder, source, target *)
160 | ALambda of id * name * annterm * annterm (* binder, source, target *)
161 | ALetIn of id * name * annterm * annterm * annterm (* binder, term, type, target *)
162 | AAppl of id * annterm list (* arguments *)
163 | AConst of id * UriManager.uri * (* uri, *)
164 annterm explicit_named_substitution (* explicit named subst. *)
165 | AMutInd of id * UriManager.uri * int * (* uri, typeno *)
166 annterm explicit_named_substitution (* explicit named subst. *)
167 (* typeno is 0 based *)
168 | AMutConstruct of id * UriManager.uri * (* uri, *)
169 int * int * (* typeno, consno *)
170 annterm explicit_named_substitution (* explicit named subst. *)
171 (* typeno is 0 based *)
172 (* consno is 1 based *)
173 | AMutCase of id * UriManager.uri * (* ind. uri, *)
174 int * (* ind. typeno, *)
175 annterm * annterm * (* outtype, ind. term *)
176 annterm list (* patterns *)
177 | AFix of id * int * anninductiveFun list (* funno, functions *)
178 | ACoFix of id * int * anncoInductiveFun list (* funno, functions *)
180 AConstant of id * id option * string * (* name, *)
181 annterm option * annterm * (* body, type, *)
182 UriManager.uri list * attribute list (* parameters *)
184 string * annterm option * annterm * (* name, body, type *)
185 UriManager.uri list * attribute list (* parameters *)
186 | ACurrentProof of id * id *
187 string * annmetasenv * (* name, conjectures, *)
188 annterm * annterm * UriManager.uri list * (* body,type,parameters *)
190 | AInductiveDefinition of id *
191 anninductiveType list * (* inductive types , *)
192 UriManager.uri list * int * attribute list (* parameters,n ind. pars*)
193 and anninductiveType =
194 id * string * bool * annterm * (* typename, inductive, arity *)
195 annconstructor list (* constructors *)
197 string * annterm (* id, type *)
198 and anninductiveFun =
199 id * string * int * annterm * annterm (* name, ind. index, type, body *)
200 and anncoInductiveFun =
201 id * string * annterm * annterm (* name, type, body *)
205 and context_entry = (* A declaration or definition *)
207 | Def of term * term (* body, type *)
210 (name * context_entry) option (* None means no more accessible *)
212 and context = hypothesis list
214 and anncontext_entry = (* A declaration or definition *)
216 | ADef of annterm * annterm
219 id * (name * anncontext_entry) option (* None means no more accessible *)
221 and anncontext = annhypothesis list
225 context -> metasenv -> CicUniv.universe_graph ->
226 term * metasenv * CicUniv.universe_graph
229 Object of annobj (* if annobj is a Constant, this is its type *)
230 | ConstantBody of annobj
232 | Conjecture of annconjecture
233 | Hypothesis of annhypothesis
240 let hash = Hashtbl.hash_param 100 1000