]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_notation/grafiteAst.ml
added a minimal parser to extract informations relevant to dependencies calculation
[helm.git] / helm / ocaml / cic_notation / grafiteAst.ml
1 (* Copyright (C) 2004, 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 module Ast = CicNotationPt
27
28 type direction = [ `LeftToRight | `RightToLeft ]
29
30 type loc = Ast.location
31
32 type ('term, 'lazy_term, 'ident) pattern =
33   'lazy_term option * ('ident * 'term) list * 'term
34
35 type ('term, 'ident) type_spec =
36    | Ident of 'ident
37    | Type of UriManager.uri * int 
38
39 type reduction =
40   [ `Normalize
41   | `Reduce
42   | `Simpl
43   | `Unfold of CicNotationPt.term option
44   | `Whd ]
45
46 type ('term, 'lazy_term, 'reduction, 'ident) tactic =
47   | Absurd of loc * 'term
48   | Apply of loc * 'term
49   | Assumption of loc
50   | Auto of loc * int option * int option * string option
51       (* depth, width, paramodulation *)
52   | Change of loc * ('term, 'lazy_term, 'ident) pattern * 'lazy_term
53   | Clear of loc * 'ident
54   | ClearBody of loc * 'ident
55   | Compare of loc * 'term
56   | Constructor of loc * int
57   | Contradiction of loc
58   | Cut of loc * 'ident option * 'term
59   | DecideEquality of loc
60   | Decompose of loc * ('term, 'ident) type_spec list * 'ident * 'ident list
61   | Discriminate of loc * 'term
62   | Elim of loc * 'term * 'term option * int option * 'ident list
63   | ElimType of loc * 'term * 'term option * int option * 'ident list
64   | Exact of loc * 'term
65   | Exists of loc
66   | Fail of loc
67   | Fold of loc * 'reduction * 'lazy_term * ('term, 'lazy_term, 'ident) pattern
68   | Fourier of loc
69   | FwdSimpl of loc * string * 'ident list
70   | Generalize of loc * ('term, 'lazy_term, 'ident) pattern * 'ident option
71   | Goal of loc * int (* change current goal, argument is goal number 1-based *)
72   | IdTac of loc
73   | Injection of loc * 'term
74   | Intros of loc * int option * 'ident list
75   | LApply of loc * int option * 'term list * 'term * 'ident option
76   | Left of loc
77   | LetIn of loc * 'term * 'ident
78   | Reduce of loc * 'reduction * ('term, 'lazy_term, 'ident) pattern 
79   | Reflexivity of loc
80   | Replace of loc * ('term, 'lazy_term, 'ident) pattern * 'lazy_term
81   | Rewrite of loc * direction * 'term *
82       ('term, 'lazy_term, 'ident) pattern
83   | Right of loc
84   | Ring of loc
85   | Split of loc
86   | Symmetry of loc
87   | Transitivity of loc * 'term
88
89 type thm_flavour = Cic.object_flavour
90
91   (** <name, inductive/coinductive, type, constructor list>
92   * true means inductive, false coinductive *)
93 type 'term inductive_type = string * bool * 'term * (string * 'term) list
94
95 type search_kind = [ `Locate | `Hint | `Match | `Elim ]
96
97 type print_kind = [ `Env | `Coer ]
98
99 type 'term macro = 
100   (* Whelp's stuff *)
101   | WHint of loc * 'term 
102   | WMatch of loc * 'term 
103   | WInstance of loc * 'term 
104   | WLocate of loc * string
105   | WElim of loc * 'term
106   (* real macros *)
107 (*   | Abort of loc *)
108   | Print of loc * string
109   | Check of loc * 'term 
110   | Hint of loc
111   | Quit of loc
112 (*   | Redo of loc * int option
113   | Undo of loc * int option *)
114 (*   | Print of loc * print_kind *)
115   | Search_pat of loc * search_kind * string  (* searches with string pattern *)
116   | Search_term of loc * search_kind * 'term  (* searches with term pattern *)
117
118 type alias_spec =
119   | Ident_alias of string * string        (* identifier, uri *)
120   | Symbol_alias of string * int * string (* name, instance no, description *)
121   | Number_alias of int * string          (* instance no, description *)
122
123 type obj =
124   | Inductive of (string * Ast.term) list *
125       Ast.term inductive_type list
126       (** parameters, list of loc * mutual inductive types *)
127   | Theorem of thm_flavour * string * Ast.term *
128       Ast.term option
129       (** flavour, name, type, body
130        * - name is absent when an unnamed theorem is being proved, tipically in
131        *   interactive usage
132        * - body is present when its given along with the command, otherwise it
133        *   will be given in proof editing mode using the tactical language
134        *)
135   | Record of (string * Ast.term) list * string * Ast.term *
136       (string * Ast.term) list
137       (** left parameters, name, type, fields *)
138
139 type ('term,'obj) command =
140   | Default of loc * string * UriManager.uri list
141   | Include of loc * string
142   | Set of loc * string * string
143   | Drop of loc
144   | Qed of loc
145       (** name.
146        * Name is needed when theorem was started without providing a name
147        *)
148   | Coercion of loc * 'term
149   | Alias of loc * alias_spec
150       (** parameters, name, type, fields *) 
151   | Obj of loc * 'obj
152   | Notation of loc * direction option * Ast.term * Gramext.g_assoc *
153       int * Ast.term
154       (* direction, l1 pattern, associativity, precedence, l2 pattern *)
155   | Interpretation of loc *
156       string * (string * Ast.argument_pattern list) *
157         Ast.cic_appl_pattern
158       (* description (i.e. id), symbol, arg pattern, appl pattern *)
159
160     (* DEBUGGING *)
161   | Dump of loc (* dump grammar on stdout *)
162     (* DEBUGGING *)
163   | Render of loc * UriManager.uri (* render library object *)
164
165 type ('term, 'lazy_term, 'reduction, 'ident) tactical =
166   | Tactic of loc * ('term, 'lazy_term, 'reduction, 'ident) tactic
167   | Do of loc * int * ('term, 'lazy_term, 'reduction, 'ident) tactical
168   | Repeat of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical
169   | Seq of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical list
170       (* sequential composition *)
171   | Then of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical *
172       ('term, 'lazy_term, 'reduction, 'ident) tactical list
173   | First of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical list
174       (* try a sequence of loc * tacticals until one succeeds, fail otherwise *)
175   | Try of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical
176       (* try a tactical and mask failures *)
177   | Solve of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical list
178
179
180 type ('term, 'lazy_term, 'reduction, 'obj, 'ident) code =
181   | Command of loc * ('term,'obj) command
182   | Macro of loc * 'term macro 
183   | Tactical of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical
184              
185 type ('term, 'lazy_term, 'reduction, 'obj, 'ident) comment =
186   | Note of loc * string
187   | Code of loc * ('term, 'lazy_term, 'reduction, 'obj, 'ident) code
188              
189 type ('term, 'lazy_term, 'reduction, 'obj, 'ident) statement =
190   | Executable of loc * ('term, 'lazy_term, 'reduction, 'obj, 'ident) code
191   | Comment of loc * ('term, 'lazy_term, 'reduction, 'obj, 'ident) comment
192
193   (* statements meaningful for matitadep *)
194 type dependency =
195   | IncludeDep of string
196   | BaseuriDep of string
197   | UriDep of UriManager.uri
198