Debian Codegraph @

plugins/ltac/tacentries.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 (** Ltac toplevel command entries. *)
12
13 open Vernacexpr
14 open Tacexpr
15
16 (** {5 Tactic Definitions} *)
17
18 val register_ltac : Attributes.vernac_flags -> Tacexpr.tacdef_body list -> unit
19 (** Adds new Ltac definitions to the environment. *)
20
21 (** {5 Tactic Notations} *)
22
23 type 'a grammar_tactic_prod_item_expr = 'a Pptactic.grammar_tactic_prod_item_expr =
24 | TacTerm of string
25 | TacNonTerm of ('a * Names.Id.t option) Loc.located
26
27 type tactic_grammar_obj
28
29 type raw_argument = string * string option
30 (** An argument type as provided in Tactic notations, i.e. a string like
31 "ne_foo_list_opt" together with a separator that only makes sense in the
32 "_sep" cases. *)
33
34 type argument = Genarg.ArgT.any Extend.user_symbol
35 (** A fully resolved argument type given as an AST with generic arguments on the
36 leaves. *)
37
38 val add_tactic_notation :
39 ?deprecation:Deprecation.t -> tactic_grammar_obj ->
40 raw_tactic_expr -> unit
41 (** [add_tactic_notation local level prods expr] adds a tactic notation in the
42 environment at level [level] with locality [local] made of the grammar
43 productions [prods] and returning the body [expr] *)
44
45 val add_tactic_notation_syntax :
46 locality_flag -> int -> ?deprecation:Deprecation.t -> raw_argument
47 grammar_tactic_prod_item_expr list ->
48 tactic_grammar_obj
49
50 val register_tactic_notation_entry : string -> ('a, 'b, 'c) Genarg.genarg_type -> unit
51 (** Register an argument under a given entry name for tactic notations. When
52 translating [raw_argument] into [argument], atomic names will be first
53 looked up according to names registered through this function and fallback
54 to finding an argument by name (as in {!Genarg}) if there is none
55 matching. *)
56
57 (** {5 Tactic Quotations} *)
58
59 val create_ltac_quotation : plugin:string -> string ->
60 ('grm Loc.located -> raw_tactic_arg) -> ('grm Procq.Entry.t * int option) -> unit
61 (** [create_ltac_quotation name f e] adds a quotation rule to Ltac, that is,
62 Ltac grammar now accepts arguments of the form ["name" ":" "(" <e> ")"], and
63 generates an argument using [f] on the entry parsed by [e]. *)
64
65 (** {5 Queries} *)
66
67 val print_ltacs : unit -> unit
68 (** Display the list of ltac definitions currently available. *)
69
70 val print_located_tactic : Libnames.qualid -> unit
71 (** Display the absolute name of a tactic. *)
72
73 val print_ltac : Libnames.qualid -> Pp.t
74 (** Display the definition of a tactic. *)
75
76 (** {5 Low-level registering of tactics} *)
77
78 type (_, 'a) ml_ty_sig =
79 | MLTyNil : ('a, 'a) ml_ty_sig
80 | MLTyArg : ('r, 'a) ml_ty_sig -> (Geninterp.Val.t -> 'r, 'a) ml_ty_sig
81
82 val ml_tactic_extend : plugin:string -> name:string -> local:locality_flag ->
83 ?deprecation:Deprecation.t -> ('r, unit Proofview.tactic) ml_ty_sig -> 'r -> unit
84 (** Helper function to define directly an Ltac function in OCaml without any
85 associated parsing rule nor further shenanigans. The Ltac function will be
86 defined as [name] in the Rocq file that loads the ML plugin where this
87 function is called. It will have the arity given by the [ml_ty_sig]
88 argument. *)
89
90 val ml_val_tactic_extend : plugin:string -> name:string -> local:locality_flag ->
91 ?deprecation:Deprecation.t -> ('r, Geninterp.Val.t Ftactic.t) ml_ty_sig -> 'r -> unit
92 (** Same as {!ml_tactic_extend} but the function can return an argument
93 instead. *)
94
95 (** {5 TACTIC EXTEND} *)
96
97 type _ ty_sig =
98 | TyNil : (Geninterp.interp_sign -> unit Proofview.tactic) ty_sig
99 | TyIdent : string * 'r ty_sig -> 'r ty_sig
100 | TyArg : ('a, 'b, 'c) Extend.ty_user_symbol * 'r ty_sig -> ('c -> 'r) ty_sig
101
102 type ty_ml = TyML : 'r ty_sig * 'r -> ty_ml
103
104 val tactic_extend : string -> string -> level:Int.t ->
105 ?deprecation:Deprecation.t -> ty_ml list -> unit
106
107 val eval_of_ty_ml :
108 ty_ml ->
109 Geninterp.Val.t list ->
110 Geninterp.interp_sign ->
111 unit Proofview.tactic
112
113 (** grammar rule for [add_tactic_notation] *)
114 val clause_of_ty_ml :
115 ty_ml ->
116 Genarg.ArgT.any Extend.user_symbol grammar_tactic_prod_item_expr list
117
118 (** {5 ARGUMENT EXTEND} *)
119
120 (**
121
122 This is the main entry point for the ARGUMENT EXTEND macro that allows to
123 easily create user-made Ltac arguments.
124
125
126 Each argument has three type parameters. See {!Genarg} for more details.
127 There are two kinds of Ltac arguments, uniform and non-uniform. The former
128 have the same type at each level (raw, glob, top) while the latter may vary.
129
130 When declaring an argument one must provide the following data:
131 - Internalization : raw -> glob
132 - Substitution : glob -> glob
133 - Interpretation : glob -> Ltac dynamic value
134 - Printing for every level
135 - An optional toplevel tag of type top (with the proviso that the
136 interpretation function only produces values with this tag)
137
138 This data can be either given explicitly with the [Fun] constructors, or it
139 can be inherited from another argument with the [Wit] constructors.
140
141 *)
142
143 type ('a, 'b, 'c) argument_printer =
144 'a Pptactic.raw_extra_genarg_printer *
145 'b Pptactic.glob_extra_genarg_printer *
146 'c Pptactic.extra_genarg_printer
147
148 type ('a, 'b) argument_intern =
149 | ArgInternFun : ('a, 'b) Genintern.intern_fun -> ('a, 'b) argument_intern
150 | ArgInternWit : ('a, 'b, 'c) Genarg.genarg_type -> ('a, 'b) argument_intern
151
152 type 'b argument_subst =
153 | ArgSubstFun : 'b Gensubst.subst_fun -> 'b argument_subst
154 | ArgSubstWit : ('a, 'b, 'c) Genarg.genarg_type -> 'b argument_subst
155
156 type ('b, 'c) argument_interp =
157 | ArgInterpRet : ('c, 'c) argument_interp
158 | ArgInterpFun : ('b, Geninterp.Val.t) Geninterp.interp_fun -> ('b, 'c) argument_interp
159 | ArgInterpWit : ('a, 'b, 'r) Genarg.genarg_type -> ('b, 'c) argument_interp
160 | ArgInterpSimple :
161 (Geninterp.interp_sign -> Environ.env -> Evd.evar_map -> 'b -> 'c) -> ('b, 'c) argument_interp
162
163 type ('a, 'b, 'c) tactic_argument = {
164 arg_parsing : 'a Vernacextend.argument_rule;
165 arg_tag : 'c Geninterp.Val.tag option;
166 arg_intern : ('a, 'b) argument_intern;
167 arg_subst : 'b argument_subst;
168 arg_interp : ('b, 'c) argument_interp;
169 arg_printer : ('a, 'b, 'c) argument_printer;
170 }
171
172 val argument_extend : plugin:string -> name:string -> ignore_kw:bool ->
173 ('a, 'b, 'c) tactic_argument ->
174 ('a, 'b, 'c) Genarg.genarg_type * 'a Procq.Entry.t