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