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