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