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
71 | `Elim of sort (** elimination principle; if sort is Type, the universe is
73 | `Record of (string * bool * int) list (**
74 inductive type that encodes a record; the arguments are
75 the record fields names and if they are coercions and
76 then the coercion arity *)
77 | `Projection (** record projection *)
78 | `InversionPrinciple (** inversion principle *)
82 [ `Class of object_class
83 | `Flavour of object_flavour
88 Rel of int (* DeBrujin index, 1 based*)
89 | Var of UriManager.uri * (* uri, *)
90 term explicit_named_substitution (* explicit named subst. *)
91 | Meta of int * (term option) list (* numeric id, *)
93 | Sort of sort (* sort *)
94 | Implicit of implicit_annotation option (* *)
95 | Cast of term * term (* value, type *)
96 | Prod of name * term * term (* binder, source, target *)
97 | Lambda of name * term * term (* binder, source, target *)
98 | LetIn of name * term * term (* binder, term, target *)
99 | Appl of term list (* arguments *)
100 | Const of UriManager.uri * (* uri, *)
101 term explicit_named_substitution (* explicit named subst. *)
102 | MutInd of UriManager.uri * int * (* uri, typeno, *)
103 term explicit_named_substitution (* explicit named subst. *)
104 (* typeno is 0 based *)
105 | MutConstruct of UriManager.uri * (* uri, *)
106 int * int * (* typeno, consno *)
107 term explicit_named_substitution (* explicit named subst. *)
108 (* typeno is 0 based *)
109 (* consno is 1 based *)
110 | MutCase of UriManager.uri * (* ind. uri, *)
111 int * (* ind. typeno, *)
112 term * term * (* outtype, ind. term *)
113 term list (* patterns *)
114 | Fix of int * inductiveFun list (* funno (0 based), funs *)
115 | CoFix of int * coInductiveFun list (* funno (0 based), funs *)
117 Constant of string * term option * term * (* id, body, type, *)
118 UriManager.uri list * attribute list (* parameters *)
119 | Variable of string * term option * term * (* name, body, type *)
120 UriManager.uri list * attribute list (* parameters *)
121 | CurrentProof of string * metasenv * term * (* name, conjectures, body, *)
122 term * UriManager.uri list * attribute list (* type, parameters *)
123 | InductiveDefinition of inductiveType list * (* inductive types, *)
124 UriManager.uri list * int * attribute list (* params, left params no *)
126 string * bool * term * (* typename, inductive, arity *)
127 constructor list (* constructors *)
129 string * term (* id, type *)
131 string * int * term * term (* name, ind. index, type, body *)
133 string * term * term (* name, type, body *)
135 (* a metasenv is a list of declarations of metas in declarations *)
136 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
137 (* depend on new ones. *)
138 and conjecture = int * context * term
139 and metasenv = conjecture list
140 and substitution = (int * (context * term * term)) list
144 (* a metasenv is a list of declarations of metas in declarations *)
145 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
146 (* depend on new ones. *)
147 and annconjecture = id * int * anncontext * annterm
148 and annmetasenv = annconjecture list
151 ARel of id * id * int * (* idref, DeBrujin index, *)
153 | AVar of id * UriManager.uri * (* uri, *)
154 annterm explicit_named_substitution (* explicit named subst. *)
155 | AMeta of id * int * (annterm option) list (* numeric id, *)
157 | ASort of id * sort (* sort *)
158 | AImplicit of id * implicit_annotation option (* *)
159 | ACast of id * annterm * annterm (* value, type *)
160 | AProd of id * name * annterm * annterm (* binder, source, target *)
161 | ALambda of id * name * annterm * annterm (* binder, source, target *)
162 | ALetIn of id * name * annterm * annterm (* binder, term, target *)
163 | AAppl of id * annterm list (* arguments *)
164 | AConst of id * UriManager.uri * (* uri, *)
165 annterm explicit_named_substitution (* explicit named subst. *)
166 | AMutInd of id * UriManager.uri * int * (* uri, typeno *)
167 annterm explicit_named_substitution (* explicit named subst. *)
168 (* typeno is 0 based *)
169 | AMutConstruct of id * UriManager.uri * (* uri, *)
170 int * int * (* typeno, consno *)
171 annterm explicit_named_substitution (* explicit named subst. *)
172 (* typeno is 0 based *)
173 (* consno is 1 based *)
174 | AMutCase of id * UriManager.uri * (* ind. uri, *)
175 int * (* ind. typeno, *)
176 annterm * annterm * (* outtype, ind. term *)
177 annterm list (* patterns *)
178 | AFix of id * int * anninductiveFun list (* funno, functions *)
179 | ACoFix of id * int * anncoInductiveFun list (* funno, functions *)
181 AConstant of id * id option * string * (* name, *)
182 annterm option * annterm * (* body, type, *)
183 UriManager.uri list * attribute list (* parameters *)
185 string * annterm option * annterm * (* name, body, type *)
186 UriManager.uri list * attribute list (* parameters *)
187 | ACurrentProof of id * id *
188 string * annmetasenv * (* name, conjectures, *)
189 annterm * annterm * UriManager.uri list * (* body,type,parameters *)
191 | AInductiveDefinition of id *
192 anninductiveType list * (* inductive types , *)
193 UriManager.uri list * int * attribute list (* parameters,n ind. pars*)
194 and anninductiveType =
195 id * string * bool * annterm * (* typename, inductive, arity *)
196 annconstructor list (* constructors *)
198 string * annterm (* id, type *)
199 and anninductiveFun =
200 id * string * int * annterm * annterm (* name, ind. index, type, body *)
201 and anncoInductiveFun =
202 id * string * annterm * annterm (* name, type, body *)
206 and context_entry = (* A declaration or definition *)
208 | Def of term * term option (* body, type (if known) *)
211 (name * context_entry) option (* None means no more accessible *)
213 and context = hypothesis list
215 and anncontext_entry = (* A declaration or definition *)
220 id * (name * anncontext_entry) option (* None means no more accessible *)
222 and anncontext = annhypothesis list
226 context -> metasenv -> CicUniv.universe_graph ->
227 term * metasenv * CicUniv.universe_graph
230 Object of annobj (* if annobj is a Constant, this is its type *)
231 | ConstantBody of annobj
233 | Conjecture of annconjecture
234 | Hypothesis of annhypothesis
241 let hash = Hashtbl.hash_param 100 1000