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 ]
45 Object of annobj (* if annobj is a Constant, this is its type *)
46 | ConstantBody of annobj
48 | Conjecture of annconjecture
49 | Hypothesis of annhypothesis
51 (* INTERNAL REPRESENTATION OF CIC OBJECTS AND TERMS *)
55 | Type of CicUniv.universe
61 Rel of int (* DeBrujin index *)
62 | Var of UriManager.uri * (* uri, *)
63 term explicit_named_substitution (* explicit named subst. *)
64 | Meta of int * (term option) list (* numeric id, *)
66 | Sort of sort (* sort *)
67 | Implicit of implicit_annotation option (* *)
68 | Cast of term * term (* value, type *)
69 | Prod of name * term * term (* binder, source, target *)
70 | Lambda of name * term * term (* binder, source, target *)
71 | LetIn of name * term * term (* binder, term, target *)
72 | Appl of term list (* arguments *)
73 | Const of UriManager.uri * (* uri, *)
74 term explicit_named_substitution (* explicit named subst. *)
75 | MutInd of UriManager.uri * int * (* uri, typeno, *)
76 term explicit_named_substitution (* explicit named subst. *)
77 (* typeno is 0 based *)
78 | MutConstruct of UriManager.uri * (* uri, *)
79 int * int * (* typeno, consno *)
80 term explicit_named_substitution (* explicit named subst. *)
81 (* typeno is 0 based *)
82 (* consno is 1 based *)
83 | MutCase of UriManager.uri * (* ind. uri, *)
84 int * (* ind. typeno, *)
85 term * term * (* outtype, ind. term *)
86 term list (* patterns *)
87 | Fix of int * inductiveFun list (* funno (0 based), funs *)
88 | CoFix of int * coInductiveFun list (* funno (0 based), funs *)
90 Constant of string * term option * term * (* id, body, type, *)
91 UriManager.uri list (* parameters *)
92 | Variable of string * term option * term * (* name, body, type *)
93 UriManager.uri list (* parameters *)
94 | CurrentProof of string * metasenv * (* name, conjectures, *)
95 term * term * UriManager.uri list (* value, type, parameters *)
96 | InductiveDefinition of inductiveType list * (* inductive types, *)
97 UriManager.uri list * int (* parameters, n ind. pars *)
99 string * bool * term * (* typename, inductive, arity *)
100 constructor list (* constructors *)
102 string * term (* id, type *)
104 string * int * term * term (* name, ind. index, type, body *)
106 string * term * term (* name, type, body *)
108 (* a metasenv is a list of declarations of metas in declarations *)
109 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
110 (* depend on new ones. *)
111 and conjecture = int * context * term
112 and metasenv = conjecture list
114 (* a metasenv is a list of declarations of metas in declarations *)
115 (* order (i.e. [oldest ; ... ; newest]). Older variables can not *)
116 (* depend on new ones. *)
117 and annconjecture = id * int * anncontext * annterm
118 and annmetasenv = annconjecture list
121 ARel of id * id * int * (* idref, DeBrujin index, *)
123 | AVar of id * UriManager.uri * (* uri, *)
124 annterm explicit_named_substitution (* explicit named subst. *)
125 | AMeta of id * int * (annterm option) list (* numeric id, *)
127 | ASort of id * sort (* sort *)
128 | AImplicit of id * implicit_annotation option (* *)
129 | ACast of id * annterm * annterm (* value, type *)
130 | AProd of id * name * annterm * annterm (* binder, source, target *)
131 | ALambda of id * name * annterm * annterm (* binder, source, target *)
132 | ALetIn of id * name * annterm * annterm (* binder, term, target *)
133 | AAppl of id * annterm list (* arguments *)
134 | AConst of id * UriManager.uri * (* uri, *)
135 annterm explicit_named_substitution (* explicit named subst. *)
136 | AMutInd of id * UriManager.uri * int * (* uri, typeno *)
137 annterm explicit_named_substitution (* explicit named subst. *)
138 (* typeno is 0 based *)
139 | AMutConstruct of id * UriManager.uri * (* uri, *)
140 int * int * (* typeno, consno *)
141 annterm explicit_named_substitution (* explicit named subst. *)
142 (* typeno is 0 based *)
143 (* consno is 1 based *)
144 | AMutCase of id * UriManager.uri * (* ind. uri, *)
145 int * (* ind. typeno, *)
146 annterm * annterm * (* outtype, ind. term *)
147 annterm list (* patterns *)
148 | AFix of id * int * anninductiveFun list (* funno, functions *)
149 | ACoFix of id * int * anncoInductiveFun list (* funno, functions *)
151 AConstant of id * id option * string * (* name, *)
152 annterm option * annterm * (* body, type, *)
153 UriManager.uri list (* parameters *)
155 string * annterm option * annterm * (* name, body, type *)
156 UriManager.uri list (* parameters *)
157 | ACurrentProof of id * id *
158 string * annmetasenv * (* name, conjectures, *)
159 annterm * annterm * UriManager.uri list (* value,type,parameters *)
160 | AInductiveDefinition of id *
161 anninductiveType list * (* inductive types , *)
162 UriManager.uri list * int (* parameters,n ind. pars*)
163 and anninductiveType =
164 id * string * bool * annterm * (* typename, inductive, arity *)
165 annconstructor list (* constructors *)
167 string * annterm (* id, type *)
168 and anninductiveFun =
169 id * string * int * annterm * annterm (* name, ind. index, type, body *)
170 and anncoInductiveFun =
171 id * string * annterm * annterm (* name, type, body *)
175 and context_entry = (* A declaration or definition *)
177 | Def of term * term option (* body, type (if known) *)
180 (name * context_entry) option (* None means no more accessible *)
182 and context = hypothesis list
184 and anncontext_entry = (* A declaration or definition *)
189 id * (name * anncontext_entry) option (* None means no more accessible *)
191 and anncontext = annhypothesis list