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