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