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 * 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 *)
80 [ `Class of object_class
81 | `Flavour of object_flavour
86 Rel of int (* DeBrujin index, 1 based*)
87 | Var of UriManager.uri * (* uri, *)
88 term explicit_named_substitution (* explicit named subst. *)
89 | Meta of int * (term option) list (* numeric id, *)
91 | Sort of sort (* sort *)
92 | Implicit of implicit_annotation option (* *)
93 | Cast of term * term (* value, type *)
94 | Prod of name * term * term (* binder, source, target *)
95 | Lambda of name * term * term (* binder, source, target *)
96 | LetIn of name * term * term (* binder, term, target *)
97 | Appl of term list (* arguments *)
98 | Const of UriManager.uri * (* uri, *)
99 term explicit_named_substitution (* explicit named subst. *)
100 | MutInd of UriManager.uri * int * (* uri, typeno, *)
101 term explicit_named_substitution (* explicit named subst. *)
102 (* typeno is 0 based *)
103 | MutConstruct of UriManager.uri * (* uri, *)
104 int * int * (* typeno, consno *)
105 term explicit_named_substitution (* explicit named subst. *)
106 (* typeno is 0 based *)
107 (* consno is 1 based *)
108 | MutCase of UriManager.uri * (* ind. uri, *)
109 int * (* ind. typeno, *)
110 term * term * (* outtype, ind. term *)
111 term list (* patterns *)
112 | Fix of int * inductiveFun list (* funno (0 based), funs *)
113 | CoFix of int * coInductiveFun list (* funno (0 based), funs *)
115 Constant of string * term option * term * (* id, body, type, *)
116 UriManager.uri list * attribute list (* parameters *)
117 | Variable of string * term option * term * (* name, body, type *)
118 UriManager.uri list * attribute list (* parameters *)
119 | CurrentProof of string * metasenv * term * (* name, conjectures, body, *)
120 term * UriManager.uri list * attribute list (* type, parameters *)
121 | InductiveDefinition of inductiveType list * (* inductive types, *)
122 UriManager.uri list * int * attribute list (* params, left params no *)
124 string * bool * term * (* typename, inductive, arity *)
125 constructor list (* constructors *)
127 string * term (* id, type *)
129 string * int * term * term (* name, ind. index, type, body *)
131 string * term * term (* name, type, body *)
133 (* a metasenv is a list of declarations of metas in declarations *)
134 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
135 (* depend on new ones. *)
136 and conjecture = int * context * term
137 and metasenv = conjecture list
138 and substitution = (int * (context * term * term)) list
142 (* a metasenv is a list of declarations of metas in declarations *)
143 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
144 (* depend on new ones. *)
145 and annconjecture = id * int * anncontext * annterm
146 and annmetasenv = annconjecture list
149 ARel of id * id * int * (* idref, DeBrujin index, *)
151 | AVar of id * UriManager.uri * (* uri, *)
152 annterm explicit_named_substitution (* explicit named subst. *)
153 | AMeta of id * int * (annterm option) list (* numeric id, *)
155 | ASort of id * sort (* sort *)
156 | AImplicit of id * implicit_annotation option (* *)
157 | ACast of id * annterm * annterm (* value, type *)
158 | AProd of id * name * annterm * annterm (* binder, source, target *)
159 | ALambda of id * name * annterm * annterm (* binder, source, target *)
160 | ALetIn of id * name * annterm * annterm (* binder, term, target *)
161 | AAppl of id * annterm list (* arguments *)
162 | AConst of id * UriManager.uri * (* uri, *)
163 annterm explicit_named_substitution (* explicit named subst. *)
164 | AMutInd of id * UriManager.uri * int * (* uri, typeno *)
165 annterm explicit_named_substitution (* explicit named subst. *)
166 (* typeno is 0 based *)
167 | AMutConstruct of id * UriManager.uri * (* uri, *)
168 int * int * (* typeno, consno *)
169 annterm explicit_named_substitution (* explicit named subst. *)
170 (* typeno is 0 based *)
171 (* consno is 1 based *)
172 | AMutCase of id * UriManager.uri * (* ind. uri, *)
173 int * (* ind. typeno, *)
174 annterm * annterm * (* outtype, ind. term *)
175 annterm list (* patterns *)
176 | AFix of id * int * anninductiveFun list (* funno, functions *)
177 | ACoFix of id * int * anncoInductiveFun list (* funno, functions *)
179 AConstant of id * id option * string * (* name, *)
180 annterm option * annterm * (* body, type, *)
181 UriManager.uri list * attribute list (* parameters *)
183 string * annterm option * annterm * (* name, body, type *)
184 UriManager.uri list * attribute list (* parameters *)
185 | ACurrentProof of id * id *
186 string * annmetasenv * (* name, conjectures, *)
187 annterm * annterm * UriManager.uri list * (* body,type,parameters *)
189 | AInductiveDefinition of id *
190 anninductiveType list * (* inductive types , *)
191 UriManager.uri list * int * attribute list (* parameters,n ind. pars*)
192 and anninductiveType =
193 id * string * bool * annterm * (* typename, inductive, arity *)
194 annconstructor list (* constructors *)
196 string * annterm (* id, type *)
197 and anninductiveFun =
198 id * string * int * annterm * annterm (* name, ind. index, type, body *)
199 and anncoInductiveFun =
200 id * string * annterm * annterm (* name, type, body *)
204 and context_entry = (* A declaration or definition *)
206 | Def of term * term option (* body, type (if known) *)
209 (name * context_entry) option (* None means no more accessible *)
211 and context = hypothesis list
213 and anncontext_entry = (* A declaration or definition *)
218 id * (name * anncontext_entry) option (* None means no more accessible *)
220 and anncontext = annhypothesis list
224 context -> metasenv -> CicUniv.universe_graph ->
225 term * metasenv * CicUniv.universe_graph
228 Object of annobj (* if annobj is a Constant, this is its type *)
229 | ConstantBody of annobj
231 | Conjecture of annconjecture
232 | Hypothesis of annhypothesis
239 let hash = Hashtbl.hash_param 100 1000