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