Debian Codegraph @

plugins/ltac2/tac2env.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 Genarg
12 open Names
13 open Libnames
14 open Nametab
15 open Tac2expr
16 open Tac2val
17
18 (** Ltac2 global environment *)
19
20 (** {5 Toplevel definition of values} *)
21
22 type global_data = {
23 gdata_expr : glb_tacexpr;
24 gdata_type : type_scheme;
25 gdata_mutable : bool;
26 gdata_deprecation : Deprecation.t option;
27 gdata_mutation_history : ModPath.t list;
28 }
29
30 val define_global : ltac_constant -> global_data -> unit
31 val interp_global : ltac_constant -> global_data
32
33 type compile_info = {
34 source : string;
35 }
36
37 val set_compiled_global : ltac_constant -> compile_info -> valexpr -> unit
38 val get_compiled_global : ltac_constant -> (compile_info * valexpr) option
39
40 val globals : unit -> global_data KerName.Map.t
41
42 (** {5 Toplevel definition of types} *)
43
44 val define_type : type_constant -> glb_quant_typedef -> unit
45 val interp_type : type_constant -> glb_quant_typedef
46
47 (** {5 Toplevel definition of algebraic constructors} *)
48
49 type constructor_data = {
50 cdata_prms : int;
51 (** Type parameters *)
52 cdata_type : type_constant;
53 (** Inductive definition to which the constructor pertains *)
54 cdata_args : int glb_typexpr list;
55 (** Types of the constructor arguments *)
56 cdata_indx : int option;
57 (** Index of the constructor in the ADT. Numbering is duplicated between
58 argumentless and argument-using constructors, e.g. in type ['a option]
59 [None] and [Some] have both index 0. This field is empty whenever the
60 constructor is a member of an open type. *)
61 }
62
63 val define_constructor : ltac_constructor -> constructor_data -> unit
64 val interp_constructor : ltac_constructor -> constructor_data
65
66 val find_all_constructors_in_type : type_constant -> constructor_data KerName.Map.t
67 (** Useful for printing info about currently defined constructors of open types. *)
68
69 (** {5 Toplevel definition of projections} *)
70
71 type projection_data = {
72 pdata_prms : int;
73 (** Type parameters *)
74 pdata_type : type_constant;
75 (** Record definition to which the projection pertains *)
76 pdata_ptyp : int glb_typexpr;
77 (** Type of the projection *)
78 pdata_mutb : bool;
79 (** Whether the field is mutable *)
80 pdata_indx : int;
81 (** Index of the projection *)
82 }
83
84 val define_projection : ltac_projection -> projection_data -> unit
85 val interp_projection : ltac_projection -> projection_data
86
87 (** {5 Toplevel definition of aliases} *)
88
89 type alias_data = {
90 alias_body : raw_tacexpr;
91 alias_depr : Deprecation.t option;
92 }
93
94 val define_alias : ?deprecation:Deprecation.t -> ltac_constant -> raw_tacexpr -> unit
95 val interp_alias : ltac_constant -> alias_data
96
97 (** {5 Toplevel definition of notations} *)
98
99 (* no deprecation info: deprecation warning is emitted by the parser *)
100 type notation_data =
101 | UntypedNota of raw_tacexpr
102 | TypedNota of {
103 nota_prms : int;
104 nota_argtys : int glb_typexpr Id.Map.t;
105 nota_ty : int glb_typexpr;
106 nota_body : glb_tacexpr;
107 }
108
109 val define_notation : ltac_notation -> notation_data -> unit
110 val interp_notation : ltac_notation -> notation_data
111
112 (** {5 Name management} *)
113
114 val push_ltac : visibility -> full_path -> tacref -> unit
115 val locate_ltac : qualid -> tacref
116 val locate_extended_all_ltac : qualid -> tacref list
117 val shortest_qualid_of_ltac : ?loc:Loc.t -> ?force_short:bool -> Id.Set.t -> tacref -> qualid
118 val path_of_ltac : tacref -> full_path
119
120 val push_constructor : ?user_warns:UserWarn.t -> visibility -> full_path -> ltac_constructor -> unit
121 val locate_constructor : qualid -> ltac_constructor
122 val locate_extended_all_constructor : qualid -> ltac_constructor list
123 val shortest_qualid_of_constructor : ltac_constructor -> qualid
124 val path_of_constructor : ltac_constructor -> full_path
125
126 val push_type : visibility -> full_path -> type_constant -> unit
127 val locate_type : qualid -> type_constant
128 val locate_extended_all_type : qualid -> type_constant list
129 val shortest_qualid_of_type : ?loc:Loc.t -> type_constant -> qualid
130 val path_of_type : type_constant -> full_path
131
132 val push_projection : visibility -> full_path -> ltac_projection -> unit
133 val locate_projection : qualid -> ltac_projection
134 val locate_extended_all_projection : qualid -> ltac_projection list
135 val shortest_qualid_of_projection : ltac_projection -> qualid
136
137 (** {5 Toplevel definitions of ML tactics} *)
138
139 (** This state is not part of the summary, contrarily to the ones above. It is
140 intended to be used from ML plugins to register ML-side functions. *)
141
142 val define_primitive : ml_tactic_name -> valexpr -> unit
143 val interp_primitive : ml_tactic_name -> valexpr
144
145 (** {5 ML primitive types} *)
146
147 type 'a or_glb_tacexpr =
148 | GlbVal of 'a
149 | GlbTacexpr of glb_tacexpr
150
151 type ('a, 'b, 'r) intern_fun = Genintern.glob_sign -> 'a -> 'b * 'r glb_typexpr
152
153 type environment = {
154 env_ist : valexpr Id.Map.t;
155 }
156
157 type ('a, 'b) ml_object = {
158 ml_intern : 'r. ('a, 'b or_glb_tacexpr, 'r) intern_fun;
159 ml_subst : Mod_subst.substitution -> 'b -> 'b;
160 ml_interp : environment -> 'b -> valexpr Proofview.tactic;
161 ml_print : Environ.env -> Evd.evar_map -> 'b -> Pp.t;
162 ml_raw_print : Environ.env -> Evd.evar_map -> 'a -> Pp.t;
163 }
164
165 val define_ml_object : ('a, 'b) Tac2dyn.Arg.tag -> ('a, 'b) ml_object -> unit
166 val interp_ml_object : ('a, 'b) Tac2dyn.Arg.tag -> ('a, 'b) ml_object
167
168 (** {5 Absolute paths} *)
169
170 val rocq_prefix : ModPath.t
171 (** Path where primitive datatypes are defined in Ltac2 plugin. *)
172
173 val coq_prefix : ModPath.t [@@ocaml.deprecated "(9.0) Use rocq_prefix"]
174 (** Path where primitive datatypes are defined in Ltac2 plugin. *)
175
176 val std_prefix : ModPath.t
177 (** Path where Ltac-specific datatypes are defined in Ltac2 plugin. *)
178
179 val ltac1_prefix : ModPath.t
180 (** Path where the Ltac1 legacy FFI is defined. *)
181
182 (** {5 Generic arguments} *)
183
184 val wit_ltac2_constr : (raw_tacexpr, Id.Set.t * glb_tacexpr, Util.Empty.t) genarg_type
185 (** Ltac2 quotations in Gallina terms *)
186
187 val wit_ltac2_tac : (raw_tacexpr, glb_tacexpr, unit) genarg_type
188 (** Ltac2 as a generic tactic depending on proof mode (eg as argument to Solve Obligations) *)
189
190 type var_quotation_kind =
191 | ConstrVar
192 | PretermVar
193 | PatternVar
194 | HypVar
195
196 val wit_ltac2_var_quotation : (lident option * lident, var_quotation_kind * Id.t, Util.Empty.t) genarg_type
197 (** Ltac2 quotations for variables "$x" or "$kind:foo" in Gallina terms.
198 NB: "$x" means "$constr:x" *)
199
200 (** {5 Helper functions} *)
201
202 val is_constructor_id : Id.t -> bool
203 val is_constructor : qualid -> bool