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
70 | `Elim of sort (** elimination principle; if sort is Type, the universe is
72 | `Record of (string * bool) list (**
73 inductive type that encodes a record; the arguments are
74 the record fields names and if they are coercions *)
75 | `Projection (** record projection *)
79 [ `Class of object_class
80 | `Flavour of object_flavour
85 Rel of int (* DeBrujin index, 1 based*)
86 | Var of UriManager.uri * (* uri, *)
87 term explicit_named_substitution (* explicit named subst. *)
88 | Meta of int * (term option) list (* numeric id, *)
90 | Sort of sort (* sort *)
91 | Implicit of implicit_annotation option (* *)
92 | Cast of term * term (* value, type *)
93 | Prod of name * term * term (* binder, source, target *)
94 | Lambda of name * term * term (* binder, source, target *)
95 | LetIn of name * term * term (* binder, term, target *)
96 | Appl of term list (* arguments *)
97 | Const of UriManager.uri * (* uri, *)
98 term explicit_named_substitution (* explicit named subst. *)
99 | MutInd of UriManager.uri * int * (* uri, typeno, *)
100 term explicit_named_substitution (* explicit named subst. *)
101 (* typeno is 0 based *)
102 | MutConstruct of UriManager.uri * (* uri, *)
103 int * int * (* typeno, consno *)
104 term explicit_named_substitution (* explicit named subst. *)
105 (* typeno is 0 based *)
106 (* consno is 1 based *)
107 | MutCase of UriManager.uri * (* ind. uri, *)
108 int * (* ind. typeno, *)
109 term * term * (* outtype, ind. term *)
110 term list (* patterns *)
111 | Fix of int * inductiveFun list (* funno (0 based), funs *)
112 | CoFix of int * coInductiveFun list (* funno (0 based), funs *)
114 Constant of string * term option * term * (* id, body, type, *)
115 UriManager.uri list * attribute list (* parameters *)
116 | Variable of string * term option * term * (* name, body, type *)
117 UriManager.uri list * attribute list (* parameters *)
118 | CurrentProof of string * metasenv * term * (* name, conjectures, body, *)
119 term * UriManager.uri list * attribute list (* type, parameters *)
120 | InductiveDefinition of inductiveType list * (* inductive types, *)
121 UriManager.uri list * int * attribute list (* params, left params no *)
123 string * bool * term * (* typename, inductive, arity *)
124 constructor list (* constructors *)
126 string * term (* id, type *)
128 string * int * term * term (* name, ind. index, type, body *)
130 string * term * term (* name, type, body *)
132 (* a metasenv is a list of declarations of metas in declarations *)
133 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
134 (* depend on new ones. *)
135 and conjecture = int * context * term
136 and metasenv = conjecture list
137 and substitution = (int * (context * term * term)) list
141 (* a metasenv is a list of declarations of metas in declarations *)
142 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
143 (* depend on new ones. *)
144 and annconjecture = id * int * anncontext * annterm
145 and annmetasenv = annconjecture list
148 ARel of id * id * int * (* idref, DeBrujin index, *)
150 | AVar of id * UriManager.uri * (* uri, *)
151 annterm explicit_named_substitution (* explicit named subst. *)
152 | AMeta of id * int * (annterm option) list (* numeric id, *)
154 | ASort of id * sort (* sort *)
155 | AImplicit of id * implicit_annotation option (* *)
156 | ACast of id * annterm * annterm (* value, type *)
157 | AProd of id * name * annterm * annterm (* binder, source, target *)
158 | ALambda of id * name * annterm * annterm (* binder, source, target *)
159 | ALetIn of id * name * annterm * annterm (* binder, term, target *)
160 | AAppl of id * annterm list (* arguments *)
161 | AConst of id * UriManager.uri * (* uri, *)
162 annterm explicit_named_substitution (* explicit named subst. *)
163 | AMutInd of id * UriManager.uri * int * (* uri, typeno *)
164 annterm explicit_named_substitution (* explicit named subst. *)
165 (* typeno is 0 based *)
166 | AMutConstruct of id * UriManager.uri * (* uri, *)
167 int * int * (* typeno, consno *)
168 annterm explicit_named_substitution (* explicit named subst. *)
169 (* typeno is 0 based *)
170 (* consno is 1 based *)
171 | AMutCase of id * UriManager.uri * (* ind. uri, *)
172 int * (* ind. typeno, *)
173 annterm * annterm * (* outtype, ind. term *)
174 annterm list (* patterns *)
175 | AFix of id * int * anninductiveFun list (* funno, functions *)
176 | ACoFix of id * int * anncoInductiveFun list (* funno, functions *)
178 AConstant of id * id option * string * (* name, *)
179 annterm option * annterm * (* body, type, *)
180 UriManager.uri list * attribute list (* parameters *)
182 string * annterm option * annterm * (* name, body, type *)
183 UriManager.uri list * attribute list (* parameters *)
184 | ACurrentProof of id * id *
185 string * annmetasenv * (* name, conjectures, *)
186 annterm * annterm * UriManager.uri list * (* body,type,parameters *)
188 | AInductiveDefinition of id *
189 anninductiveType list * (* inductive types , *)
190 UriManager.uri list * int * attribute list (* parameters,n ind. pars*)
191 and anninductiveType =
192 id * string * bool * annterm * (* typename, inductive, arity *)
193 annconstructor list (* constructors *)
195 string * annterm (* id, type *)
196 and anninductiveFun =
197 id * string * int * annterm * annterm (* name, ind. index, type, body *)
198 and anncoInductiveFun =
199 id * string * annterm * annterm (* name, type, body *)
203 and context_entry = (* A declaration or definition *)
205 | Def of term * term option (* body, type (if known) *)
208 (name * context_entry) option (* None means no more accessible *)
210 and context = hypothesis list
212 and anncontext_entry = (* A declaration or definition *)
217 id * (name * anncontext_entry) option (* None means no more accessible *)
219 and anncontext = annhypothesis list
223 context -> metasenv -> CicUniv.universe_graph ->
224 term * metasenv * CicUniv.universe_graph
227 Object of annobj (* if annobj is a Constant, this is its type *)
228 | ConstantBody of annobj
230 | Conjecture of annconjecture
231 | Hypothesis of annhypothesis
238 let hash = Hashtbl.hash_param 100 1000