Debian Codegraph @

plugins/ltac/tacexpr.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Loc
12 open Names
13 open Constrexpr
14 open Libnames
15 open Genredexpr
16 open Genarg
17 open Pattern
18 open Locus
19 open Tactypes
20
21 type ltac_constant = KerName.t
22
23 type direction_flag = bool (* true = Left-to-right false = right-to-right *)
24 type lazy_flag =
25 | General (* returns all possible successes *)
26 | Select (* returns all successes of the first matching branch *)
27 | Once (* returns the first success in a matching branch
28 (not necessarily the first) *)
29 type global_flag = (* [gfail] or [fail] *)
30 | TacGlobal
31 | TacLocal
32 type evars_flag = bool (* true = pose evars false = fail on evars *)
33 type rec_flag = bool (* true = recursive false = not recursive *)
34 type advanced_flag = bool (* true = advanced false = basic *)
35 type letin_flag = bool (* true = use local def false = use Leibniz *)
36 type clear_flag = bool option (* true = clear hyp, false = keep hyp, None = use default *)
37 type check_flag = bool (* true = check false = do not check *)
38
39 type ('c,'d,'id) inversion_strength =
40 | NonDepInversion of
41 Inv.inversion_kind * 'id list * 'd or_and_intro_pattern_expr CAst.t or_var option
42 | DepInversion of
43 Inv.inversion_kind * 'c option * 'd or_and_intro_pattern_expr CAst.t or_var option
44 | InversionUsing of 'c * 'id list
45
46 type 'id message_token =
47 | MsgString of string
48 | MsgInt of int
49 | MsgIdent of 'id
50
51 type ('dconstr,'id) induction_clause =
52 'dconstr with_bindings Tactics.destruction_arg *
53 (Namegen.intro_pattern_naming_expr CAst.t option (* eqn:... *)
54 * 'dconstr or_and_intro_pattern_expr CAst.t or_var option) (* as ... *)
55 * 'id clause_expr option (* in ... *)
56
57 type ('constr,'dconstr,'id) induction_clause_list =
58 ('dconstr,'id) induction_clause list
59 * 'constr with_bindings option (* using ... *)
60
61 type 'a with_bindings_arg = clear_flag * 'a with_bindings
62
63 (* Type of patterns *)
64 type 'a match_pattern =
65 | Term of 'a
66 | Subterm of Id.t option * 'a
67
68 (* Type of hypotheses for a Match Context rule *)
69 type 'a match_context_hyps =
70 | Hyp of lname * 'a match_pattern
71 | Def of lname * 'a match_pattern * 'a match_pattern
72
73 (* Type of a Match rule for Match Context and Match *)
74 type ('a,'t) match_rule =
75 | Pat of 'a match_context_hyps list * 'a match_pattern * 't
76 | All of 't
77
78 (** Extension indentifiers for the TACTIC EXTEND mechanism. *)
79 type ml_tactic_name = {
80 mltac_plugin : string;
81 (** Name of the plugin where the tactic is defined, typically coming from a
82 DECLARE PLUGIN statement in the source. *)
83 mltac_tactic : string;
84 (** Name of the tactic entry where the tactic is defined, typically found
85 after the TACTIC EXTEND statement in the source. *)
86 }
87
88 type ml_tactic_entry = {
89 mltac_name : ml_tactic_name;
90 mltac_index : int;
91 }
92
93 (** Composite types *)
94 type open_constr_expr = unit * constr_expr
95 type open_glob_constr = unit * Genintern.glob_constr_and_expr
96
97 type intro_pattern = delayed_open_constr intro_pattern_expr CAst.t
98 type intro_patterns = delayed_open_constr intro_pattern_expr CAst.t list
99 type or_and_intro_pattern = delayed_open_constr or_and_intro_pattern_expr CAst.t
100 type intro_pattern_naming = Namegen.intro_pattern_naming_expr CAst.t
101
102 (** Generic expressions for atomic tactics *)
103
104 type 'a gen_atomic_tactic_expr =
105 (* Basic tactics *)
106 | TacIntroPattern of evars_flag * 'dtrm intro_pattern_expr CAst.t list
107 | TacApply of advanced_flag * evars_flag * 'trm with_bindings_arg list *
108 ('nam * 'dtrm intro_pattern_expr CAst.t option) list
109 | TacElim of evars_flag * 'trm with_bindings_arg * 'trm with_bindings option
110 | TacCase of evars_flag * 'trm with_bindings_arg
111 | TacMutualFix of Id.t * int * (Id.t * int * 'trm) list
112 | TacMutualCofix of Id.t * (Id.t * 'trm) list
113 | TacAssert of
114 evars_flag * bool * 'tacexpr option option *
115 'dtrm intro_pattern_expr CAst.t option * 'trm
116 | TacGeneralize of (('occvar occurrences_gen * 'trm) * Name.t) list
117 | TacLetTac of evars_flag * Name.t * 'trm * 'nam clause_expr * letin_flag *
118 Namegen.intro_pattern_naming_expr CAst.t option
119
120 (* Derived basic tactics *)
121 | TacInductionDestruct of
122 rec_flag * evars_flag * ('trm,'dtrm,'nam) induction_clause_list
123
124 (* Conversion *)
125 | TacReduce of ('trm,'cst,'rpat,'occvar, 'lev Redexpr.user_red_expr) red_expr_gen * 'nam clause_expr
126 | TacChange of check_flag * 'rpat option * 'dtrm * 'nam clause_expr
127
128 (* Equality and inversion *)
129 | TacRewrite of evars_flag *
130 (bool * Equality.multi * 'dtrm with_bindings_arg) list * 'nam clause_expr *
131 (* spiwack: using ['dtrm] here is a small hack, may not be
132 stable by a change in the representation of delayed
133 terms. Because, in fact, it is the whole "with_bindings"
134 which is delayed. But because the "t" level for ['dtrm] is
135 uninterpreted, it works fine here too, and avoid more
136 disruption of this file. *)
137 'tacexpr option
138 | TacInversion of ('trm,'dtrm,'nam) inversion_strength * quantified_hypothesis
139
140 constraint 'a = <
141 term:'trm;
142 dterm: 'dtrm;
143 pattern:'pat;
144 red_pattern:'rpat;
145 constant:'cst;
146 reference:'ref;
147 name:'nam;
148 occvar:'occvar;
149 tacexpr:'tacexpr;
150 level:'lev
151 >
152
153 (** Possible arguments of a tactic definition *)
154
155 type ('a,'b,'c,'occvar,'usr) may_eval =
156 | ConstrTerm of 'a
157 | ConstrEval of ('a,'b,'c,'occvar, 'usr) red_expr_gen * 'a
158 | ConstrContext of Names.lident * 'a
159 | ConstrTypeOf of 'a
160
161 type 'a gen_tactic_arg =
162 | TacGeneric of string option * 'lev generic_argument
163 | ConstrMayEval of ('trm,'cst,'rpat, 'occvar, 'lev Redexpr.user_red_expr) may_eval
164 | Reference of 'ref
165 | TacCall of ('ref * 'a gen_tactic_arg list) CAst.t
166 | TacFreshId of string or_var list
167 | Tacexp of 'tacexpr
168 | TacPretype of 'trm
169 | TacNumgoals
170
171 constraint 'a = <
172 term:'trm;
173 dterm: 'dtrm;
174 pattern:'pat;
175 red_pattern:'rpat;
176 constant:'cst;
177 reference:'ref;
178 name:'nam;
179 occvar:'occvar;
180 tacexpr:'tacexpr;
181 level:'lev
182 >
183
184 (** Generic ltac expressions.
185 't : terms, 'p : patterns, 'c : constants, 'i : inductive,
186 'r : ltac refs, 'n : idents, 'l : levels *)
187
188 and 'a gen_tactic_expr_r =
189 | TacAtom of 'a gen_atomic_tactic_expr
190 | TacThen of
191 'a gen_tactic_expr *
192 'a gen_tactic_expr
193 | TacDispatch of
194 'a gen_tactic_expr list
195 | TacExtendTac of
196 'a gen_tactic_expr array *
197 'a gen_tactic_expr *
198 'a gen_tactic_expr array
199 | TacThens of
200 'a gen_tactic_expr *
201 'a gen_tactic_expr list
202 | TacThens3parts of
203 'a gen_tactic_expr *
204 'a gen_tactic_expr array *
205 'a gen_tactic_expr *
206 'a gen_tactic_expr array
207 | TacFirst of 'a gen_tactic_expr list
208 | TacSolve of 'a gen_tactic_expr list
209 | TacTry of 'a gen_tactic_expr
210 | TacOr of
211 'a gen_tactic_expr *
212 'a gen_tactic_expr
213 | TacOnce of
214 'a gen_tactic_expr
215 | TacExactlyOnce of
216 'a gen_tactic_expr
217 | TacIfThenCatch of
218 'a gen_tactic_expr *
219 'a gen_tactic_expr *
220 'a gen_tactic_expr
221 | TacOrelse of
222 'a gen_tactic_expr *
223 'a gen_tactic_expr
224 | TacDo of int or_var * 'a gen_tactic_expr
225 | TacTimeout of int or_var * 'a gen_tactic_expr
226 | TacTime of string option * 'a gen_tactic_expr
227 | TacRepeat of 'a gen_tactic_expr
228 | TacProgress of 'a gen_tactic_expr
229 | TacAbstract of
230 'a gen_tactic_expr * Id.t option
231 | TacId of 'n message_token list
232 | TacFail of global_flag * int or_var * 'n message_token list
233 | TacLetIn of rec_flag *
234 (lname * 'a gen_tactic_arg) list *
235 'a gen_tactic_expr
236 | TacMatch of lazy_flag *
237 'a gen_tactic_expr *
238 ('p,'a gen_tactic_expr) match_rule list
239 | TacMatchGoal of lazy_flag * direction_flag *
240 ('p,'a gen_tactic_expr) match_rule list
241 | TacFun of 'a gen_tactic_fun_ast
242 | TacArg of 'a gen_tactic_arg
243 | TacSelect of Goal_select.t * 'a gen_tactic_expr
244 (* For ML extensions *)
245 | TacML of ml_tactic_entry * 'a gen_tactic_arg list
246 (* For syntax extensions *)
247 | TacAlias of KerName.t * 'a gen_tactic_arg list
248
249 constraint 'a = <
250 term:'t;
251 dterm: 'dtrm;
252 pattern:'p;
253 red_pattern:'rp;
254 constant:'c;
255 reference:'r;
256 name:'n;
257 occvar:'occvar;
258 tacexpr:'tacexpr;
259 level:'l
260 >
261
262 and 'a gen_tactic_expr =
263 'a gen_tactic_expr_r CAst.t
264
265 constraint 'a = <
266 term:'t;
267 dterm: 'dtrm;
268 pattern:'p;
269 red_pattern:'rp;
270 constant:'c;
271 reference:'r;
272 name:'n;
273 occvar:'occvar;
274 tacexpr:'tacexpr;
275 level:'l
276 >
277
278 and 'a gen_tactic_fun_ast =
279 Name.t list * 'a gen_tactic_expr
280
281 constraint 'a = <
282 term:'t;
283 dterm: 'dtrm;
284 pattern:'p;
285 red_pattern:'rp;
286 constant:'c;
287 reference:'r;
288 name:'n;
289 occvar:'occvar;
290 tacexpr:'te;
291 level:'l
292 >
293
294 (** Globalized tactics *)
295
296 type g_trm = Genintern.glob_constr_and_expr
297 type g_pat = Genintern.glob_constr_pattern_and_expr
298 type g_cst = Evaluable.t Genredexpr.and_short_name or_var
299 type g_ref = ltac_constant located or_var
300 type g_nam = lident
301 type g_occvar = int or_var
302
303 type g_dispatch = <
304 term:g_trm;
305 dterm:g_trm;
306 pattern:g_pat;
307 red_pattern:g_trm;
308 constant:g_cst;
309 reference:g_ref;
310 name:g_nam;
311 occvar:g_occvar;
312 tacexpr:glob_tactic_expr;
313 level:glevel
314 >
315
316 and glob_tactic_expr =
317 g_dispatch gen_tactic_expr
318
319 type glob_atomic_tactic_expr =
320 g_dispatch gen_atomic_tactic_expr
321
322 type glob_tactic_arg =
323 g_dispatch gen_tactic_arg
324
325 (** Raw tactics *)
326
327 type r_ref = qualid
328 type r_nam = lident
329 type r_lev = rlevel
330 type r_occvar = int or_var
331
332 type r_dispatch = <
333 term:r_trm;
334 dterm:r_trm;
335 pattern:r_pat;
336 red_pattern:r_pat;
337 constant:r_cst;
338 reference:r_ref;
339 name:r_nam;
340 occvar:r_occvar;
341 tacexpr:raw_tactic_expr;
342 level:rlevel
343 >
344
345 and raw_tactic_expr =
346 r_dispatch gen_tactic_expr
347
348 type raw_atomic_tactic_expr =
349 r_dispatch gen_atomic_tactic_expr
350
351 type raw_tactic_arg =
352 r_dispatch gen_tactic_arg
353
354 (** Interpreted tactics *)
355
356 type t_trm = EConstr.constr
357 type t_pat = constr_pattern
358 type t_cst = Evaluable.t
359 type t_ref = ltac_constant located
360 type t_nam = Id.t
361 type t_occvar = int
362
363 type t_dispatch = <
364 term:t_trm;
365 dterm:g_trm;
366 pattern:t_pat;
367 red_pattern:t_pat;
368 constant:t_cst;
369 reference:t_ref;
370 name:t_nam;
371 occvar:t_occvar;
372 tacexpr:unit;
373 level:tlevel
374 >
375
376 type atomic_tactic_expr =
377 t_dispatch gen_atomic_tactic_expr
378
379 (** Misc *)
380
381 type raw_strategy = (constr_expr, Redexpr.raw_red_expr, lident) Rewrite.strategy_ast
382 type glob_strategy = (Genintern.glob_constr_and_expr, Redexpr.glob_red_expr, Id.t) Rewrite.strategy_ast
383
384 (** Traces *)
385
386 type ltac_call_kind =
387 | LtacMLCall of glob_tactic_expr
388 | LtacNotationCall of KerName.t
389 | LtacNameCall of ltac_constant
390 | LtacAtomCall of glob_atomic_tactic_expr
391 | LtacVarCall of KerName.t option * Id.t * glob_tactic_expr
392 | LtacConstrInterp of Environ.env * Evd.evar_map * Glob_term.glob_constr * Ltac_pretype.ltac_var_map
393
394 type ltac_stack = ltac_call_kind Loc.located list
395 type ltac_trace = ltac_stack * Geninterp.Val.t Id.Map.t list
396
397 type tacdef_body =
398 | TacticDefinition of lident * raw_tactic_expr (* indicates that user employed ':=' in Ltac body *)
399 | TacticRedefinition of qualid * raw_tactic_expr (* indicates that user employed '::=' in Ltac body *)