]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_kernel/nCic.ml
b2f3351c61ed1164b206260e4f4a4d8c8b7ef801
[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: nCicReduction.ml 8250 2008-03-25 17:56:20Z tassi $ *)
13
14 (********************************* TERMS ************************************)
15
16 type sort = Prop | Set | 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 type inductiveFun = relevance * string * int * term * term 
64   (* if coinductive, the int has no meaning and must be set to -1 *)
65
66 type constructor = relevance * string * term  (* id, type *)
67
68 type inductiveType = 
69  relevance * string * term * constructor list    
70  (* relevance, typename, arity, constructors *)
71
72 type def_flavour = (* presentational *)
73   [ `Definition | `Fact | `Lemma | `Theorem | `Corollary | `Example ]
74
75 type def_pragma = (* pragmatic of the object *)
76   [ `Coercion of int
77   | `Elim of sort       (* elimination principle; universe is not relevant *)
78   | `Projection         (* record projection *)
79   | `InversionPrinciple (* inversion principle *)
80   | `Variant 
81   | `Local 
82   | `Regular ]            (* Local = hidden technicality *)
83  
84 type ind_pragma = (* pragmatic of the object *)
85   [ `Record of (string * bool * int) list | `Regular ]
86   (* inductive type that encodes a record; the arguments are the record 
87    * fields names and if they are coercions and then the coercion arity *)
88
89 type generated = [ `Generated | `Provided ]
90
91 type c_attr = generated * def_flavour * def_pragma
92 type f_attr = generated * def_flavour
93 type i_attr = generated * ind_pragma
94
95  (* invariant: metasenv and substitution have disjoint domains *)
96 type obj_kind =
97  | Constant  of relevance * string * term option * term * c_attr
98  | Fixpoint  of bool * inductiveFun list * f_attr
99                 (* true -> fix, funcs, arrts *)
100  | Inductive of bool * int * inductiveType list * i_attr
101                 (* true -> inductive, leftno, types *)
102
103  (* the int must be 0 if the object has no body *)
104 type obj = NUri.uri * int * metasenv * substitution * obj_kind