]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_kernel/nCic.ml
added leftno to indtypes, better indentation and comments
[helm.git] / helm / software / components / ng_kernel / nCic.ml
1 (* Copyright (C) 2000, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 (********************************* TERMS ************************************)
27
28 type sort = Prop | Set | Type of int | CProp
29
30 type implicit_annotation = [ `Closed | `Type | `Hole | `Term ]
31
32 type local_context = int * (term list) option    (* shift (0 -> no shift), 
33                                                     subst (None means id) *) 
34 and term =
35  | Rel      of int                            (* DeBruijn index, 1 based    *)
36  | Meta     of int * local_context
37  | Appl     of term list                      (* arguments                  *)
38  | Prod     of string * term * term           (* binder, source, target     *)
39  | Lambda   of string * term * term           (* binder, source, target     *)
40  | LetIn    of string * term * term * term    (* binder, type, term, body   *)
41 (* Cast \def degenerate LetIn *)
42  | Const    of NReference.reference           (* ref has (indtype|constr)no *)
43  | Sort     of sort                           (* sort                       *)
44  | Implicit of implicit_annotation            (* ...                        *)
45  | Match    of NReference.reference *         (* ind. reference,            *)
46     term * term *                             (*  outtype, ind. term        *)
47     term list                                 (*  patterns                  *)
48
49
50 (********************************* TYPING ***********************************)
51
52 type context_entry =                       (* A declaration or definition *)
53  | Decl of term                            (* type *)
54  | Def  of term * term                     (* body, type *)
55
56 type hypothesis = string * context_entry   
57
58 type context = hypothesis list
59
60 type conjecture = int * string option * context * term
61
62 type metasenv = conjecture list
63
64 type substitution = (int * (string option * context * term * term)) list
65
66
67 (******************************** OBJECTS **********************************)
68
69 type inductiveFun = string * int * term * term 
70   (* if coinductive, the int has no meaning and must be set to -1 *)
71
72 type constructor = string * term  (* id, type *)
73
74 type inductiveType = 
75  string * bool * term * int * (* typename, inductive, arity, leftno *)
76  constructor list             (* constructors                       *)
77
78 type def_flavour = (* presentational *)
79   [ `Definition | `Fact | `Lemma | `Remark | `Theorem | `Corollary ]
80
81 type def_pragma = (* pragmatic of the object *)
82   [ `Coercion of int
83   | `Elim of sort       (* elimination principle; universe is not relevant *)
84   | `Projection         (* record projection *)
85   | `InversionPrinciple (* inversion principle *)
86   | `Variant ]
87  
88 type ind_pragma = (* pragmatic of the object *)
89   [ `Record of (string * bool * int) list ]
90   (* inductive type that encodes a record; the arguments are the record 
91    * fields names and if they are coercions and then the coercion arity *)
92
93 type generated = [ `Generated | `Provided ]
94
95 type c_attr = generated * def_flavour * def_pragma
96 type f_attr = generated * def_flavour
97 type i_attr = generated * ind_pragma
98
99  (* invariant: metasenv and substitution have disjoint domains *)
100 type obj =
101  | Constant  of NUri.uri * metasenv * substitution * string * term option * term * c_attr
102  | Fixpoint  of NUri.uri * metasenv * substitution * bool * inductiveFun list * f_attr
103  | Inductive of NUri.uri * metasenv * substitution * inductiveType list * i_attr
104