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 (*****************************************************************************)
38 (* STUFF TO MANAGE IDENTIFIERS *)
39 type id = string (* the abstract type of the (annotated) node identifiers *)
40 type 'term explicit_named_substitution = (UriManager.uri * 'term) list
42 type implicit_annotation = [ `Closed | `Type | `Hole ]
44 (* INTERNAL REPRESENTATION OF CIC OBJECTS AND TERMS *)
49 | Type of CicUniv.universe
67 | `Elim of sort (** elimination principle; if sort is Type, the universe is
69 | `Record of (string * bool) list (**
70 inductive type that encodes a record; the arguments are
71 the record fields names and if they are coercions *)
72 | `Projection (** record projection *)
76 [ `Class of object_class
77 | `Flavour of object_flavour
82 Rel of int (* DeBrujin index, 1 based*)
83 | Var of UriManager.uri * (* uri, *)
84 term explicit_named_substitution (* explicit named subst. *)
85 | Meta of int * (term option) list (* numeric id, *)
87 | Sort of sort (* sort *)
88 | Implicit of implicit_annotation option (* *)
89 | Cast of term * term (* value, type *)
90 | Prod of name * term * term (* binder, source, target *)
91 | Lambda of name * term * term (* binder, source, target *)
92 | LetIn of name * term * term (* binder, term, target *)
93 | Appl of term list (* arguments *)
94 | Const of UriManager.uri * (* uri, *)
95 term explicit_named_substitution (* explicit named subst. *)
96 | MutInd of UriManager.uri * int * (* uri, typeno, *)
97 term explicit_named_substitution (* explicit named subst. *)
98 (* typeno is 0 based *)
99 | MutConstruct of UriManager.uri * (* uri, *)
100 int * int * (* typeno, consno *)
101 term explicit_named_substitution (* explicit named subst. *)
102 (* typeno is 0 based *)
103 (* consno is 1 based *)
104 | MutCase of UriManager.uri * (* ind. uri, *)
105 int * (* ind. typeno, *)
106 term * term * (* outtype, ind. term *)
107 term list (* patterns *)
108 | Fix of int * inductiveFun list (* funno (0 based), funs *)
109 | CoFix of int * coInductiveFun list (* funno (0 based), funs *)
111 Constant of string * term option * term * (* id, body, type, *)
112 UriManager.uri list * attribute list (* parameters *)
113 | Variable of string * term option * term * (* name, body, type *)
114 UriManager.uri list * attribute list (* parameters *)
115 | CurrentProof of string * metasenv * term * (* name, conjectures, body, *)
116 term * UriManager.uri list * attribute list (* type, parameters *)
117 | InductiveDefinition of inductiveType list * (* inductive types, *)
118 UriManager.uri list * int * attribute list (* params, left params no *)
120 string * bool * term * (* typename, inductive, arity *)
121 constructor list (* constructors *)
123 string * term (* id, type *)
125 string * int * term * term (* name, ind. index, type, body *)
127 string * term * term (* name, type, body *)
129 (* a metasenv is a list of declarations of metas in declarations *)
130 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
131 (* depend on new ones. *)
132 and conjecture = int * context * term
133 and metasenv = conjecture list
134 and substitution = (int * (context * term * term)) list
138 (* a metasenv is a list of declarations of metas in declarations *)
139 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
140 (* depend on new ones. *)
141 and annconjecture = id * int * anncontext * annterm
142 and annmetasenv = annconjecture list
145 ARel of id * id * int * (* idref, DeBrujin index, *)
147 | AVar of id * UriManager.uri * (* uri, *)
148 annterm explicit_named_substitution (* explicit named subst. *)
149 | AMeta of id * int * (annterm option) list (* numeric id, *)
151 | ASort of id * sort (* sort *)
152 | AImplicit of id * implicit_annotation option (* *)
153 | ACast of id * annterm * annterm (* value, type *)
154 | AProd of id * name * annterm * annterm (* binder, source, target *)
155 | ALambda of id * name * annterm * annterm (* binder, source, target *)
156 | ALetIn of id * name * annterm * annterm (* binder, term, target *)
157 | AAppl of id * annterm list (* arguments *)
158 | AConst of id * UriManager.uri * (* uri, *)
159 annterm explicit_named_substitution (* explicit named subst. *)
160 | AMutInd of id * UriManager.uri * int * (* uri, typeno *)
161 annterm explicit_named_substitution (* explicit named subst. *)
162 (* typeno is 0 based *)
163 | AMutConstruct of id * UriManager.uri * (* uri, *)
164 int * int * (* typeno, consno *)
165 annterm explicit_named_substitution (* explicit named subst. *)
166 (* typeno is 0 based *)
167 (* consno is 1 based *)
168 | AMutCase of id * UriManager.uri * (* ind. uri, *)
169 int * (* ind. typeno, *)
170 annterm * annterm * (* outtype, ind. term *)
171 annterm list (* patterns *)
172 | AFix of id * int * anninductiveFun list (* funno, functions *)
173 | ACoFix of id * int * anncoInductiveFun list (* funno, functions *)
175 AConstant of id * id option * string * (* name, *)
176 annterm option * annterm * (* body, type, *)
177 UriManager.uri list * attribute list (* parameters *)
179 string * annterm option * annterm * (* name, body, type *)
180 UriManager.uri list * attribute list (* parameters *)
181 | ACurrentProof of id * id *
182 string * annmetasenv * (* name, conjectures, *)
183 annterm * annterm * UriManager.uri list * (* body,type,parameters *)
185 | AInductiveDefinition of id *
186 anninductiveType list * (* inductive types , *)
187 UriManager.uri list * int * attribute list (* parameters,n ind. pars*)
188 and anninductiveType =
189 id * string * bool * annterm * (* typename, inductive, arity *)
190 annconstructor list (* constructors *)
192 string * annterm (* id, type *)
193 and anninductiveFun =
194 id * string * int * annterm * annterm (* name, ind. index, type, body *)
195 and anncoInductiveFun =
196 id * string * annterm * annterm (* name, type, body *)
200 and context_entry = (* A declaration or definition *)
202 | Def of term * term option (* body, type (if known) *)
205 (name * context_entry) option (* None means no more accessible *)
207 and context = hypothesis list
209 and anncontext_entry = (* A declaration or definition *)
214 id * (name * anncontext_entry) option (* None means no more accessible *)
216 and anncontext = annhypothesis list
220 Object of annobj (* if annobj is a Constant, this is its type *)
221 | ConstantBody of annobj
223 | Conjecture of annconjecture
224 | Hypothesis of annhypothesis
231 let hash = Hashtbl.hash