]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_kernel/nCic.ml
fead92210f45053b925c7acbc82aeb6f55b64cce
[helm.git] / helm / software / components / ng_kernel / nCic.ml
1 (*
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.                     
5     ||I||                                                                
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_______________________________________________________________ *)
11
12 (* $Id$ *)
13
14 (********************************* TERMS ************************************)
15
16 type univ_algebra = [ `Type | `Succ | `CProp ]
17
18 type universe = (univ_algebra * NUri.uri) list 
19   (* Max of non-empty list of named universes, or their successor (when true) 
20    * The empty list represents type0 *)
21
22 type sort = Prop | Type of universe
23
24 type implicit_annotation =
25  [ `Closed | `Type | `Hole | `Tagged of string | `Term | `Typeof of int | `Vector ]
26
27
28 type lc_kind = Irl of int | Ctx of term list
29
30 and local_context = int * lc_kind             (* shift (0 -> no shift), 
31                                                  subst (Irl n means id of
32                                                  length n) *) 
33 and term =
34  | Rel      of int                            (* DeBruijn index, 1 based    *)
35  | Meta     of int * local_context
36  | Appl     of term list                      (* arguments                  *)
37  | Prod     of string * term * term           (* binder, source, target     *)
38  | Lambda   of string * term * term           (* binder, source, target     *)
39  | LetIn    of string * term * term * term    (* binder, type, term, body   *)
40 (* Cast \def degenerate LetIn *)
41  | Const    of NReference.reference           (* ref has (indtype|constr)no *)
42  | Sort     of sort                           (* sort                       *)
43  | Implicit of implicit_annotation            (* ...                        *)
44  | Match    of NReference.reference *         (* ind. reference,            *)
45     term * term *                             (*  outtype, ind. term        *)
46     term list                                 (*  patterns                  *)
47
48
49 (********************************* TYPING ***********************************)
50
51 type context_entry =                       (* A declaration or definition *)
52  | Decl of term                            (* type *)
53  | Def  of term * term                     (* body, type *)
54
55 type hypothesis = string * context_entry   (* name, entry *)
56
57 type context = hypothesis list
58
59 type conjecture = string option * context * term
60
61 type metasenv = (int * conjecture) list
62
63 type subst_entry = string option * context * term * term (* name,ctx,bo,ty *)
64
65 type substitution = (int * subst_entry) list
66
67
68 (******************************** OBJECTS **********************************)
69
70 type relevance = bool list (* relevance of arguments for conversion *)
71
72                     (* relevance, name, recno, ty, bo *)
73 type inductiveFun = relevance * string * int * term * term 
74   (* if coinductive, the int has no meaning and must be set to -1 *)
75
76 type constructor = relevance * string * term  (* id, type *)
77
78 type inductiveType = 
79  relevance * string * term * constructor list    
80  (* relevance, typename, arity, constructors *)
81
82 type def_flavour = (* presentational *)
83   [ `Definition | `Fact | `Lemma | `Theorem | `Corollary | `Example ]
84
85 type def_pragma = (* pragmatic of the object *)
86   [ `Coercion of int
87   | `Elim of sort       (* elimination principle; universe is not relevant *)
88   | `Projection         (* record projection *)
89   | `InversionPrinciple (* inversion principle *)
90   | `Variant 
91   | `Local 
92   | `Regular ]            (* Local = hidden technicality *)
93  
94 type ind_pragma = (* pragmatic of the object *)
95   [ `Record of (string * bool * int) list | `Regular ]
96   (* inductive type that encodes a record; the arguments are the record 
97    * fields names and if they are coercions and then the coercion arity *)
98
99 type generated = [ `Generated | `Provided ]
100
101 type c_attr = generated * def_flavour * def_pragma
102 type f_attr = generated * def_flavour * def_pragma
103 type i_attr = generated * ind_pragma
104
105  (* invariant: metasenv and substitution have disjoint domains *)
106 type obj_kind =
107  | Constant  of relevance * string * term option * term * c_attr
108  | Fixpoint  of bool * inductiveFun list * f_attr
109                 (* true -> fix, funcs, arrts *)
110  | Inductive of bool * int * inductiveType list * i_attr
111                 (* true -> inductive, leftno, types *)
112
113  (* the int must be 0 if the object has no body *)
114 type obj = NUri.uri * int * metasenv * substitution * obj_kind