]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_transformations/tacticAst.ml
version 0.7.1
[helm.git] / helm / ocaml / cic_transformations / tacticAst.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 reduction_kind = [ `Reduce | `Simpl | `Whd | `Normalize ]
28
29 type loc = CicAst.location
30
31 type ('term, 'ident) pattern = 'term option * ('ident * 'term) list * 'term
32
33 type ('term, 'ident) tactic =
34   | Absurd of loc * 'term
35   | Apply of loc * 'term
36   | Assumption of loc
37   | Auto of loc * int option * int option (* depth, width *)
38   | Change of loc * ('term,'ident) pattern * 'term
39   | Clear of loc * 'ident
40   | ClearBody of loc * 'ident
41   | Compare of loc * 'term
42   | Constructor of loc * int
43   | Contradiction of loc
44   | Cut of loc * 'ident option * 'term
45   | DecideEquality of loc
46   | Decompose of loc * 'term
47   | Discriminate of loc * 'term
48   | Elim of loc * 'term * 'term option * int option * 'ident list
49   | ElimType of loc * 'term * 'term option * int option * 'ident list
50   | Exact of loc * 'term
51   | Exists of loc
52   | Fail of loc
53   | Fold of loc * reduction_kind * 'term * ('term, 'ident) pattern
54   | Fourier of loc
55   | FwdSimpl of loc * string * 'ident list
56   | Generalize of loc * ('term, 'ident) pattern * 'ident option
57   | Goal of loc * int (* change current goal, argument is goal number 1-based *)
58   | IdTac of loc
59   | Injection of loc * 'term
60   | Intros of loc * int option * 'ident list
61   | LApply of loc * int option * 'term list * 'term * 'ident option
62   | Left of loc
63   | LetIn of loc * 'term * 'ident
64   | Reduce of loc * reduction_kind * ('term, 'ident) pattern 
65   | Reflexivity of loc
66   | Replace of loc * ('term, 'ident) pattern * 'term
67   | Rewrite of loc * direction * 'term * ('term, 'ident) pattern
68   | Right of loc
69   | Ring of loc
70   | Split of loc
71   | Symmetry of loc
72   | Transitivity of loc * 'term
73
74 type thm_flavour =
75   [ `Definition
76   | `Fact
77   | `Lemma
78   | `Remark
79   | `Theorem
80   ]
81
82   (** <name, inductive/coinductive, type, constructor list>
83   * true means inductive, false coinductive *)
84 type 'term inductive_type = string * bool * 'term * (string * 'term) list
85
86 type search_kind = [ `Locate | `Hint | `Match | `Elim ]
87
88 type print_kind = [ `Env | `Coer ]
89
90 type 'term macro = 
91   (* Whelp's stuff *)
92   | WHint of loc * 'term 
93   | WMatch of loc * 'term 
94   | WInstance of loc * 'term 
95   | WLocate of loc * string
96   | WElim of loc * 'term
97   (* real macros *)
98 (*   | Abort of loc *)
99   | Print of loc * string
100   | Check of loc * 'term 
101   | Hint of loc
102   | Quit of loc
103 (*   | Redo of loc * int option
104   | Undo of loc * int option *)
105 (*   | Print of loc * print_kind *)
106   | Search_pat of loc * search_kind * string  (* searches with string pattern *)
107   | Search_term of loc * search_kind * 'term  (* searches with term pattern *)
108
109 type alias_spec =
110   | Ident_alias of string * string        (* identifier, uri *)
111   | Symbol_alias of string * int * string (* name, instance no, description *)
112   | Number_alias of int * string          (* instance no, description *)
113
114 type obj =
115   | Inductive of (string * CicAst.term) list * CicAst.term inductive_type list
116       (** parameters, list of loc * mutual inductive types *)
117   | Theorem of thm_flavour * string * CicAst.term * CicAst.term option
118       (** flavour, name, type, body
119        * - name is absent when an unnamed theorem is being proved, tipically in
120        *   interactive usage
121        * - body is present when its given along with the command, otherwise it
122        *   will be given in proof editing mode using the tactical language
123        *)
124   | Record of
125      (string * CicAst.term) list * string * CicAst.term *
126       (string * CicAst.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
142 type ('term, 'ident) tactical =
143   | Tactic of loc * ('term, 'ident) tactic
144   | Do of loc * int * ('term, 'ident) tactical
145   | Repeat of loc * ('term, 'ident) tactical
146   | Seq of loc * ('term, 'ident) tactical list (* sequential composition *)
147   | Then of loc * ('term, 'ident) tactical * ('term, 'ident) tactical list
148   | First of loc * ('term, 'ident) tactical list
149       (* try a sequence of loc * tacticals until one succeeds, fail otherwise *)
150   | Try of loc * ('term, 'ident) tactical (* try a tactical and mask failures *)
151   | Solve of loc * ('term, 'ident) tactical list
152
153
154 type ('term, 'obj, 'ident) code =
155   | Command of loc * ('term,'obj) command
156   | Macro of loc * 'term macro 
157       (* Macro are substantially queries, but since we are not the kind of
158        * peolpe that like to push "start" to turn off the computer 
159        * we added this command *)
160   | Tactical of loc * ('term, 'ident) tactical
161              
162 type ('term, 'obj, 'ident) comment =
163   | Note of loc * string
164   | Code of loc * ('term, 'obj, 'ident) code
165              
166 type ('term, 'obj, 'ident) statement =
167   | Executable of loc * ('term, 'obj, 'ident) code
168   | Comment of loc * ('term, 'obj, 'ident) comment
169