]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/acic_content/cicNotationPt.ml
Preparing for 0.5.9 release.
[helm.git] / helm / software / components / acic_content / cicNotationPt.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (* $Id$ *)
27
28 (** CIC Notation Parse Tree *)
29
30 type binder_kind = [ `Lambda | `Pi | `Exists | `Forall ]
31 type induction_kind = [ `Inductive | `CoInductive ]
32 type sort_kind = [ `Prop | `Set | `Type of CicUniv.universe | `CProp of
33 CicUniv.universe | `NType of string |`NCProp of string]
34 type fold_kind = [ `Left | `Right ]
35
36 type location = Stdpp.location
37 let fail floc msg =
38   let (x, y) = HExtlib.loc_of_floc floc in
39   failwith (Printf.sprintf "Error at characters %d - %d: %s" x y msg)
40
41 type href = UriManager.uri
42
43 type child_pos = [ `Left | `Right | `Inner ]
44
45 type term_attribute =
46   [ `Loc of location                  (* source file location *)
47   | `IdRef of string                  (* ACic pointer *)
48   | `Level of int
49   | `XmlAttrs of (string option * string * string) list
50       (* list of XML attributes: namespace, name, value *)
51   | `Raw of string                    (* unparsed version *)
52   ]
53
54 type literal =
55   [ `Symbol of string
56   | `Keyword of string
57   | `Number of string
58   ]
59
60 type case_indtype = string * href option
61
62 type 'term capture_variable = 'term * 'term option
63
64 (** To be increased each time the term type below changes, used for "safe"
65  * marshalling *)
66 let magic = 6
67
68 type term =
69   (* CIC AST *)
70
71   | AttributedTerm of term_attribute * term
72
73   | Appl of term list
74   | Binder of binder_kind * term capture_variable * term (* kind, name, body *)
75   | Case of term * case_indtype option * term option *
76       (case_pattern * term) list
77       (* what to match, inductive type, out type, <pattern,action> list *)
78   | Cast of term * term
79   | LetIn of term capture_variable * term * term  (* name, body, where *)
80   | LetRec of induction_kind * (term capture_variable list * term capture_variable * term * int) list * term
81       (* (params, name, body, decreasing arg) list, where *)
82   | Ident of string * subst list option
83       (* literal, substitutions.
84       * Some [] -> user has given an empty explicit substitution list 
85       * None -> user has given no explicit substitution list *)
86   | Implicit of [`Vector | `JustOne | `Tagged of string]
87   | Meta of int * meta_subst list
88   | Num of string * int (* literal, instance *)
89   | Sort of sort_kind
90   | Symbol of string * int  (* canonical name, instance *)
91
92   | UserInput (* place holder for user input, used by MatitaConsole, not to be
93               used elsewhere *)
94   | Uri of string * subst list option (* as Ident, for long names *)
95   | NRef of NReference.reference
96
97   | NCic of NCic.term
98
99   (* Syntax pattern extensions *)
100
101   | Literal of literal
102   | Layout of layout_pattern
103
104   | Magic of magic_term
105   | Variable of pattern_variable
106
107   (* name, type. First component must be Ident or Variable (FreshVar _) *)
108
109 and meta_subst = term option
110 and subst = string * term
111 and case_pattern =
112    Pattern of string * href option * term capture_variable list
113  | Wildcard
114
115 and box_kind = H | V | HV | HOV
116 and box_spec = box_kind * bool * bool (* kind, spacing, indent *)
117
118 and layout_pattern =
119   | Sub of term * term
120   | Sup of term * term
121   | Below of term * term
122   | Above of term * term
123   | Frac of term * term
124   | Over of term * term
125   | Atop of term * term
126   | InfRule of term * term * term
127 (*   | array of term * literal option * literal option
128       |+ column separator, row separator +| *)
129   | Maction of term list
130   | Sqrt of term
131   | Root of term * term (* argument, index *)
132   | Break
133   | Box of box_spec * term list
134   | Group of term list
135   | Mstyle of (string * string) list * term list
136   | Mpadded of (string * string) list * term list
137
138 and magic_term =
139   (* level 1 magics *)
140   | List0 of term * literal option (* pattern, separator *)
141   | List1 of term * literal option (* pattern, separator *)
142   | Opt of term
143
144   (* level 2 magics *)
145   | Fold of fold_kind * term * string list * term
146     (* base case pattern, recursive case bound names, recursive case pattern *)
147   | Default of term * term  (* "some" case pattern, "none" case pattern *)
148   | Fail
149   | If of term * term * term (* test, pattern if true, pattern if false *)
150
151 and term_level = Self of int | Level of int
152
153 and pattern_variable =
154   (* level 1 and 2 variables *)
155   | NumVar of string
156   | IdentVar of string
157   | TermVar of string * term_level
158
159   (* level 1 variables *)
160   | Ascription of term * string
161
162   (* level 2 variables *)
163   | FreshVar of string
164
165 type argument_pattern =
166   | IdentArg of int * string (* eta-depth, name *)
167
168 type cic_appl_pattern =
169   | UriPattern of UriManager.uri
170   | NRefPattern of NReference.reference
171   | VarPattern of string
172   | ImplicitPattern
173   | ApplPattern of cic_appl_pattern list
174
175   (** <name, inductive/coinductive, type, constructor list>
176   * true means inductive, false coinductive *)
177 type 'term inductive_type = string * bool * 'term * (string * 'term) list
178
179 type 'term obj =
180   | Inductive of 'term capture_variable list * 'term inductive_type list
181       (** parameters, list of loc * mutual inductive types *)
182   | Theorem of Cic.object_flavour * string * 'term * 'term option * NCic.def_pragma
183       (** flavour, name, type, body
184        * - name is absent when an unnamed theorem is being proved, tipically in
185        *   interactive usage
186        * - body is present when its given along with the command, otherwise it
187        *   will be given in proof editing mode using the tactical language,
188        *   unless the flavour is an Axiom
189        *)
190   | Record of 'term capture_variable list * string * 'term * (string * 'term * bool * int) list
191       (** left parameters, name, type, fields *)
192
193 (** {2 Standard precedences} *)
194
195 let let_in_prec = 10
196 let binder_prec = 20
197 let apply_prec = 70
198 let simple_prec = 90
199