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