Debian Codegraph @

tactics/hints.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 Util
12 open Names
13 open EConstr
14 open Environ
15 open Evd
16 open Tactypes
17 open Typeclasses
18
19 (** {6 General functions. } *)
20
21 exception Bound
22
23 val decompose_app_bound : evar_map -> constr -> GlobRef.t * constr array
24
25 type debug = Debug | Info | Off
26
27 val secvars_of_hyps : ('c, 't,'r) Context.Named.pt -> Id.Pred.t
28
29 val empty_hint_info : 'a Typeclasses.hint_info_gen
30
31 val hint_cat : Libobject.category
32
33 (** Pre-created hint databases *)
34
35 type 'a hint_ast =
36 | Res_pf of 'a (* Hint Apply *)
37 | ERes_pf of 'a (* Hint EApply *)
38 | Give_exact of 'a
39 | Res_pf_THEN_trivial_fail of 'a (* Hint Immediate *)
40 | Unfold_nth of Evaluable.t (* Hint Unfold *)
41 | Extern of Pattern.constr_pattern option * Gentactic.glob_generic_tactic (* Hint Extern *)
42
43 type hint
44
45 val hint_as_term : hint -> UnivGen.sort_context_set option * constr
46
47 type 'a hints_path_atom_gen =
48 | PathHints of 'a list
49 (* For forward hints, their names is the list of projections *)
50 | PathAny
51
52 type hints_path_atom = GlobRef.t hints_path_atom_gen
53 type hint_db_name = string
54
55 module FullHint :
56 sig
57 type t
58 val priority : t -> int
59 val pattern : t -> Pattern.constr_pattern option
60 val database : t -> string option
61 val run : t -> (hint hint_ast -> 'r Proofview.tactic) -> 'r Proofview.tactic
62 val name : t -> GlobRef.t option
63 val print : env -> evar_map -> t -> Pp.t
64 val subgoals : t -> int option
65
66 (** This function is for backward compatibility only, not to use in newly
67 written code. *)
68 val repr : t -> hint hint_ast
69 end
70
71 (** The head may not be bound. *)
72
73 type hint_mode =
74 | ModeInput (* No evars *)
75 | ModeNoHeadEvar (* No evar at the head *)
76 | ModeOutput (* Anything *)
77
78 type 'a hints_transparency_target =
79 | HintsVariables
80 | HintsConstants
81 | HintsProjections
82 | HintsReferences of 'a list
83
84 type 'a hints_path_gen =
85 | PathAtom of 'a hints_path_atom_gen
86 | PathStar of 'a hints_path_gen
87 | PathSeq of 'a hints_path_gen * 'a hints_path_gen
88 | PathOr of 'a hints_path_gen * 'a hints_path_gen
89 | PathEmpty
90 | PathEpsilon
91
92 type pre_hints_path = Libnames.qualid hints_path_gen
93 type hints_path = GlobRef.t hints_path_gen
94
95 val path_matches_epsilon : hints_path -> bool
96 val path_derivate : env -> hints_path -> GlobRef.t option -> hints_path
97 val pp_hints_path_gen : ('a -> Pp.t) -> 'a hints_path_gen -> Pp.t
98
99 val parse_mode : string -> hint_mode
100 val parse_modes : string -> hint_mode list
101 val string_of_mode : hint_mode -> string
102 val pp_hint_mode : hint_mode -> Pp.t
103 val glob_hints_path : pre_hints_path -> hints_path
104
105 type mode_match =
106 | NoMode
107 | WithMode of hint_mode array
108
109 type 'a with_mode =
110 | ModeMatch of mode_match * 'a
111 | ModeMismatch
112
113 module Modes :
114 sig
115 type t
116 val empty : t
117 val union : t -> t -> t
118 end
119
120 module Hint_db :
121 sig
122 type t
123 val empty : ?name:hint_db_name -> TransparentState.t -> bool -> t
124
125 (** All hints which have no pattern.
126 * [secvars] represent the set of section variables that
127 * can be used in the hint. *)
128 val map_none : secvars:Id.Pred.t -> t -> FullHint.t list
129
130 (** All hints associated to the reference *)
131 val map_all : secvars:Id.Pred.t -> GlobRef.t -> t -> FullHint.t list
132
133 (** All hints associated to the reference, respecting modes if evars appear in the
134 arguments and using the discrimination net.
135 Returns a [ModeMismatch] if there are declared modes and none matches. *)
136 val map_eauto : env -> evar_map -> secvars:Id.Pred.t -> (GlobRef.t * constr array) -> constr -> t -> FullHint.t list with_mode
137
138 (** All hints associated to the reference.
139 Precondition: no evars should appear in the arguments, so no modes
140 are checked. *)
141 val map_auto : env -> evar_map -> secvars:Id.Pred.t ->
142 (GlobRef.t * constr array) -> constr -> t -> FullHint.t list
143
144 val remove_one : Environ.env -> GlobRef.t -> t -> t
145 val remove_list : Environ.env -> GlobRef.t list -> t -> t
146 val iter : (GlobRef.t option ->
147 hint_mode array list -> FullHint.t list -> unit) -> t -> unit
148
149 val fold : (GlobRef.t option -> hint_mode array list -> FullHint.t list -> 'a -> 'a) -> t -> 'a -> 'a
150
151 val use_dn : t -> bool
152 val transparent_state : t -> TransparentState.t
153 val set_transparent_state : t -> TransparentState.t -> t
154
155 val add_cut : env -> hints_path -> t -> t
156 val cut : t -> hints_path
157
158 val unfolds : t -> Id.Set.t * Cset.t * PRset.t
159
160 val add_modes : Modes.t -> t -> t
161 val modes : t -> Modes.t
162 val find_mode : env -> GlobRef.t -> t -> hint_mode array list
163 end
164
165 type hint_db = Hint_db.t
166
167 type hnf = bool
168
169 type hints_entry =
170 | HintsResolveEntry of (hint_info * hnf * GlobRef.t) list
171 | HintsImmediateEntry of GlobRef.t list
172 | HintsCutEntry of hints_path
173 | HintsUnfoldEntry of Evaluable.t list
174 | HintsTransparencyEntry of Evaluable.t hints_transparency_target * bool
175 | HintsModeEntry of GlobRef.t * hint_mode list
176 | HintsExternEntry of hint_info * Gentactic.glob_generic_tactic
177
178 val searchtable_map : hint_db_name -> hint_db
179
180 val searchtable_add : (hint_db_name * hint_db) -> unit
181
182 type hint_locality = Libobject.locality = Local | Export | SuperGlobal
183
184 (** [create_hint_db local name st use_dn].
185 [st] is a transparency state for unification using this db
186 [use_dn] switches the use of the discrimination net for all hints
187 and patterns. *)
188
189 val create_hint_db : bool -> hint_db_name -> TransparentState.t -> bool -> unit
190
191 val remove_hints : locality:hint_locality -> hint_db_name list -> GlobRef.t list -> unit
192
193 val current_db_names : unit -> String.Set.t
194
195 val current_pure_db : unit -> hint_db list
196
197 val add_hints : locality:hint_locality -> hint_db_name list -> hints_entry -> unit
198
199 (** A constr which is Hint'ed will be:
200 - (1) used as an Exact, if it does not start with a product
201 - (2) used as an Apply, if its HNF starts with a product, and
202 has no missing arguments.
203 - (3) used as an EApply, if its HNF starts with a product, and
204 has missing arguments. *)
205
206 val push_resolves :
207 env -> evar_map -> GlobRef.t -> Hint_db.t -> Hint_db.t
208
209 (** [push_resolve_hyp hname htyp db].
210 used to add an hypothesis to the local hint database;
211 Never raises a user exception;
212 If the hyp cannot be used as a Hint, it is not added. *)
213
214 val push_resolve_hyp :
215 env -> evar_map -> Id.t -> Hint_db.t -> Hint_db.t
216
217 (** Create a Hint database from the pairs (name, constr).
218 Useful to take the current goal hypotheses as hints;
219 Boolean tells if lemmas with evars are allowed *)
220
221 val make_local_hint_db : env -> evar_map -> ?ts:TransparentState.t -> bool -> delayed_open_constr list -> hint_db
222
223 val make_db_list : hint_db_name list -> hint_db list
224
225 val fresh_hint : env -> evar_map -> hint -> evar_map * constr
226
227 val hint_res_pf : ?with_evars:bool -> ?with_classes:bool ->
228 ?flags:Unification.unify_flags -> hint -> unit Proofview.tactic
229
230 (** Printing hints *)
231
232 val pr_searchtable : env -> evar_map -> Pp.t
233 val pr_applicable_hint : Proof.t -> Pp.t
234 val pr_hint_ref : env -> evar_map -> GlobRef.t -> Pp.t
235 val pr_hint_db_by_name : env -> evar_map -> hint_db_name -> Pp.t
236 val pr_hint_db_env : env -> evar_map -> Hint_db.t -> Pp.t