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.
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_______________________________________________________________ *)
14 (********************************* TERMS ************************************)
16 type univ_algebra = [ `Type | `Succ | `CProp ]
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 *)
22 type sort = Prop | Type of universe
24 type implicit_annotation =
25 [ `Closed | `Type | `Hole | `Tagged of string | `Term | `Typeof of int | `Vector ]
28 type lc_kind = Irl of int | Ctx of term list
30 and local_context = int * lc_kind (* shift (0 -> no shift),
31 subst (Irl n means id of
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 *)
49 (********************************* TYPING ***********************************)
51 type context_entry = (* A declaration or definition *)
52 | Decl of term (* type *)
53 | Def of term * term (* body, type *)
55 type hypothesis = string * context_entry (* name, entry *)
57 type context = hypothesis list
61 | `IsTerm | `IsType | `IsSort
62 | `InScope | `OutScope of int]
64 type meta_attrs = meta_attr list
66 type conjecture = meta_attrs * context * term
68 type metasenv = (int * conjecture) list
70 type subst_entry = meta_attrs * context * term * term (* name,ctx,bo,ty *)
72 type substitution = (int * subst_entry) list
75 (******************************** OBJECTS **********************************)
77 type relevance = bool list (* relevance of arguments for conversion *)
79 (* relevance, name, recno, ty, bo *)
80 type inductiveFun = relevance * string * int * term * term
81 (* if coinductive, the int has no meaning and must be set to -1 *)
83 type constructor = relevance * string * term (* id, type *)
86 relevance * string * term * constructor list
87 (* relevance, typename, arity, constructors *)
89 type def_flavour = (* presentational *)
90 [ `Axiom | `Definition | `Fact | `Lemma | `Theorem | `Corollary | `Example ]
92 type def_pragma = (* pragmatic of the object *)
94 | `Elim of sort (* elimination principle; universe is not relevant *)
95 | `Projection (* record projection *)
96 | `InversionPrinciple (* inversion principle *)
97 | `DiscriminationPrinciple (* discrimination principle *)
100 | `Regular ] (* Local = hidden technicality *)
102 type ind_pragma = (* pragmatic of the object *)
103 [ `Record of (string * bool * int) list | `Regular ]
104 (* inductive type that encodes a record; the arguments are the record
105 * fields names and if they are coercions and then the coercion arity *)
107 type generated = [ `Generated | `Provided ]
109 type c_attr = generated * def_flavour * def_pragma
110 type f_attr = generated * def_flavour * def_pragma
111 type i_attr = generated * ind_pragma
113 (* invariant: metasenv and substitution have disjoint domains *)
115 | Constant of relevance * string * term option * term * c_attr
116 | Fixpoint of bool * inductiveFun list * f_attr
117 (* true -> fix, funcs, arrts *)
118 | Inductive of bool * int * inductiveType list * i_attr
119 (* true -> inductive, leftno, types *)
121 (* the int must be 0 if the object has no body *)
122 type obj = NUri.uri * int * metasenv * substitution * obj_kind
124 (* pretty-printing *)
125 class virtual status =
127 method virtual ppterm: context:context -> subst:substitution ->
128 metasenv:metasenv -> ?margin:int -> ?inside_fix:bool -> term -> string
130 method virtual ppcontext: ?sep:string -> subst:substitution ->
131 metasenv:metasenv -> context -> string
133 method virtual ppmetasenv: subst:substitution -> metasenv -> string
135 method virtual ppsubst: metasenv:metasenv -> ?use_subst:bool -> substitution -> string
137 method virtual ppobj: obj -> string
140 (* pretty-printing: same as vstatus, but all methods are concrete *)
141 (* used only to declare concrete instances of subclasses of vstatus class *)
146 method ppterm: context:context -> subst:substitution ->
147 metasenv:metasenv -> ?margin:int -> ?inside_fix:bool -> term -> string
149 method ppcontext: ?sep:string -> subst:substitution ->
150 metasenv:metasenv -> context -> string
152 method ppmetasenv: subst:substitution -> metasenv -> string
154 method ppsubst: metasenv:metasenv -> ?use_subst:bool -> substitution -> string
156 method ppobj: obj -> string