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