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