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