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