1 (* Copyright (C) 2004, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
26 module Ast = CicNotationPt
28 type direction = [ `LeftToRight | `RightToLeft ]
30 type loc = Ast.location
32 type ('term, 'lazy_term, 'ident) pattern =
33 'lazy_term option * ('ident * 'term) list * 'term
35 type ('term, 'ident) type_spec =
37 | Type of UriManager.uri * int
43 | `Unfold of CicNotationPt.term option
46 type ('term, 'lazy_term, 'reduction, 'ident) tactic =
47 | Absurd of loc * 'term
48 | Apply of loc * 'term
50 | Auto of loc * int option * int option * string option * string option
51 (* depth, width, paramodulation, full *) (* ALB *)
52 | Change of loc * ('term, 'lazy_term, 'ident) pattern * 'lazy_term
53 | Clear of loc * 'ident
54 | ClearBody of loc * 'ident
55 | Compare of loc * 'term
56 | Constructor of loc * int
57 | Contradiction of loc
58 | Cut of loc * 'ident option * 'term
59 | DecideEquality of loc
60 | Decompose of loc * ('term, 'ident) type_spec list * 'ident * 'ident list
61 | Discriminate of loc * 'term
62 | Elim of loc * 'term * 'term option * int option * 'ident list
63 | ElimType of loc * 'term * 'term option * int option * 'ident list
64 | Exact of loc * 'term
67 | Fold of loc * 'reduction * 'lazy_term * ('term, 'lazy_term, 'ident) pattern
69 | FwdSimpl of loc * string * 'ident list
70 | Generalize of loc * ('term, 'lazy_term, 'ident) pattern * 'ident option
71 | Goal of loc * int (* change current goal, argument is goal number 1-based *)
73 | Injection of loc * 'term
74 | Intros of loc * int option * 'ident list
75 | LApply of loc * int option * 'term list * 'term * 'ident option
77 | LetIn of loc * 'term * 'ident
78 | Reduce of loc * 'reduction * ('term, 'lazy_term, 'ident) pattern
80 | Replace of loc * ('term, 'lazy_term, 'ident) pattern * 'lazy_term
81 | Rewrite of loc * direction * 'term *
82 ('term, 'lazy_term, 'ident) pattern
87 | Transitivity of loc * 'term
89 type thm_flavour = Cic.object_flavour
91 (** <name, inductive/coinductive, type, constructor list>
92 * true means inductive, false coinductive *)
93 type 'term inductive_type = string * bool * 'term * (string * 'term) list
95 type search_kind = [ `Locate | `Hint | `Match | `Elim ]
97 type print_kind = [ `Env | `Coer ]
101 | WHint of loc * 'term
102 | WMatch of loc * 'term
103 | WInstance of loc * 'term
104 | WLocate of loc * string
105 | WElim of loc * 'term
108 | Print of loc * string
109 | Check of loc * 'term
112 (* | Redo of loc * int option
113 | Undo of loc * int option *)
114 (* | Print of loc * print_kind *)
115 | Search_pat of loc * search_kind * string (* searches with string pattern *)
116 | Search_term of loc * search_kind * 'term (* searches with term pattern *)
119 | Ident_alias of string * string (* identifier, uri *)
120 | Symbol_alias of string * int * string (* name, instance no, description *)
121 | Number_alias of int * string (* instance no, description *)
124 | Inductive of (string * Ast.term) list *
125 Ast.term inductive_type list
126 (** parameters, list of loc * mutual inductive types *)
127 | Theorem of thm_flavour * string * Ast.term * Ast.term option
128 (** flavour, name, type, body
129 * - name is absent when an unnamed theorem is being proved, tipically in
131 * - body is present when its given along with the command, otherwise it
132 * will be given in proof editing mode using the tactical language
134 | Record of (string * Ast.term) list * string * Ast.term *
135 (string * Ast.term) list
136 (** left parameters, name, type, fields *)
139 | Dependency of string (* baseuri without trailing slash *)
142 let compare_metadata = Pervasives.compare
144 let eq_metadata = (=)
146 (** To be increased each time the command type below changes, used for "safe"
150 type ('term,'obj) command =
151 | Default of loc * string * UriManager.uri list
152 | Include of loc * string
153 | Set of loc * string * string
157 * Name is needed when theorem was started without providing a name
159 | Coercion of loc * 'term
160 | Alias of loc * alias_spec
161 (** parameters, name, type, fields *)
163 | Notation of loc * direction option * Ast.term * Gramext.g_assoc *
165 (* direction, l1 pattern, associativity, precedence, l2 pattern *)
166 | Interpretation of loc *
167 string * (string * Ast.argument_pattern list) *
169 (* description (i.e. id), symbol, arg pattern, appl pattern *)
171 | Metadata of loc * metadata
174 | Dump of loc (* dump grammar on stdout *)
176 | Render of loc * UriManager.uri (* render library object *)
178 (* composed magic: term + command magics. No need to change this value *)
179 let magic = magic + 10000 * CicNotationPt.magic
182 let reash_uri uri = UriManager.uri_of_string (UriManager.string_of_uri uri) in
184 | Default (loc, name, uris) ->
185 let uris = List.map reash_uri uris in
186 Default (loc, name, uris)
187 | Interpretation (loc, dsc, args, cic_appl_pattern) ->
190 | CicNotationPt.UriPattern uri ->
191 CicNotationPt.UriPattern (reash_uri uri)
192 | CicNotationPt.ApplPattern args ->
193 CicNotationPt.ApplPattern (List.map aux args)
194 | CicNotationPt.VarPattern _
195 | CicNotationPt.ImplicitPattern as pat -> pat
197 let appl_pattern = aux cic_appl_pattern in
198 Interpretation (loc, dsc, args, appl_pattern)
201 type ('term, 'lazy_term, 'reduction, 'ident) tactical =
202 | Tactic of loc * ('term, 'lazy_term, 'reduction, 'ident) tactic
203 | Do of loc * int * ('term, 'lazy_term, 'reduction, 'ident) tactical
204 | Repeat of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical
205 | Seq of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical list
206 (* sequential composition *)
207 | Then of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical *
208 ('term, 'lazy_term, 'reduction, 'ident) tactical list
209 | First of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical list
210 (* try a sequence of loc * tactical until one succeeds, fail otherwise *)
211 | Try of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical
212 (* try a tactical and mask failures *)
213 | Solve of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical list
221 | Focus of loc * int list
227 | Dot _ | Semicolon _ | Branch _ | Shift _ | Merge _ | Pos _ -> true
230 type ('term, 'lazy_term, 'reduction, 'obj, 'ident) code =
231 | Command of loc * ('term,'obj) command
232 | Macro of loc * 'term macro
233 | Tactical of loc * ('term, 'lazy_term, 'reduction, 'ident) tactical
234 * ('term, 'lazy_term, 'reduction, 'ident) tactical option(* punctuation *)
236 type ('term, 'lazy_term, 'reduction, 'obj, 'ident) comment =
237 | Note of loc * string
238 | Code of loc * ('term, 'lazy_term, 'reduction, 'obj, 'ident) code
240 type ('term, 'lazy_term, 'reduction, 'obj, 'ident) statement =
241 | Executable of loc * ('term, 'lazy_term, 'reduction, 'obj, 'ident) code
242 | Comment of loc * ('term, 'lazy_term, 'reduction, 'obj, 'ident) comment
244 (* statements meaningful for matitadep *)
246 | IncludeDep of string
247 | BaseuriDep of string
248 | UriDep of UriManager.uri