| 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 Names |
| 12 | open Constr |
| 13 | open EConstr |
| 14 | open Environ |
| 15 | open Evd |
| 16 | open Redexpr |
| 17 | open Pattern |
| 18 | open Unification |
| 19 | open Tactypes |
| 20 | open Locus |
| 21 | open Ltac_pretype |
| 22 | |
| 23 | (** Main tactics defined in ML. *) |
| 24 | |
| 25 | (** {6 General functions. } *) |
| 26 | |
| 27 | val is_quantified_hypothesis : Id.t -> Proofview.Goal.t -> bool |
| 28 | |
| 29 | (** {6 Conversion tactics. } *) |
| 30 | |
| 31 | (** [vm_cast_no_check new_concl] changes the conclusion to [new_concl] by inserting a [VMcast]. |
| 32 | It does not check that the new conclusion is indeed convertible to the old conclusion. *) |
| 33 | val vm_cast_no_check : constr -> unit Proofview.tactic |
| 34 | |
| 35 | (** Same as [vm_cast_no_check] but uses a [NATIVEcast]. *) |
| 36 | val native_cast_no_check : constr -> unit Proofview.tactic |
| 37 | |
| 38 | (** [convert_concl ~cast ~check new_concl kind] changes the conclusion to [new_concl], |
| 39 | which should be convertible to the old conclusion. |
| 40 | - [cast]: if [true] insert a cast in the proof term using [kind] as the cast kind. |
| 41 | - [check]: if [true] we check for convertibility. *) |
| 42 | val convert_concl : cast:bool -> check:bool -> types -> cast_kind -> unit Proofview.tactic |
| 43 | |
| 44 | (** [convert_hyp ~check ~reorder decl] changes the declaration of [x] to [decl], |
| 45 | where [x] is the variable bound by [decl]. |
| 46 | - [check]: if [true] we check that [x] is in the context, that the new and old declarations of [x] |
| 47 | are convertible (both the types and bodies need to be convertible), and that the new |
| 48 | declaration of [x] has a body if and only if the old declaration of [x] has a body. *) |
| 49 | val convert_hyp : check:bool -> reorder:bool -> named_declaration -> unit Proofview.tactic |
| 50 | |
| 51 | (** [convert x y] checks that [x] and [y] are convertible (using all conversion rules), |
| 52 | and fails otherwise. *) |
| 53 | val convert : constr -> constr -> unit Proofview.tactic |
| 54 | |
| 55 | (** [convert_leq x y] checks that [x] is smaller than [y] for cumulativity (using all conversion rules), |
| 56 | and fails otherwise. *) |
| 57 | val convert_leq : constr -> constr -> unit Proofview.tactic |
| 58 | |
| 59 | (** {6 Basic introduction tactics. } *) |
| 60 | |
| 61 | (** [introduction id] is a low-level tactic which introduces a single variable with name [id]. |
| 62 | - Fails if the goal is not a product or a let-in. |
| 63 | - Fails if [id] is already declared in the context. *) |
| 64 | val introduction : Id.t -> unit Proofview.tactic |
| 65 | |
| 66 | (** [fresh_id_in_env avoid id env] generates a fresh identifier built from [id]. |
| 67 | The returned identifier is guaranteed to be distinct from: |
| 68 | - The identifiers in [avoid]. |
| 69 | - The global constants in [env]. |
| 70 | - The local variables in [env]. *) |
| 71 | val fresh_id_in_env : Id.Set.t -> Id.t -> env -> Id.t |
| 72 | |
| 73 | (** [find_intro_names env sigma ctx] returns the names that would be created by [intros], |
| 74 | without actually doing [intros]. *) |
| 75 | val find_intro_names : env -> Evd.evar_map -> rel_context -> Id.t list |
| 76 | |
| 77 | (** [intro] introduces a single variable with an automatically-generated name. |
| 78 | Fails if the goal is not a product or a let-in. *) |
| 79 | val intro : unit Proofview.tactic |
| 80 | |
| 81 | (** [introf] is a more aggressive version of [intro]: |
| 82 | - If the goal is an evar it will instantiate it with a product. |
| 83 | - It will attempt to head normalize the goal until it is a product, a let-in, or an evar. *) |
| 84 | val introf : unit Proofview.tactic |
| 85 | |
| 86 | (** [intro_move id_opt loc] introduces a single variable and moves it to location [loc]. |
| 87 | - If [id_opt] is [Some id] the introduced variable is named [id]. |
| 88 | - If [id_opt] is [None] we use an automatically generated name. |
| 89 | - It will instantiate evars and head-normalize the goal in the same way as [introf]. *) |
| 90 | val intro_move : Id.t option -> Id.t Logic.move_location -> unit Proofview.tactic |
| 91 | |
| 92 | (** [intro_move_avoid id_opt avoid loc] is the same as [intro_move] except that |
| 93 | the automatically generated name is guaranteed to not be in the set [avoid]. *) |
| 94 | val intro_move_avoid : Id.t option -> Id.Set.t -> Id.t Logic.move_location -> unit Proofview.tactic |
| 95 | |
| 96 | (** Generalization of [intro_move] to a list of variables and locations (processed from left to right). *) |
| 97 | val intros_move : (Id.t * Id.t Logic.move_location) list -> unit Proofview.tactic |
| 98 | |
| 99 | (** [intro_avoiding avoid] introduces a single variable with an automatically-generated name |
| 100 | which is guaranteed to not be the set [avoid]. *) |
| 101 | val intro_avoiding : Id.Set.t -> unit Proofview.tactic |
| 102 | |
| 103 | (** [intro_replacing id] introduces a single variable named [id], replacing the previous declaration of [id]. |
| 104 | |
| 105 | Fails if [id] is not already in the context. *) |
| 106 | val intro_replacing : Id.t -> unit Proofview.tactic |
| 107 | |
| 108 | (** [intro_using_then id tac] introduces a single variable named [id]. It refreshes the name [id] if needed, |
| 109 | and applies [tac] to the resulting identifier. *) |
| 110 | val intro_using_then : Id.t -> (Id.t -> unit Proofview.tactic) -> unit Proofview.tactic |
| 111 | |
| 112 | (** [intro_mustbe_force id] is the same as [introf] but the name [id] is used instead of |
| 113 | an automatically-generated name. *) |
| 114 | val intro_mustbe_force : Id.t -> unit Proofview.tactic |
| 115 | |
| 116 | (** Generalization of [intro_mustbe_force] to a list of variables (processed from left to right). *) |
| 117 | val intros_mustbe_force : Id.t list -> unit Proofview.tactic |
| 118 | |
| 119 | (** [intro_then tac] introduces a single variable with an automatically-generated name, |
| 120 | and applies [tac] to the resulting identifier. *) |
| 121 | val intro_then : (Id.t -> unit Proofview.tactic) -> unit Proofview.tactic |
| 122 | |
| 123 | (** Generalization of [intro_using_then] to a list of variables (processed from left to right). *) |
| 124 | val intros_using_then : Id.t list -> (Id.t list -> unit Proofview.tactic) -> unit Proofview.tactic |
| 125 | |
| 126 | (** Generalization of [intro_replacing] to a list of variables (processed from left to right). *) |
| 127 | val intros_replacing : Id.t list -> unit Proofview.tactic |
| 128 | |
| 129 | (** Variant of [intros_replacing] which does not assume that the variables are |
| 130 | already declared in the context. *) |
| 131 | val intros_possibly_replacing : Id.t list -> unit Proofview.tactic |
| 132 | |
| 133 | (** [auto_intros_tac names] introduces the variables in [names]. |
| 134 | - The variables are introduced from right to left (contrary to the conventional order). |
| 135 | - Names are chosen as follow: [Anonymous] indicates to generate a fresh name |
| 136 | and [Name id] indicates to use the name [id]. |
| 137 | - It will instantiate evars and head-normalize the goal in the same way as [introf]. *) |
| 138 | val auto_intros_tac : Names.Name.t list -> unit Proofview.tactic |
| 139 | |
| 140 | (** [intros] keeps introducing variables while the goal is a product or a let-in. *) |
| 141 | val intros : unit Proofview.tactic |
| 142 | |
| 143 | (** [intros_until hyp] is a variant of [intros] which stops when hypothesis [hyp] is introduced. *) |
| 144 | val intros_until : quantified_hypothesis -> unit Proofview.tactic |
| 145 | |
| 146 | (** [intros_clearing bs] introduces as many variables as booleans in [bs]. Each boolean indicates |
| 147 | whether to clear the introduced variable (if [true]) or to keep it (if [false]). *) |
| 148 | val intros_clearing : bool list -> unit Proofview.tactic |
| 149 | |
| 150 | (** Assuming a tactic [tac] depending on a hypothesis, |
| 151 | [try_intros_until tac arg] first assumes that [arg] denotes a |
| 152 | quantified hypothesis (denoted by name or by index) and tries to |
| 153 | introduce it in context before applying [tac], otherwise assumes the |
| 154 | hypothesis is already in context and directly applies [tac]. *) |
| 155 | val try_intros_until : |
| 156 | (Id.t -> unit Proofview.tactic) -> quantified_hypothesis -> unit Proofview.tactic |
| 157 | |
| 158 | type evars_flag = bool (* true = pose evars false = fail on evars *) |
| 159 | type rec_flag = bool (* true = recursive false = not recursive *) |
| 160 | type advanced_flag = bool (* true = advanced false = basic *) |
| 161 | type clear_flag = bool option (* true = clear hyp, false = keep hyp, None = use default *) |
| 162 | |
| 163 | (** Apply a tactic on a quantified hypothesis, an hypothesis in context |
| 164 | or a term with bindings. *) |
| 165 | |
| 166 | type 'a core_destruction_arg = |
| 167 | | ElimOnConstr of 'a |
| 168 | | ElimOnIdent of lident |
| 169 | | ElimOnAnonHyp of int |
| 170 | |
| 171 | type equality_position_on_elim = |
| 172 | | UnknownPosition |
| 173 | | AtPosition of int |
| 174 | |
| 175 | type 'a destruction_arg = |
| 176 | clear_flag * 'a core_destruction_arg |
| 177 | |
| 178 | val onInductionArg : |
| 179 | (clear_flag -> constr with_bindings -> unit Proofview.tactic) -> |
| 180 | constr with_bindings destruction_arg -> unit Proofview.tactic |
| 181 | |
| 182 | val force_destruction_arg : evars_flag -> env -> evar_map -> |
| 183 | delayed_open_constr_with_bindings destruction_arg -> |
| 184 | evar_map * constr with_bindings destruction_arg |
| 185 | |
| 186 | val finish_evar_resolution : ?flags:Pretyping.inference_flags -> |
| 187 | env -> evar_map -> (evar_map option * constr) -> evar_map * constr |
| 188 | |
| 189 | (** {6 Pattern introduction tactics. } *) |
| 190 | |
| 191 | (** [intro_patterns with_evars patt] introduces variables and processes them according |
| 192 | to the introduction patterns [patt]. *) |
| 193 | val intro_patterns : evars_flag -> intro_patterns -> unit Proofview.tactic |
| 194 | |
| 195 | (** Variant of [intro_patterns] which moves introduced variables to location [loc]. *) |
| 196 | val intro_patterns_to : evars_flag -> Id.t Logic.move_location -> intro_patterns -> |
| 197 | unit Proofview.tactic |
| 198 | |
| 199 | (** Variant of [intro_patterns_to] which introduces a single variable. *) |
| 200 | val intro_pattern_to : evars_flag -> Id.t Logic.move_location -> delayed_open_constr intro_pattern_expr -> |
| 201 | unit Proofview.tactic |
| 202 | |
| 203 | val intro_patterns_bound_to : evars_flag -> int -> Id.t Logic.move_location -> intro_patterns -> |
| 204 | unit Proofview.tactic |
| 205 | |
| 206 | (** [intros_patterns with_evars patt] implements the user-level "intros" tactic: |
| 207 | - If [patt] is empty it will introduces as many variables as possible (using [intros]). |
| 208 | - Otherwise it will behave as [intro_patterns with_evars patt]. *) |
| 209 | val intros_patterns : evars_flag -> intro_patterns -> unit Proofview.tactic |
| 210 | |
| 211 | (** {6 Exact tactics. } *) |
| 212 | |
| 213 | (** [assumption] solves the goal if it is convertible to the type of a hypothesis. |
| 214 | Fails if there is no such hypothesis. *) |
| 215 | val assumption : unit Proofview.tactic |
| 216 | |
| 217 | (** [exact_no_check x] solves the goal with term [x]. |
| 218 | It does not check that the type of [x] is convertible to the conclusion. *) |
| 219 | val exact_no_check : constr -> unit Proofview.tactic |
| 220 | |
| 221 | (** [exact_check x] solves the goal with term [x]. |
| 222 | Fails if the type of [x] does not match the conclusion. *) |
| 223 | val exact_check : constr -> unit Proofview.tactic |
| 224 | |
| 225 | (** [exact_proof x] internalizes the constr_expr [x] using the conclusion, |
| 226 | and solves the goal using the internalized term. |
| 227 | Fails if [x] could not be internalized. *) |
| 228 | val exact_proof : Constrexpr.constr_expr -> unit Proofview.tactic |
| 229 | |
| 230 | (** {6 Reduction tactics. } *) |
| 231 | |
| 232 | type tactic_reduction = Reductionops.reduction_function |
| 233 | type e_tactic_reduction = Reductionops.e_reduction_function |
| 234 | |
| 235 | type change_arg = patvar_map -> env -> evar_map -> (evar_map * constr) Tacred.change |
| 236 | |
| 237 | val make_change_arg : constr -> change_arg |
| 238 | |
| 239 | (** [reduct_in_hyp ~check ~reorder red_fun hyp] applies the reduction function [red_fun] in hypothesis [hyp]. |
| 240 | - [check]: if [true] we check that the new hypothesis is convertible to the old hypothesis. *) |
| 241 | val reduct_in_hyp : check:bool -> reorder:bool -> tactic_reduction -> hyp_location -> unit Proofview.tactic |
| 242 | |
| 243 | (** [reduct_in_concl ~cast ~check (red_fun, kind)] applies the reduction function [red_fun] to the conclusion. |
| 244 | - [cast]: if [true] we insert a cast in the proof term using [kind] as the cast kind. |
| 245 | - [check]: if [true] we check that the new conclusion is convertible to the old conclusion. *) |
| 246 | val reduct_in_concl : cast:bool -> check:bool -> tactic_reduction * cast_kind -> unit Proofview.tactic |
| 247 | |
| 248 | (** [reduct_option] combines the behaviour of [reduct_in_hyp] and [reduct_in_concl]. |
| 249 | If reducing in the conclusion it will insert a cast. *) |
| 250 | val reduct_option : check:bool -> tactic_reduction * cast_kind -> goal_location -> unit Proofview.tactic |
| 251 | |
| 252 | (** Same as [reduct_in_concl] but the reduction function can update the evar map. *) |
| 253 | val e_reduct_in_concl : cast:bool -> check:bool -> e_tactic_reduction * cast_kind -> unit Proofview.tactic |
| 254 | |
| 255 | (** [change_in_concl ~check where change_fun] changes the conclusion (or subterms of the conclusion) using |
| 256 | the change function [change_fun]. |
| 257 | - [check]: if [true] we check that the new conclusion is convertible to the old conclusion. |
| 258 | - [where]: if [None] then the whole conclusion is changed. |
| 259 | If [Some (occs, patt)] then only the subterms of the conclusion which match occurences [occs] |
| 260 | and pattern [patt] are changed. *) |
| 261 | val change_in_concl : check:bool -> (occurrences * constr_pattern) option -> change_arg -> unit Proofview.tactic |
| 262 | |
| 263 | (** [change_concl new_concl] replaces the conclusion with [new_concl]. |
| 264 | Fails if the new conclusion and old conclusion are not convertible. *) |
| 265 | val change_concl : constr -> unit Proofview.tactic |
| 266 | |
| 267 | (** [change_in_hyp ~check where change_fun hyp] is analogous to [change_in_concl] but works |
| 268 | on the hypothesis [hyp] instead of the conclusion. *) |
| 269 | val change_in_hyp : check:bool -> (occurrences * constr_pattern) option -> change_arg -> |
| 270 | hyp_location -> unit Proofview.tactic |
| 271 | |
| 272 | (** [change ~check where change_fun clause] applies the change function [change_fun]. |
| 273 | - [check]: if [true] we check that the changed terms are convertible to the old terms. |
| 274 | - [clause]: specifies where to apply the change function: to the conclusion and/or to a (subset of) hypotheses. |
| 275 | - [where]: if [None] we change the complete conclusion/hypothesis. |
| 276 | If [Some patt] we change subterms matching pattern [patt]. *) |
| 277 | val change : |
| 278 | check:bool -> constr_pattern option -> change_arg -> clause -> unit Proofview.tactic |
| 279 | |
| 280 | (** [red_in_concl] reduces the conclusion using the [red] reduction strategy. *) |
| 281 | val red_in_concl : unit Proofview.tactic |
| 282 | |
| 283 | (** [red_in_hyp hyp] reduces hypothesis [hyp] using the [red] reduction strategy. *) |
| 284 | val red_in_hyp : hyp_location -> unit Proofview.tactic |
| 285 | |
| 286 | (** [red_option loc] reduces the hypothesis or conclusion [loc] using the [red] reduction strategy. *) |
| 287 | val red_option : goal_location -> unit Proofview.tactic |
| 288 | |
| 289 | (** [hnf_in_concl] reduces the conclusion to head normal form. *) |
| 290 | val hnf_in_concl : unit Proofview.tactic |
| 291 | |
| 292 | (** [hnf_in_hyp hyp] reduces hypothesis [hyp] to head normal form. *) |
| 293 | val hnf_in_hyp : hyp_location -> unit Proofview.tactic |
| 294 | |
| 295 | (** [hnf_option loc] reduces the hypothesis or conclusion [loc] to head normal form. *) |
| 296 | val hnf_option : goal_location -> unit Proofview.tactic |
| 297 | |
| 298 | (** [simpl_in_concl] reduces the conclusion using the [simpl] reduction strategy. *) |
| 299 | val simpl_in_concl : unit Proofview.tactic |
| 300 | |
| 301 | (** [simpl_in_hyp hyp] reduces hypothesis [hyp] using the [red] reduction strategy. *) |
| 302 | val simpl_in_hyp : hyp_location -> unit Proofview.tactic |
| 303 | |
| 304 | (** [simpl_option loc] reduces the hypothesis or conclusion [loc] using the [simpl] reduction strategy. *) |
| 305 | val simpl_option : goal_location -> unit Proofview.tactic |
| 306 | |
| 307 | (** [normalise_in_concl] reduces the conclusion to normal form. *) |
| 308 | val normalise_in_concl : unit Proofview.tactic |
| 309 | |
| 310 | (** [normalise_in_hyp hyp] reduces hypothesis [hyp] to normal form. *) |
| 311 | val normalise_in_hyp : hyp_location -> unit Proofview.tactic |
| 312 | |
| 313 | (** [normalise_option loc] reduces the hypothesis or conclusion [loc] to normal form. *) |
| 314 | val normalise_option : goal_location -> unit Proofview.tactic |
| 315 | |
| 316 | (** [normalise_in_concl] reduces the conclusion to normal form using VM compute. *) |
| 317 | val normalise_vm_in_concl : unit Proofview.tactic |
| 318 | |
| 319 | (** [unfold_in_concl cs] unfolds a list of constants [cs] in the conclusion. |
| 320 | One can specify which occurences of each constant to unfold. *) |
| 321 | val unfold_in_concl : |
| 322 | (occurrences * Evaluable.t) list -> unit Proofview.tactic |
| 323 | |
| 324 | (** [unfold_in_hyp cs hyp] unfolds a list of constants [cs] in hypothesis [hyp]. |
| 325 | One can specify which occurences of each constant to unfold. *) |
| 326 | val unfold_in_hyp : |
| 327 | (occurrences * Evaluable.t) list -> hyp_location -> unit Proofview.tactic |
| 328 | |
| 329 | (** [unfold_option cs loc] unfolds a list of constants [cs] in the hypothesis or conclusion [loc]. |
| 330 | One can specify which occurences of each constant to unfold. *) |
| 331 | val unfold_option : |
| 332 | (occurrences * Evaluable.t) list -> goal_location -> unit Proofview.tactic |
| 333 | |
| 334 | (** [pattern_option [(occs1, t1); (occs2, t2); ...] loc] implements the [pattern] user tactic. |
| 335 | It performs beta-expansion for the terms [ti] at occurences [occsi], in the goal location |
| 336 | [loc] (i.e. either in the goal or in a hypothesis). *) |
| 337 | val pattern_option : |
| 338 | (occurrences * constr) list -> goal_location -> unit Proofview.tactic |
| 339 | |
| 340 | val reduce : red_expr -> clause -> unit Proofview.tactic |
| 341 | |
| 342 | (** [unfold_constr x] unfolds all occurences of [x] in the conclusion. *) |
| 343 | val unfold_constr : GlobRef.t -> unit Proofview.tactic |
| 344 | |
| 345 | (** {6 Modification of the local context. } *) |
| 346 | |
| 347 | (** [clear ids] removes hypotheses [ids] from the context. *) |
| 348 | val clear : Id.t list -> unit Proofview.tactic |
| 349 | |
| 350 | (** [clear_body ids] removes the definitions (but not the declarations) of hypotheses [ids] |
| 351 | from the context. *) |
| 352 | val clear_body : Id.t list -> unit Proofview.tactic |
| 353 | |
| 354 | (** [unfold_body id] unfolds the definition of the local variable [id] in the conclusion |
| 355 | and in all hypotheses. Fails if [id] does not have a body. *) |
| 356 | val unfold_body : Id.t -> unit Proofview.tactic |
| 357 | |
| 358 | (** [keep ids] clears every hypothesis except: |
| 359 | - The hypotheses in [ids]. |
| 360 | - The hypotheses which occur in the conclusion. |
| 361 | - The hypotheses which occur in the type or body of a kept hypothesis. *) |
| 362 | val keep : Id.t list -> unit Proofview.tactic |
| 363 | |
| 364 | val specialize : constr with_bindings -> intro_pattern option -> unit Proofview.tactic |
| 365 | |
| 366 | (** [move_hyp id loc] moves hypothesis [id] to location [loc]. *) |
| 367 | val move_hyp : Id.t -> Id.t Logic.move_location -> unit Proofview.tactic |
| 368 | |
| 369 | (** [rename_hyp [(x1, y1); (x2; y2); ...]] renames hypotheses [xi] into [yi]. |
| 370 | - The names [x1, x2, ...] are expected to be distinct. |
| 371 | - The names [y1, y2, ...] are expected to be distinct. *) |
| 372 | val rename_hyp : (Id.t * Id.t) list -> unit Proofview.tactic |
| 373 | |
| 374 | (** {6 Apply tactics. } *) |
| 375 | |
| 376 | (** [use_clear_hyp_by_default ()] returns the default clear flag used by [apply] and related tactics. |
| 377 | - [true] means that hypotheses are cleared after being applied. |
| 378 | - [false] means that hypotheses are kept after being applied. *) |
| 379 | val use_clear_hyp_by_default : unit -> bool |
| 380 | |
| 381 | (** [apply_clear_request c1 c2 id] implements the clear behaviour of [apply] and friends. |
| 382 | - [c1] is the primary clear flag. If [None] we use the secondary clear flag. |
| 383 | - [c2] is the secondary clear flag, usually [use_clear_hyp_by_default ()]. |
| 384 | - [id] is the identifier of the hypothesis to clear. If [None] we do nothing. *) |
| 385 | val apply_clear_request : clear_flag -> bool -> Id.t option -> unit Proofview.tactic |
| 386 | |
| 387 | (** [apply t] applies the lemma [t] to the conclusion. *) |
| 388 | val apply : constr -> unit Proofview.tactic |
| 389 | |
| 390 | (** Variant of [apply] which allows creating new evars. *) |
| 391 | val eapply : ?with_classes:bool -> constr -> unit Proofview.tactic |
| 392 | |
| 393 | (** Variant of [apply] which takes a term with bindings (e.g. [apply foo with (x := 42)]). *) |
| 394 | val apply_with_bindings : constr with_bindings -> unit Proofview.tactic |
| 395 | |
| 396 | (** Variant of [eapply] which takes a term with bindings (e.g. [eapply foo with (x := 42)]). |
| 397 | - [with_classes] specifies whether to attempt to solve remaining evars using typeclass resolution. *) |
| 398 | val eapply_with_bindings : ?with_classes:bool -> constr with_bindings -> unit Proofview.tactic |
| 399 | |
| 400 | (** [apply_with_bindings_gen ?with_classes advanced with_evars [(c1, t1); (c2, t2); ...]] is the most |
| 401 | general version of [apply]. It applies lemmas [t1], [t2], ... in order. |
| 402 | - [with_evars]: if [true] allow the creation of (non-goal) evars (i.e. setting [with_evars] to [true] |
| 403 | gives the behaviour of [eapply]). |
| 404 | - [with_classes]: if [true] attempt to solve remaining evars using typeclass resolution. |
| 405 | - [advanced]: if [true] use delta reduction (constant unfolding) in unification, |
| 406 | and descend under conjunctions in the conclusion. |
| 407 | - [ci]: if [ti] is a hypothesis, [ci] tells whether to clear [ti] after applying it. |
| 408 | If [ci] is [None] we use the default clear flag. *) |
| 409 | val apply_with_bindings_gen : |
| 410 | ?with_classes:bool -> advanced_flag -> evars_flag -> (clear_flag * constr with_bindings CAst.t) list -> unit Proofview.tactic |
| 411 | |
| 412 | (** Variant of [apply_with_bindings_gen] in which the terms are produced by tactics. *) |
| 413 | val apply_with_delayed_bindings_gen : |
| 414 | advanced_flag -> evars_flag -> (clear_flag * constr with_bindings Proofview.tactic CAst.t) list -> unit Proofview.tactic |
| 415 | |
| 416 | (** Variant of [apply_with_bindings_gen] which works on a hypothesis instead of the goal. *) |
| 417 | val apply_in : |
| 418 | advanced_flag -> evars_flag -> Id.t -> |
| 419 | (clear_flag * constr with_bindings CAst.t) list -> |
| 420 | intro_pattern option -> unit Proofview.tactic |
| 421 | |
| 422 | (** Variant of [apply_in] in which the terms are produced by tactics.*) |
| 423 | val apply_delayed_in : |
| 424 | advanced_flag -> evars_flag -> Id.t -> |
| 425 | (clear_flag * constr with_bindings Proofview.tactic CAst.t) list -> |
| 426 | intro_pattern option -> unit Proofview.tactic -> unit Proofview.tactic |
| 427 | |
| 428 | val apply_type : typecheck:bool -> constr -> constr list -> unit Proofview.tactic |
| 429 | |
| 430 | (** [cut_and_apply t] (where [t] has type [A -> B]) transforms a goal [ |- C ] into two goals |
| 431 | [ |- B -> C ] and [ |- A ]. *) |
| 432 | val cut_and_apply : constr -> unit Proofview.tactic |
| 433 | |
| 434 | (** {6 Elimination tactics. } *) |
| 435 | |
| 436 | (** [simplest_elim t] eliminates [t] using the default eliminator associated to [t]. |
| 437 | It does not allow unresolved evars, and uses the default clear flag. *) |
| 438 | val simplest_elim : constr -> unit Proofview.tactic |
| 439 | |
| 440 | (** [elim with_evars clear t eliminator] eliminates [t]. |
| 441 | - [with_evars]: if [true] we allow unresolved evars (this is the behaviour of [eelim]). |
| 442 | - [clear]: if [Some _], [clear] tells whether to remove [t] from the context. |
| 443 | If [None] we use the default clear flag. |
| 444 | - [eliminator]: if [Some _] we use this as the eliminator for [t]. |
| 445 | If [None] we use the default eliminator associated to [t]. *) |
| 446 | val elim : |
| 447 | evars_flag -> clear_flag -> constr with_bindings -> constr with_bindings option -> unit Proofview.tactic |
| 448 | |
| 449 | (** Variant of [elim] which uses the default eliminator. *) |
| 450 | val default_elim : evars_flag -> clear_flag -> constr with_bindings -> |
| 451 | unit Proofview.tactic |
| 452 | |
| 453 | val general_elim_clause : evars_flag -> unify_flags -> Id.t option -> |
| 454 | ((metavariable list * Unification.Meta.t) * EConstr.t * EConstr.types) -> EConstr.t -> equality_position_on_elim -> unit Proofview.tactic |
| 455 | |
| 456 | (** [general_case_analysis with_evars clear (t, bindings)] performs case analysis on [t]. |
| 457 | If [t] is a variable which is not in the context, we attempt to perform introductions |
| 458 | until [t] is in the context. |
| 459 | - [with_evars]: if [true] allow unsolved evars (this is the behaviour of [ecase]). |
| 460 | - [clear]: if [Some _], [clear] tells whether to remove [t] from the context. |
| 461 | If [None] we use the default clear flag. *) |
| 462 | val general_case_analysis : evars_flag -> clear_flag -> constr with_bindings -> unit Proofview.tactic |
| 463 | |
| 464 | (** [simplest_case t] performs case analysis on [t]. It does not allow unresolved evars, |
| 465 | and uses the default clear flag. *) |
| 466 | val simplest_case : constr -> unit Proofview.tactic |
| 467 | |
| 468 | (** [exfalso] changes the conclusion to [False]. *) |
| 469 | val exfalso : unit Proofview.tactic |
| 470 | |
| 471 | (** {6 Constructor tactics. } *) |
| 472 | |
| 473 | (** [constructor_tac with_evars expected_num_ctors i bindings] checks that the goal is |
| 474 | an inductive [ind] and applies the [i]-th constructor of [ind]. |
| 475 | - [with_evars]: if [true] applying the constructor can leave evars (this gives the |
| 476 | behaviour of [econstructor]). |
| 477 | - [expected_num_ctors]: if [Some nctors] we check that the number of constructors of [ind] |
| 478 | is equal to [nctors]. |
| 479 | - [i]: index of the constructor to apply, starting at [1]. |
| 480 | - [bindings]: bindings to use when applying the constructor. *) |
| 481 | val constructor_tac : evars_flag -> int option -> int -> |
| 482 | constr bindings -> unit Proofview.tactic |
| 483 | |
| 484 | (** [one_constructor i bindings] is a specialization of [constructor_tac] with: |
| 485 | - [with_evars] set to [false]. |
| 486 | - [expected_num_ctors] set to [None]. *) |
| 487 | val one_constructor : int -> constr bindings -> unit Proofview.tactic |
| 488 | |
| 489 | (** [any_constructor with_evars tac] checks that the goal is an inductive [ind] and |
| 490 | tries to apply the constructors of [ind] one by one (from first to last). |
| 491 | - [with_evars]: if [true] applying the constructor can leave evars (this gives the |
| 492 | behaviour of [econstructor]). |
| 493 | - [tac]: we run [tac] after applying each constructor, and backtrack |
| 494 | to the next constructor if [tac] fails. *) |
| 495 | val any_constructor : evars_flag -> unit Proofview.tactic option -> unit Proofview.tactic |
| 496 | |
| 497 | (** [simplest_left] checks the goal is an inductive with two constructors |
| 498 | and applies the first constructor. *) |
| 499 | val simplest_left : unit Proofview.tactic |
| 500 | |
| 501 | (** Variant of [simplest_left] which takes bindings. *) |
| 502 | val left : constr bindings -> unit Proofview.tactic |
| 503 | |
| 504 | (** Variant of [simplest_left] which takes an evar flag and bindings. *) |
| 505 | val left_with_bindings : evars_flag -> constr bindings -> unit Proofview.tactic |
| 506 | |
| 507 | (** [simplest_right] checks the goal is an inductive with two constructors |
| 508 | and applies the second constructor. *) |
| 509 | val simplest_right : unit Proofview.tactic |
| 510 | |
| 511 | (** Variant of [simplest_right] which takes bindings. *) |
| 512 | val right : constr bindings -> unit Proofview.tactic |
| 513 | |
| 514 | (** Variant of [simplest_right] which takes an evar flag and bindings. *) |
| 515 | val right_with_bindings : evars_flag -> constr bindings -> unit Proofview.tactic |
| 516 | |
| 517 | (** [simplest_left] checks the goal is an inductive with one constructor |
| 518 | and applies the (unique) constructor. *) |
| 519 | val simplest_split : unit Proofview.tactic |
| 520 | |
| 521 | (** Variant of [simplest_split] which takes bindings. *) |
| 522 | val split : constr bindings -> unit Proofview.tactic |
| 523 | |
| 524 | (** Variant of [simplest_split] which takes an evar flag and bindings. *) |
| 525 | val split_with_bindings : evars_flag -> constr bindings list -> unit Proofview.tactic |
| 526 | |
| 527 | (** Variant of [simplest_split] which takes an evar flag and delayed bindings. *) |
| 528 | val split_with_delayed_bindings : evars_flag -> constr bindings delayed_open list -> unit Proofview.tactic |
| 529 | |
| 530 | (** {6 Equality tactics. } *) |
| 531 | |
| 532 | (** Hook to the [setoid_reflexivity] tactic, set at runtime. *) |
| 533 | val setoid_reflexivity : unit Proofview.tactic Hook.t |
| 534 | |
| 535 | (** [reflexivity_red reduce] solves a goal of the form [x = y]. |
| 536 | - [reduce]: if [true] we weak-head normalize the goal before checking it is |
| 537 | indeed an equality. *) |
| 538 | val reflexivity_red : bool -> unit Proofview.tactic |
| 539 | |
| 540 | (** Variant of [reflexivity_red] which does not perform reduction, |
| 541 | and falls back to [setoid_reflexivity] in case of failure. *) |
| 542 | val reflexivity : unit Proofview.tactic |
| 543 | |
| 544 | (** [intros_reflexivity] performs [intros] followed by [reflexivity]. *) |
| 545 | val intros_reflexivity : unit Proofview.tactic |
| 546 | |
| 547 | (** Hook to the [setoid_symmetry] tactic, set at runtime. *) |
| 548 | val setoid_symmetry : unit Proofview.tactic Hook.t |
| 549 | |
| 550 | (** [symmetry_red reduce] checks the goal is of the form [x = y] and changes it to [y = x]. |
| 551 | - [reduce]: if [true] we weak-head normalize the goal before checking it is |
| 552 | indeed an equality. *) |
| 553 | val symmetry_red : bool -> unit Proofview.tactic |
| 554 | |
| 555 | (** Variant of [symmetry_red] which does not perform reduction, |
| 556 | and falls back to [setoid_symmetry] in case of failure. *) |
| 557 | val symmetry : unit Proofview.tactic |
| 558 | |
| 559 | (** Hook to the [setoid_symmetry_in] tactic, set at runtime. *) |
| 560 | val setoid_symmetry_in : (Id.t -> unit Proofview.tactic) Hook.t |
| 561 | |
| 562 | (** [intros_symmetry clause] performs [intros] followed by [symmetry] on all |
| 563 | the locations indicated by [clause] (i.e. the conclusion and/or a (subset of) hypotheses). |
| 564 | Actual occurences contained in [clause] are not used: only the hypotheses names are relevant. *) |
| 565 | val intros_symmetry : clause -> unit Proofview.tactic |
| 566 | |
| 567 | (** Hook to the [setoid_transitivity] tactic, set at runtime. *) |
| 568 | val setoid_transitivity : (constr option -> unit Proofview.tactic) Hook.t |
| 569 | |
| 570 | (** [transitivity_red reduce t] checks the goal is of the form [x = y] and changes it to [x = t] and [t = y]. |
| 571 | - [reduce]: if [true] we weak-head normalize the goal before checking it is |
| 572 | indeed an equality. |
| 573 | - [t]: if [Some] then we use [apply eq_trans with t] to perform transitivity. |
| 574 | If [None] we use [eapply eq_trans] instead. *) |
| 575 | val transitivity_red : bool -> constr option -> unit Proofview.tactic |
| 576 | |
| 577 | (** Variant of [transitivity_red] which does not perform reduction, |
| 578 | uses [apply eq_trans with t], |
| 579 | and falls back to [setoid_transitivity] in case of failure. *) |
| 580 | val transitivity : constr -> unit Proofview.tactic |
| 581 | |
| 582 | (** Variant of [transitivity_red] which does not perform reduction, |
| 583 | uses [eapply eq_trans], |
| 584 | and falls back to [setoid_transitivity] in case of failure. *) |
| 585 | val etransitivity : unit Proofview.tactic |
| 586 | |
| 587 | (** [intros_transitivity t] performs [intros] followed by [transitivity t] or [etransivity t] |
| 588 | (depending on whether [t] is [Some] or [None]). *) |
| 589 | val intros_transitivity : constr option -> unit Proofview.tactic |
| 590 | |
| 591 | (** {6 Forward reasoning tactics. } *) |
| 592 | |
| 593 | (** [assert_before x T] first asks to prove [T], then to prove the original goal augmented |
| 594 | with a new hypothesis of type [x : T]. |
| 595 | - [x]: if [None] the name of the hypothesis is generated automatically. |
| 596 | If [Some] then it is the name of the hypothesis (which should not be already defined in the context). *) |
| 597 | val assert_before : Name.t -> types -> unit Proofview.tactic |
| 598 | |
| 599 | (** Variant of [assert_before] which allows replacing hypotheses. *) |
| 600 | val assert_before_replacing: Id.t -> types -> unit Proofview.tactic |
| 601 | |
| 602 | (** [assert_after x T] first asks the original goal augmented with a new hypothesis of type [x : T], |
| 603 | then to prove [T]. |
| 604 | - [x]: if [None] the name of the hypothesis is generated automatically. |
| 605 | If [Some] then it is the name of the hypothesis (which should not be already defined in the context). *) |
| 606 | val assert_after : Name.t -> types -> unit Proofview.tactic |
| 607 | |
| 608 | (** Variant of [assert_after] which allows replacing hypotheses. *) |
| 609 | val assert_after_replacing : Id.t -> types -> unit Proofview.tactic |
| 610 | |
| 611 | (** [forward before by_tac ipat t] performs a forward reasoning step. |
| 612 | - If [by_tac] is [None] it adds a new hypothesis with _body_ equal to [t]. |
| 613 | - If [by_tac] is [Some tac] it asks to prove [t] and to prove the original goal |
| 614 | augmented with a new hypothesis of type [t]. If [tac] is [Some _] then [tac] is used |
| 615 | to prove [t] (and [tac] is required to succeed). |
| 616 | - [before]: if [true] then [t] must be proved first. |
| 617 | If [false] then [t] must be proved [last]. *) |
| 618 | val forward : bool -> unit Proofview.tactic option option -> |
| 619 | intro_pattern option -> constr -> unit Proofview.tactic |
| 620 | |
| 621 | (** [assert_by x T tac] adds a new hypothesis [x : T]. The tactic [tac] is used |
| 622 | to prove [T]. If [x] is [None] a fresh name is automatically generated. *) |
| 623 | val assert_by : Name.t -> types -> unit Proofview.tactic -> |
| 624 | unit Proofview.tactic |
| 625 | |
| 626 | (** [enough_by x T tac] changes the goal to [T]. The tactic [tac] is used to |
| 627 | prove the orignal goal augmented with a hypothesis [x : T]. If [x] is [None] a fresh name |
| 628 | is automatically generated. *) |
| 629 | val enough_by : Name.t -> types -> unit Proofview.tactic -> |
| 630 | unit Proofview.tactic |
| 631 | |
| 632 | (** [pose_proof x t] adds a new hypothesis [x := t]. If [x] is [None] a fresh name |
| 633 | is automatically generated. *) |
| 634 | val pose_proof : Name.t -> constr -> unit Proofview.tactic |
| 635 | |
| 636 | (** Implements the tactic [cut], actually a modus ponens rule. *) |
| 637 | val cut : types -> unit Proofview.tactic |
| 638 | |
| 639 | (** [pose_tac x t] adds a new hypothesis [x := t]. If [x] is [None] a fresh name |
| 640 | is automatically generated. Fails if there is alreay a hypothesis named [x]. *) |
| 641 | val pose_tac : Name.t -> constr -> unit Proofview.tactic |
| 642 | |
| 643 | val letin_tac : (bool * intro_pattern_naming) option -> |
| 644 | Name.t -> constr -> types option -> clause -> unit Proofview.tactic |
| 645 | |
| 646 | (** Common entry point for user-level "set", "pose", and "remember". *) |
| 647 | val letin_pat_tac : evars_flag -> (bool * intro_pattern_naming) option -> |
| 648 | Name.t -> (evar_map option * constr) -> clause -> unit Proofview.tactic |
| 649 | |
| 650 | (** {6 Other tactics. } *) |
| 651 | |
| 652 | (** [constr_eq ~strict x y] checks that [x] and [y] are syntactically equal (i.e. alpha-equivalent), |
| 653 | up to universes. |
| 654 | - [strict]: if [true] the universe constraints must be already true. |
| 655 | If [false] any necessary universe constraints are added to the evar map. *) |
| 656 | val constr_eq : strict:bool -> constr -> constr -> unit Proofview.tactic |
| 657 | |
| 658 | (** Legacy unification. Use [evarconv_unify] instead. *) |
| 659 | val unify : ?state:TransparentState.t -> constr -> constr -> unit Proofview.tactic |
| 660 | |
| 661 | (** [evarconv_unify ?state ?with_ho x y] unifies [x] and [y], instantiating evars and adding universe constraints |
| 662 | as needed. Fails if [x] and [y] are not unifiable. |
| 663 | - [state]: transparency state to use (defaults to [TransparentState.full]). |
| 664 | - [with_ho]: whether to use higher order unification (defaults to [true]). *) |
| 665 | val evarconv_unify : ?state:TransparentState.t -> ?with_ho:bool -> constr -> constr -> unit Proofview.tactic |
| 666 | |
| 667 | val specialize_eqs : Id.t -> unit Proofview.tactic |
| 668 | |
| 669 | val general_rewrite_clause : |
| 670 | (bool -> evars_flag -> constr with_bindings -> clause -> unit Proofview.tactic) Hook.t |
| 671 | |
| 672 | val subst_one : |
| 673 | (bool -> Id.t -> Id.t * constr * bool -> unit Proofview.tactic) Hook.t |
| 674 | |
| 675 | val declare_intro_decomp_eq : |
| 676 | ((int -> unit Proofview.tactic) -> EConstr.constr * GlobRef.t * types * |
| 677 | (types * constr * constr) -> |
| 678 | constr * types -> unit Proofview.tactic) -> unit |
| 679 | |
| 680 | (** Tactic analogous to the [Strategy] vernacular, but only applied |
| 681 | locally to the tactic argument. *) |
| 682 | val with_set_strategy : |
| 683 | (Conv_oracle.level * Names.GlobRef.t list) list -> 'a Proofview.tactic -> 'a Proofview.tactic |
| 684 | |
| 685 | (** {6 Simple form of common tactics. } *) |
| 686 | |
| 687 | module Simple : sig |
| 688 | (** Simplified version of some of the above tactics *) |
| 689 | |
| 690 | val intro : Id.t -> unit Proofview.tactic |
| 691 | val apply : constr -> unit Proofview.tactic |
| 692 | val eapply : constr -> unit Proofview.tactic |
| 693 | val elim : constr -> unit Proofview.tactic |
| 694 | val case : constr -> unit Proofview.tactic |
| 695 | val apply_in : Id.t -> constr -> unit Proofview.tactic |
| 696 | |
| 697 | end |
| 698 | |
| 699 | (** {6 Tacticals defined directly in term of Proofview} *) |
| 700 | |
| 701 | (** [refine ~typecheck c] is [Refine.refine ~typecheck c] |
| 702 | followed by beta-iota-reduction of the conclusion. *) |
| 703 | val refine : typecheck:bool -> (evar_map -> evar_map * constr) -> unit Proofview.tactic |
| 704 | |
| 705 | (** The reducing tactic called after [refine]. *) |
| 706 | val reduce_after_refine : unit Proofview.tactic |
| 707 | |
| 708 | (** {6 Internals, do not use} *) |
| 709 | |
| 710 | module Internal : |
| 711 | sig |
| 712 | |
| 713 | val explicit_intro_names : 'a intro_pattern_expr CAst.t list -> Id.Set.t |
| 714 | |
| 715 | val check_name_unicity : env -> Id.t list -> Id.t list -> 'a intro_pattern_expr CAst.t list -> unit |
| 716 | |
| 717 | val clear_gen : (env -> evar_map -> Id.t -> Evarutil.clear_dependency_error -> |
| 718 | GlobRef.t option -> evar_map * named_context_val * types) -> |
| 719 | Id.t list -> unit Proofview.tactic |
| 720 | |
| 721 | val clear_wildcards : lident list -> unit Proofview.tactic |
| 722 | |
| 723 | val dest_intro_patterns : evars_flag -> Id.Set.t -> lident list -> |
| 724 | Id.t Logic.move_location -> intro_patterns -> |
| 725 | (Id.t list -> lident list -> unit Proofview.tactic) -> unit Proofview.tactic |
| 726 | |
| 727 | end |
| 728 | |
| 729 | (** {6 Moved functions} *) |
| 730 | |
| 731 | (** The functions below have been moved to other files but are kept here |
| 732 | for backwards compatibility. Don't use in new code. *) |
| 733 | |
| 734 | (** Deprecated since 9.2, use [TacticErrors.not_convertible ()] instead. *) |
| 735 | exception NotConvertible |
| 736 | |
| 737 | val fix : Id.t -> int -> unit Proofview.tactic |
| 738 | [@@ocaml.deprecated "(since 9.2) Use [FixTactics.fix]"] |
| 739 | |
| 740 | val mutual_fix : |
| 741 | Id.t -> int -> (Id.t * int * constr) list -> unit Proofview.tactic |
| 742 | [@@ocaml.deprecated "(since 9.2) Use [FixTactics.mutual_fix]"] |
| 743 | |
| 744 | val cofix : Id.t -> unit Proofview.tactic |
| 745 | [@@ocaml.deprecated "(since 9.2) Use [FixTactics.cofix]"] |
| 746 | |
| 747 | val mutual_cofix : Id.t -> (Id.t * constr) list -> unit Proofview.tactic |
| 748 | [@@ocaml.deprecated "(since 9.2) Use [FixTactics.mutual_cofix]"] |