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
58 | `Elim of sort (** elimination principle; if sort is Type, the universe is
60 | `Record of string list (** inductive type that encodes a record;
61 the arguments are the record fields *)
62 | `Projection (** record projection *)
66 [ `Class of object_class
71 Rel of int (* DeBrujin index, 1 based*)
72 | Var of UriManager.uri * (* uri, *)
73 term explicit_named_substitution (* explicit named subst. *)
74 | Meta of int * (term option) list (* numeric id, *)
76 | Sort of sort (* sort *)
77 | Implicit of implicit_annotation option (* *)
78 | Cast of term * term (* value, type *)
79 | Prod of name * term * term (* binder, source, target *)
80 | Lambda of name * term * term (* binder, source, target *)
81 | LetIn of name * term * term (* binder, term, target *)
82 | Appl of term list (* arguments *)
83 | Const of UriManager.uri * (* uri, *)
84 term explicit_named_substitution (* explicit named subst. *)
85 | MutInd of UriManager.uri * int * (* uri, typeno, *)
86 term explicit_named_substitution (* explicit named subst. *)
87 (* typeno is 0 based *)
88 | MutConstruct of UriManager.uri * (* uri, *)
89 int * int * (* typeno, consno *)
90 term explicit_named_substitution (* explicit named subst. *)
91 (* typeno is 0 based *)
92 (* consno is 1 based *)
93 | MutCase of UriManager.uri * (* ind. uri, *)
94 int * (* ind. typeno, *)
95 term * term * (* outtype, ind. term *)
96 term list (* patterns *)
97 | Fix of int * inductiveFun list (* funno (0 based), funs *)
98 | CoFix of int * coInductiveFun list (* funno (0 based), funs *)
100 Constant of string * term option * term * (* id, body, type, *)
101 UriManager.uri list * attribute list (* parameters *)
102 | Variable of string * term option * term * (* name, body, type *)
103 UriManager.uri list * attribute list (* parameters *)
104 | CurrentProof of string * metasenv * term * (* name, conjectures, value,*)
105 term * UriManager.uri list * attribute list (* type, parameters *)
106 | InductiveDefinition of inductiveType list * (* inductive types, *)
107 UriManager.uri list * int * attribute list (* params, left params no *)
109 string * bool * term * (* typename, inductive, arity *)
110 constructor list (* constructors *)
112 string * term (* id, type *)
114 string * int * term * term (* name, ind. index, type, body *)
116 string * term * term (* name, type, body *)
118 (* a metasenv is a list of declarations of metas in declarations *)
119 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
120 (* depend on new ones. *)
121 and conjecture = int * context * term
122 and metasenv = conjecture list
123 and substitution = (int * (context * term * term)) list
127 (* a metasenv is a list of declarations of metas in declarations *)
128 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
129 (* depend on new ones. *)
130 and annconjecture = id * int * anncontext * annterm
131 and annmetasenv = annconjecture list
134 ARel of id * id * int * (* idref, DeBrujin index, *)
136 | AVar of id * UriManager.uri * (* uri, *)
137 annterm explicit_named_substitution (* explicit named subst. *)
138 | AMeta of id * int * (annterm option) list (* numeric id, *)
140 | ASort of id * sort (* sort *)
141 | AImplicit of id * implicit_annotation option (* *)
142 | ACast of id * annterm * annterm (* value, type *)
143 | AProd of id * name * annterm * annterm (* binder, source, target *)
144 | ALambda of id * name * annterm * annterm (* binder, source, target *)
145 | ALetIn of id * name * annterm * annterm (* binder, term, target *)
146 | AAppl of id * annterm list (* arguments *)
147 | AConst of id * UriManager.uri * (* uri, *)
148 annterm explicit_named_substitution (* explicit named subst. *)
149 | AMutInd of id * UriManager.uri * int * (* uri, typeno *)
150 annterm explicit_named_substitution (* explicit named subst. *)
151 (* typeno is 0 based *)
152 | AMutConstruct of id * UriManager.uri * (* uri, *)
153 int * int * (* typeno, consno *)
154 annterm explicit_named_substitution (* explicit named subst. *)
155 (* typeno is 0 based *)
156 (* consno is 1 based *)
157 | AMutCase of id * UriManager.uri * (* ind. uri, *)
158 int * (* ind. typeno, *)
159 annterm * annterm * (* outtype, ind. term *)
160 annterm list (* patterns *)
161 | AFix of id * int * anninductiveFun list (* funno, functions *)
162 | ACoFix of id * int * anncoInductiveFun list (* funno, functions *)
164 AConstant of id * id option * string * (* name, *)
165 annterm option * annterm * (* body, type, *)
166 UriManager.uri list * attribute list (* parameters *)
168 string * annterm option * annterm * (* name, body, type *)
169 UriManager.uri list * attribute list (* parameters *)
170 | ACurrentProof of id * id *
171 string * annmetasenv * (* name, conjectures, *)
172 annterm * annterm * UriManager.uri list * (* value,type,parameters *)
174 | AInductiveDefinition of id *
175 anninductiveType list * (* inductive types , *)
176 UriManager.uri list * int * attribute list (* parameters,n ind. pars*)
177 and anninductiveType =
178 id * string * bool * annterm * (* typename, inductive, arity *)
179 annconstructor list (* constructors *)
181 string * annterm (* id, type *)
182 and anninductiveFun =
183 id * string * int * annterm * annterm (* name, ind. index, type, body *)
184 and anncoInductiveFun =
185 id * string * annterm * annterm (* name, type, body *)
189 and context_entry = (* A declaration or definition *)
191 | Def of term * term option (* body, type (if known) *)
194 (name * context_entry) option (* None means no more accessible *)
196 and context = hypothesis list
198 and anncontext_entry = (* A declaration or definition *)
203 id * (name * anncontext_entry) option (* None means no more accessible *)
205 and anncontext = annhypothesis list
209 Object of annobj (* if annobj is a Constant, this is its type *)
210 | ConstantBody of annobj
212 | Conjecture of annconjecture
213 | Hypothesis of annhypothesis