2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
14 (********************************* TERMS ************************************)
16 type universe = (bool * NUri.uri) list
17 (* Max of non-empty list of named universes, or their successor (when true)
18 * The empty list represents type0 *)
20 type sort = Prop | Type of universe
22 type implicit_annotation =
23 [ `Closed | `Type | `Hole | `Term | `Typeof of int | `Vector ]
25 type lc_kind = Irl of int | Ctx of term list
27 and local_context = int * lc_kind (* shift (0 -> no shift),
28 subst (Irl n means id of
31 | Rel of int (* DeBruijn index, 1 based *)
32 | Meta of int * local_context
33 | Appl of term list (* arguments *)
34 | Prod of string * term * term (* binder, source, target *)
35 | Lambda of string * term * term (* binder, source, target *)
36 | LetIn of string * term * term * term (* binder, type, term, body *)
37 (* Cast \def degenerate LetIn *)
38 | Const of NReference.reference (* ref has (indtype|constr)no *)
39 | Sort of sort (* sort *)
40 | Implicit of implicit_annotation (* ... *)
41 | Match of NReference.reference * (* ind. reference, *)
42 term * term * (* outtype, ind. term *)
43 term list (* patterns *)
46 (********************************* TYPING ***********************************)
48 type context_entry = (* A declaration or definition *)
49 | Decl of term (* type *)
50 | Def of term * term (* body, type *)
52 type hypothesis = string * context_entry (* name, entry *)
54 type context = hypothesis list
56 type conjecture = string option * context * term
58 type metasenv = (int * conjecture) list
60 type subst_entry = string option * context * term * term (* name,ctx,bo,ty *)
62 type substitution = (int * subst_entry) list
65 (******************************** OBJECTS **********************************)
67 type relevance = bool list (* relevance of arguments for conversion *)
69 (* relevance, name, recno, ty, bo *)
70 type inductiveFun = relevance * string * int * term * term
71 (* if coinductive, the int has no meaning and must be set to -1 *)
73 type constructor = relevance * string * term (* id, type *)
76 relevance * string * term * constructor list
77 (* relevance, typename, arity, constructors *)
79 type def_flavour = (* presentational *)
80 [ `Definition | `Fact | `Lemma | `Theorem | `Corollary | `Example ]
82 type def_pragma = (* pragmatic of the object *)
84 | `Elim of sort (* elimination principle; universe is not relevant *)
85 | `Projection (* record projection *)
86 | `InversionPrinciple (* inversion principle *)
89 | `Regular ] (* Local = hidden technicality *)
91 type ind_pragma = (* pragmatic of the object *)
92 [ `Record of (string * bool * int) list | `Regular ]
93 (* inductive type that encodes a record; the arguments are the record
94 * fields names and if they are coercions and then the coercion arity *)
96 type generated = [ `Generated | `Provided ]
98 type c_attr = generated * def_flavour * def_pragma
99 type f_attr = generated * def_flavour
100 type i_attr = generated * ind_pragma
102 (* invariant: metasenv and substitution have disjoint domains *)
104 | Constant of relevance * string * term option * term * c_attr
105 | Fixpoint of bool * inductiveFun list * f_attr
106 (* true -> fix, funcs, arrts *)
107 | Inductive of bool * int * inductiveType list * i_attr
108 (* true -> inductive, leftno, types *)
110 (* the int must be 0 if the object has no body *)
111 type obj = NUri.uri * int * metasenv * substitution * obj_kind