
# 11 "plugins/ltac/extratactics.mlg"
 

open Pp
open Stdarg
open Tacarg
open Extraargs
open Mod_subst
open Names
open CErrors
open Util
open Equality
open Tactypes
open Proofview.Notations
open Attributes
open Vernacextend
open G_redexpr


# 22 "plugins/ltac/extratactics.ml"

let _ = Mltop.add_known_module "rocq-runtime.plugins.ltac"
let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "assert_succeeds" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("assert_succeeds", Tacentries.TyArg (
                                                                   Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 3), 
                                                                   Tacentries.TyNil)), 
           (fun tac ist -> 
# 34 "plugins/ltac/extratactics.mlg"
       Internals.assert_succeeds (Tacinterp.tactic_of_value ist tac) 
# 32 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "replace" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                           Tacentries.TyIdent ("with", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                           Tacentries.TyNil)))))), 
           (fun c1 c2 cl tac ist -> 
# 39 "plugins/ltac/extratactics.mlg"
       Internals.replace_in_clause_maybe_by ist None c1 c2 cl tac 
# 49 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "replace_term_left" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyIdent ("->", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                           Tacentries.TyNil)))), 
           (fun c cl ist -> 
# 44 "plugins/ltac/extratactics.mlg"
       Internals.replace_term ist (Some true) c cl 
# 62 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "replace_left" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyIdent ("->", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                           Tacentries.TyIdent ("with", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                           Tacentries.TyNil))))))), 
           (fun c1 c2 cl tac ist -> 
# 49 "plugins/ltac/extratactics.mlg"
       Internals.replace_in_clause_maybe_by ist (Some true) c1 c2 cl tac 
# 80 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "replace_term_right" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyIdent ("<-", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                           Tacentries.TyNil)))), 
           (fun c cl ist -> 
# 54 "plugins/ltac/extratactics.mlg"
       Internals.replace_term ist (Some false) c cl 
# 93 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "replace_right" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyIdent ("<-", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                           Tacentries.TyIdent ("with", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                           Tacentries.TyNil))))))), 
           (fun c1 c2 cl tac ist -> 
# 59 "plugins/ltac/extratactics.mlg"
       Internals.replace_in_clause_maybe_by ist (Some false) c1 c2 cl tac 
# 111 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "replace_term" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                           Tacentries.TyNil))), 
           (fun c cl ist -> 
# 64 "plugins/ltac/extratactics.mlg"
       Internals.replace_term ist None c cl 
# 123 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "simplify_eq" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("simplify_eq", Tacentries.TyNil), 
           (fun ist -> 
# 68 "plugins/ltac/extratactics.mlg"
                         dEq ~keep_proofs:None false None 
# 131 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("simplify_eq", Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                              Tacentries.TyNil)), 
          (fun c ist -> 
# 69 "plugins/ltac/extratactics.mlg"
                                            Internals.mytclWithHoles (dEq ~keep_proofs:None) false c 
# 139 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "esimplify_eq" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("esimplify_eq", Tacentries.TyNil), 
           (fun ist -> 
# 72 "plugins/ltac/extratactics.mlg"
                          dEq ~keep_proofs:None true None 
# 147 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("esimplify_eq", Tacentries.TyArg (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                               Tacentries.TyNil)), 
          (fun c ist -> 
# 73 "plugins/ltac/extratactics.mlg"
                                             Internals.mytclWithHoles (dEq ~keep_proofs:None) true c 
# 155 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "discriminate" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("discriminate", Tacentries.TyNil), 
           (fun ist -> 
# 77 "plugins/ltac/extratactics.mlg"
                          discr_tac false None 
# 163 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("discriminate", Tacentries.TyArg (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                               Tacentries.TyNil)), 
          (fun c ist -> 
# 79 "plugins/ltac/extratactics.mlg"
      Internals.mytclWithHoles discr_tac false c 
# 171 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "ediscriminate" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("ediscriminate", Tacentries.TyNil), 
           (fun ist -> 
# 82 "plugins/ltac/extratactics.mlg"
                           discr_tac true None 
# 179 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("ediscriminate", Tacentries.TyArg (
                                                                Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                                Tacentries.TyNil)), 
          (fun c ist -> 
# 84 "plugins/ltac/extratactics.mlg"
      Internals.mytclWithHoles discr_tac true c 
# 187 "plugins/ltac/extratactics.ml"
)))]


# 87 "plugins/ltac/extratactics.mlg"
 

let isInjPat pat = match pat.CAst.v with IntroAction (IntroInjection _) -> Some pat.CAst.loc | _ -> None

let decode_inj_ipat ?loc = function
  (* For the "as [= pat1 ... patn ]" syntax *)
  | [{ CAst.v = IntroAction (IntroInjection ipat) }] -> ipat
  (* For the "as pat1 ... patn" syntax *)
  | ([] | [_]) as ipat -> ipat
  | pat1::pat2::_ as ipat ->
  (* To be sure that there is no confusion of syntax, we check that no [= ...] occurs
     in the non-singleton list of patterns *)
  match isInjPat pat1 with
  | Some _ -> user_err ?loc:pat2.CAst.loc (str "Unexpected pattern.")
  | None ->
  match List.map_filter isInjPat ipat with
  | loc :: _ -> user_err ?loc (str "Unexpected injection pattern.")
  | [] -> ipat


# 212 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "injection" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyNil), 
           (fun ist -> 
# 109 "plugins/ltac/extratactics.mlg"
                       injClause None None false None 
# 219 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                            Tacentries.TyNil)), 
          (fun c ist -> 
# 110 "plugins/ltac/extratactics.mlg"
                                          Internals.mytclWithHoles (injClause None None) false c 
# 227 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "einjection" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyNil), 
           (fun ist -> 
# 113 "plugins/ltac/extratactics.mlg"
                        injClause None None true None 
# 235 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                             Tacentries.TyNil)), 
          (fun c ist -> 
# 114 "plugins/ltac/extratactics.mlg"
                                           Internals.mytclWithHoles (injClause None None) true c 
# 243 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "injection_as" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyIdent ("as", 
                                                             Tacentries.TyArg (
                                                             Extend.TUlist0 (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), 
                                                             Tacentries.TyNil))), 
           (fun ipat ist -> 
# 118 "plugins/ltac/extratactics.mlg"
      injClause None (Some (decode_inj_ipat ipat)) false None 
# 255 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                            Tacentries.TyIdent ("as", 
                                                            Tacentries.TyArg (
                                                            Extend.TUlist0 (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), 
                                                            Tacentries.TyNil)))), 
          (fun c ipat ist -> 
# 120 "plugins/ltac/extratactics.mlg"
      Internals.mytclWithHoles (injClause None (Some (decode_inj_ipat ipat))) false c 
# 267 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "einjection_as" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyIdent ("as", 
                                                              Tacentries.TyArg (
                                                              Extend.TUlist0 (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), 
                                                              Tacentries.TyNil))), 
           (fun ipat ist -> 
# 124 "plugins/ltac/extratactics.mlg"
      injClause None (Some (decode_inj_ipat ipat)) true None 
# 279 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                             Tacentries.TyIdent ("as", 
                                                             Tacentries.TyArg (
                                                             Extend.TUlist0 (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), 
                                                             Tacentries.TyNil)))), 
          (fun c ipat ist -> 
# 126 "plugins/ltac/extratactics.mlg"
      Internals.mytclWithHoles (injClause None (Some (decode_inj_ipat ipat))) true c 
# 291 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "simple_injection" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("injection", 
                                                          Tacentries.TyNil)), 
           (fun ist -> 
# 129 "plugins/ltac/extratactics.mlg"
                                simpleInjClause None false None 
# 300 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("injection", 
                                                         Tacentries.TyArg (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), 
                                                         Tacentries.TyNil))), 
          (fun c ist -> 
# 130 "plugins/ltac/extratactics.mlg"
                                                   Internals.mytclWithHoles (simpleInjClause None) false c 
# 309 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "dependent_rewrite" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("rewrite", 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_orient), 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                             Tacentries.TyNil)))), 
           (fun b c ist -> 
# 134 "plugins/ltac/extratactics.mlg"
                                                     rewriteInConcl b c 
# 322 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("rewrite", 
                                                            Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_orient), 
                                                            Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                            Tacentries.TyIdent ("in", 
                                                            Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                            Tacentries.TyNil)))))), 
          (fun b c id ist -> 
# 136 "plugins/ltac/extratactics.mlg"
         rewriteInHyp b c id 
# 336 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "decompose_sum" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("decompose", Tacentries.TyIdent ("sum", 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                             Tacentries.TyNil))), 
           (fun c ist -> 
# 143 "plugins/ltac/extratactics.mlg"
                                       Elim.h_decompose_or c 
# 347 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "decompose_record" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("decompose", Tacentries.TyIdent ("record", 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                             Tacentries.TyNil))), 
           (fun c ist -> 
# 147 "plugins/ltac/extratactics.mlg"
                                          Elim.h_decompose_and c 
# 358 "plugins/ltac/extratactics.ml"
)))]


# 153 "plugins/ltac/extratactics.mlg"
 

open Contradiction


# 368 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "absurd" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("absurd", Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                          Tacentries.TyNil)), 
           (fun c ist -> 
# 160 "plugins/ltac/extratactics.mlg"
                              absurd c 
# 377 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "contradiction" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("contradiction", Tacentries.TyArg (
                                                                 Extend.TUopt (
                                                                 Extend.TUentry (Genarg.get_arg_tag wit_constr_with_bindings)), 
                                                                 Tacentries.TyNil)), 
           (fun c ist -> 
# 165 "plugins/ltac/extratactics.mlg"
      Internals.onSomeWithHoles contradiction c 
# 388 "plugins/ltac/extratactics.ml"
)))]


# 171 "plugins/ltac/extratactics.mlg"
 

open Autorewrite


# 398 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "autorewrite" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("with", 
                                                               Tacentries.TyArg (
                                                               Extend.TUlist1 (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_preident)), 
                                                               Tacentries.TyArg (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                               Tacentries.TyNil)))), 
           (fun l cl ist -> 
# 179 "plugins/ltac/extratactics.mlg"
      auto_multi_rewrite  l ( cl) 
# 411 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("with", 
                                                              Tacentries.TyArg (
                                                              Extend.TUlist1 (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_preident)), 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                              Tacentries.TyIdent ("using", 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_tactic), 
                                                              Tacentries.TyNil)))))), 
          (fun l cl t ist -> 
# 181 "plugins/ltac/extratactics.mlg"
     
      auto_multi_rewrite_with (Tacinterp.tactic_of_value ist t) l cl
   
# 428 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "autorewrite_star" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("*", 
                                                               Tacentries.TyIdent ("with", 
                                                               Tacentries.TyArg (
                                                               Extend.TUlist1 (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_preident)), 
                                                               Tacentries.TyArg (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                               Tacentries.TyNil))))), 
           (fun l cl ist -> 
# 188 "plugins/ltac/extratactics.mlg"
      auto_multi_rewrite ~conds:AllMatches l cl 
# 443 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("*", 
                                                              Tacentries.TyIdent ("with", 
                                                              Tacentries.TyArg (
                                                              Extend.TUlist1 (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_preident)), 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_clause), 
                                                              Tacentries.TyIdent ("using", 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_tactic), 
                                                              Tacentries.TyNil))))))), 
          (fun l cl t ist -> 
# 190 "plugins/ltac/extratactics.mlg"
    auto_multi_rewrite_with ~conds:AllMatches (Tacinterp.tactic_of_value ist t) l cl 
# 459 "plugins/ltac/extratactics.ml"
)))]


# 196 "plugins/ltac/extratactics.mlg"
 

let rewrite_star ist clause orient occs c (tac : Geninterp.Val.t option) =
  let tac' = Option.map (fun t -> Tacinterp.tactic_of_value ist t, FirstSolved) tac in
  Internals.with_delayed_uconstr ist c
    (fun c -> general_rewrite ~where:clause ~l2r:orient occs ?tac:tac' ~freeze:true ~dep:true ~with_evars:true (c,NoBindings))


# 472 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "rewrite_star" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_orient), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                           Tacentries.TyIdent ("in", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                           Tacentries.TyIdent ("at", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_occurrences), 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                           Tacentries.TyNil))))))))), 
           (fun o c id occ tac ist -> 
# 207 "plugins/ltac/extratactics.mlg"
      rewrite_star ist (Some id) o (occurrences_of occ) c tac 
# 492 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_orient), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                          Tacentries.TyIdent ("at", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_occurrences), 
                                                          Tacentries.TyIdent ("in", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                          Tacentries.TyNil))))))))), 
          (fun o c occ id tac ist -> 
# 209 "plugins/ltac/extratactics.mlg"
      rewrite_star ist (Some id) o (occurrences_of occ) c tac 
# 511 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_orient), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                          Tacentries.TyIdent ("in", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                          Tacentries.TyNil))))))), 
          (fun o c id tac ist -> 
# 211 "plugins/ltac/extratactics.mlg"
      rewrite_star ist (Some id) o Locus.AllOccurrences c tac 
# 527 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_orient), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                          Tacentries.TyIdent ("at", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_occurrences), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                          Tacentries.TyNil))))))), 
          (fun o c occ tac ist -> 
# 213 "plugins/ltac/extratactics.mlg"
      rewrite_star ist None o (occurrences_of occ) c tac 
# 543 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_orient), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), 
                                                          Tacentries.TyNil))))), 
          (fun o c tac ist -> 
# 215 "plugins/ltac/extratactics.mlg"
      rewrite_star ist None o Locus.AllOccurrences c tac 
# 556 "plugins/ltac/extratactics.ml"
)))]


# 221 "plugins/ltac/extratactics.mlg"
 

let classify_hint _ = VtSideff ([], VtLater)


# 566 "plugins/ltac/extratactics.ml"

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"HintRewrite" ~classifier:(fun ~atts ->  classify_hint ) ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Hint",
           Vernacextend.TyTerminal
           ("Rewrite",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient),
            Vernacextend.TyNonTerminal (Extend.TUlist1 (Extend.TUentry (Genarg.get_arg_tag wit_constr)),
            Vernacextend.TyTerminal
            (":",
             Vernacextend.TyNonTerminal (Extend.TUlist1 (Extend.TUentry (Genarg.get_arg_tag wit_preident)),
             Vernacextend.TyNil)))))),
          (let coqpp_body o l bl (polymorphic, locality) =
            Vernactypes.vtdefault (fun () -> 
# 231 "plugins/ltac/extratactics.mlg"
    add_rewrite_hint ~locality ~poly:polymorphic bl o None l 
# 585 "plugins/ltac/extratactics.ml"
) in fun o l bl ?loc ~atts () ->
            coqpp_body o l bl
              (Attributes.parse Attributes.Notations.(
# 230 "plugins/ltac/extratactics.mlg"
      polymorphic
# 591 "plugins/ltac/extratactics.ml"
 ++ 
# 230 "plugins/ltac/extratactics.mlg"
                              hint_locality
# 595 "plugins/ltac/extratactics.ml"
) atts)),
          None));
         (Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Hint",
           Vernacextend.TyTerminal
           ("Rewrite",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient),
            Vernacextend.TyNonTerminal (Extend.TUlist1 (Extend.TUentry (Genarg.get_arg_tag wit_constr)),
            Vernacextend.TyTerminal
            ("using",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_generic_tactic),
             Vernacextend.TyTerminal
             (":",
              Vernacextend.TyNonTerminal (Extend.TUlist1 (Extend.TUentry (Genarg.get_arg_tag wit_preident)),
              Vernacextend.TyNil)))))))),
          (let coqpp_body o l t bl (polymorphic, locality) =
            Vernactypes.vtdefault (fun () -> 
# 234 "plugins/ltac/extratactics.mlg"
    add_rewrite_hint ~locality ~poly:polymorphic bl o (Some t) l 
# 617 "plugins/ltac/extratactics.ml"
) in
            fun o l t bl ?loc ~atts () ->
            coqpp_body o l t bl
              (Attributes.parse Attributes.Notations.(
# 232 "plugins/ltac/extratactics.mlg"
      polymorphic
# 624 "plugins/ltac/extratactics.ml"
 ++ 
# 232 "plugins/ltac/extratactics.mlg"
                              hint_locality
# 628 "plugins/ltac/extratactics.ml"
) atts)),
          None));
         (Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Hint",
           Vernacextend.TyTerminal
           ("Rewrite",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient),
            Vernacextend.TyNonTerminal (Extend.TUlist1 (Extend.TUentry (Genarg.get_arg_tag wit_constr)),
            Vernacextend.TyNil)))),
          (let coqpp_body o l (polymorphic, locality) =
            Vernactypes.vtdefault (fun () -> 
# 236 "plugins/ltac/extratactics.mlg"
    add_rewrite_hint ~locality ~poly:polymorphic ["core"] o None l 
# 644 "plugins/ltac/extratactics.ml"
) in fun o l ?loc ~atts () ->
            coqpp_body o l
              (Attributes.parse Attributes.Notations.(
# 235 "plugins/ltac/extratactics.mlg"
      polymorphic
# 650 "plugins/ltac/extratactics.ml"
 ++ 
# 235 "plugins/ltac/extratactics.mlg"
                              hint_locality
# 654 "plugins/ltac/extratactics.ml"
) atts)),
          None));
         (Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Hint",
           Vernacextend.TyTerminal
           ("Rewrite",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient),
            Vernacextend.TyNonTerminal (Extend.TUlist1 (Extend.TUentry (Genarg.get_arg_tag wit_constr)),
            Vernacextend.TyTerminal
            ("using",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_generic_tactic),
             Vernacextend.TyNil)))))),
          (let coqpp_body o l t (polymorphic, locality) =
            Vernactypes.vtdefault (fun () -> 
# 238 "plugins/ltac/extratactics.mlg"
    add_rewrite_hint ~locality ~poly:polymorphic ["core"] o (Some t) l 
# 673 "plugins/ltac/extratactics.ml"
) in fun o l t ?loc ~atts () ->
            coqpp_body o l t
              (Attributes.parse Attributes.Notations.(
# 237 "plugins/ltac/extratactics.mlg"
      polymorphic
# 679 "plugins/ltac/extratactics.ml"
 ++ 
# 237 "plugins/ltac/extratactics.mlg"
                              hint_locality
# 683 "plugins/ltac/extratactics.ml"
) atts)),
          None))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "refine" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("refine", Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                          Tacentries.TyNil)), 
           (fun c ist -> 
# 246 "plugins/ltac/extratactics.mlg"
     Internals.refine_tac ist ~simple:false ~with_classes:true c 
# 694 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "simple_refine" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("refine", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                          Tacentries.TyNil))), 
           (fun c ist -> 
# 251 "plugins/ltac/extratactics.mlg"
     Internals.refine_tac ist ~simple:true ~with_classes:true c 
# 705 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "notcs_refine" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("notypeclasses", Tacentries.TyIdent ("refine", 
                                                                 Tacentries.TyArg (
                                                                 Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                                 Tacentries.TyNil))), 
           (fun c ist -> 
# 256 "plugins/ltac/extratactics.mlg"
     Internals.refine_tac ist ~simple:false ~with_classes:false c 
# 716 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "notcs_simple_refine" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("notypeclasses", 
                                                          Tacentries.TyIdent ("refine", 
                                                          Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_uconstr), 
                                                          Tacentries.TyNil)))), 
           (fun c ist -> 
# 261 "plugins/ltac/extratactics.mlg"
     Internals.refine_tac ist ~simple:true ~with_classes:false c 
# 728 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "solve_constraints" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("solve_constraints", 
                            Tacentries.TyNil), (fun ist -> 
# 266 "plugins/ltac/extratactics.mlg"
                               Refine.solve_constraints 
# 736 "plugins/ltac/extratactics.ml"
)))]


# 272 "plugins/ltac/extratactics.mlg"
 

open Inv
open Leminv

let seff id = VtSideff ([id.CAst.v], VtLater)


# 749 "plugins/ltac/extratactics.ml"

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"DeriveInversionClear"  ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Derive",
           Vernacextend.TyTerminal
           ("Inversion_clear",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref),
            Vernacextend.TyTerminal
            ("with",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyTerminal
             ("Sort",
              Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_quality_or_set),
              Vernacextend.TyNil))))))),
          (let coqpp_body na c s polymorphic =
            Vernactypes.vtdefault (fun () -> 
# 284 "plugins/ltac/extratactics.mlg"
      
      add_inversion_lemma_exn ~poly:polymorphic na c s false inv_clear_tac 
# 771 "plugins/ltac/extratactics.ml"
) in fun na c s ?loc ~atts () ->
            coqpp_body na c s (Attributes.parse 
# 282 "plugins/ltac/extratactics.mlg"
      polymorphic
# 776 "plugins/ltac/extratactics.ml"
 atts)),
          Some (fun na c s  ~atts -> 
# 283 "plugins/ltac/extratactics.mlg"
       seff na 
# 781 "plugins/ltac/extratactics.ml"
)));
         (Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Derive",
           Vernacextend.TyTerminal
           ("Inversion_clear",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref),
            Vernacextend.TyTerminal
            ("with",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyNil))))),
          (let coqpp_body na c polymorphic =
            Vernactypes.vtdefault (fun () -> 
# 288 "plugins/ltac/extratactics.mlg"
      
      add_inversion_lemma_exn ~poly:polymorphic na c UnivGen.QualityOrSet.prop false inv_clear_tac 
# 799 "plugins/ltac/extratactics.ml"
) in fun na c ?loc ~atts () ->
            coqpp_body na c (Attributes.parse 
# 287 "plugins/ltac/extratactics.mlg"
      polymorphic
# 804 "plugins/ltac/extratactics.ml"
 atts)),
          Some (fun na c  ~atts -> 
# 287 "plugins/ltac/extratactics.mlg"
                                                                                      seff na 
# 809 "plugins/ltac/extratactics.ml"
)))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"DeriveInversion"  ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Derive",
           Vernacextend.TyTerminal
           ("Inversion",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref),
            Vernacextend.TyTerminal
            ("with",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyTerminal
             ("Sort",
              Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_quality_or_set),
              Vernacextend.TyNil))))))),
          (let coqpp_body na c s polymorphic =
            Vernactypes.vtdefault (fun () -> 
# 295 "plugins/ltac/extratactics.mlg"
      
      add_inversion_lemma_exn ~poly:polymorphic na c s false inv_tac 
# 832 "plugins/ltac/extratactics.ml"
) in fun na c s ?loc ~atts () ->
            coqpp_body na c s (Attributes.parse 
# 293 "plugins/ltac/extratactics.mlg"
      polymorphic
# 837 "plugins/ltac/extratactics.ml"
 atts)),
          Some (fun na c s  ~atts -> 
# 294 "plugins/ltac/extratactics.mlg"
       seff na 
# 842 "plugins/ltac/extratactics.ml"
)));
         (Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Derive",
           Vernacextend.TyTerminal
           ("Inversion",
            Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref),
            Vernacextend.TyTerminal
            ("with",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyNil))))),
          (let coqpp_body na c polymorphic =
            Vernactypes.vtdefault (fun () -> 
# 299 "plugins/ltac/extratactics.mlg"
      
      add_inversion_lemma_exn ~poly:polymorphic na c UnivGen.QualityOrSet.prop false inv_tac 
# 860 "plugins/ltac/extratactics.ml"
) in fun na c ?loc ~atts () ->
            coqpp_body na c (Attributes.parse 
# 298 "plugins/ltac/extratactics.mlg"
      polymorphic
# 865 "plugins/ltac/extratactics.ml"
 atts)),
          Some (fun na c  ~atts -> 
# 298 "plugins/ltac/extratactics.mlg"
                                                                                seff na 
# 870 "plugins/ltac/extratactics.ml"
)))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"DeriveDependentInversion"  ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Derive",
           Vernacextend.TyTerminal
           ("Dependent",
            Vernacextend.TyTerminal
            ("Inversion",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref),
             Vernacextend.TyTerminal
             ("with",
              Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
              Vernacextend.TyTerminal
              ("Sort",
               Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_quality_or_set),
               Vernacextend.TyNil)))))))),
          (let coqpp_body na c s polymorphic =
            Vernactypes.vtdefault (fun () -> 
# 306 "plugins/ltac/extratactics.mlg"
      
      add_inversion_lemma_exn ~poly:polymorphic na c s true dinv_tac 
# 895 "plugins/ltac/extratactics.ml"
) in fun na c s ?loc ~atts () ->
            coqpp_body na c s (Attributes.parse 
# 304 "plugins/ltac/extratactics.mlg"
      polymorphic
# 900 "plugins/ltac/extratactics.ml"
 atts)),
          Some (fun na c s  ~atts -> 
# 305 "plugins/ltac/extratactics.mlg"
       seff na 
# 905 "plugins/ltac/extratactics.ml"
)))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"DeriveDependentInversionClear"  ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Derive",
           Vernacextend.TyTerminal
           ("Dependent",
            Vernacextend.TyTerminal
            ("Inversion_clear",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref),
             Vernacextend.TyTerminal
             ("with",
              Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
              Vernacextend.TyTerminal
              ("Sort",
               Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_quality_or_set),
               Vernacextend.TyNil)))))))),
          (let coqpp_body na c s polymorphic =
            Vernactypes.vtdefault (fun () -> 
# 313 "plugins/ltac/extratactics.mlg"
      
      add_inversion_lemma_exn ~poly:polymorphic na c s true dinv_clear_tac 
# 930 "plugins/ltac/extratactics.ml"
) in fun na c s ?loc ~atts () ->
            coqpp_body na c s (Attributes.parse 
# 311 "plugins/ltac/extratactics.mlg"
      polymorphic
# 935 "plugins/ltac/extratactics.ml"
 atts)),
          Some (fun na c s  ~atts -> 
# 312 "plugins/ltac/extratactics.mlg"
       seff na 
# 940 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "subst" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("subst", Tacentries.TyArg (
                                                         Extend.TUlist1 (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_hyp)), 
                                                         Tacentries.TyNil)), 
           (fun l ist -> 
# 321 "plugins/ltac/extratactics.mlg"
                                  subst l 
# 951 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("subst", Tacentries.TyNil), 
          (fun ist -> 
# 322 "plugins/ltac/extratactics.mlg"
                   subst_all () 
# 957 "plugins/ltac/extratactics.ml"
)))]


# 325 "plugins/ltac/extratactics.mlg"
 

let simple_subst_tactic_flags =
  { only_leibniz = true; rewrite_dependent_proof = false }


# 968 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "simple_subst" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("subst", 
                                                          Tacentries.TyNil)), 
           (fun ist -> 
# 333 "plugins/ltac/extratactics.mlg"
                            subst_all ~flags:simple_subst_tactic_flags () 
# 976 "plugins/ltac/extratactics.ml"
)))]


# 336 "plugins/ltac/extratactics.mlg"
 

open Evar_tactics


# 986 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "evar" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("evar", Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_test_lpar_id_colon), 
                                                        Tacentries.TyIdent ("(", 
                                                        Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_ident), 
                                                        Tacentries.TyIdent (":", 
                                                        Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_lconstr), 
                                                        Tacentries.TyIdent (")", 
                                                        Tacentries.TyNil))))))), 
           (fun _ id typ ist -> 
# 348 "plugins/ltac/extratactics.mlg"
                                                                        let_evar (Name.Name id) typ 
# 1002 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("evar", Tacentries.TyArg (
                                                       Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                       Tacentries.TyNil)), 
          (fun typ ist -> 
# 349 "plugins/ltac/extratactics.mlg"
                              let_evar Name.Anonymous typ 
# 1010 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "instantiate" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("instantiate", Tacentries.TyIdent ("(", 
                                                               Tacentries.TyArg (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_ident), 
                                                               Tacentries.TyIdent (":=", 
                                                               Tacentries.TyArg (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_lglob), 
                                                               Tacentries.TyIdent (")", 
                                                               Tacentries.TyNil)))))), 
           (fun id c ist -> 
# 354 "plugins/ltac/extratactics.mlg"
      instantiate_tac_by_name id c 
# 1025 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("instantiate", Tacentries.TyIdent ("(", 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_natural), 
                                                              Tacentries.TyIdent (":=", 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_lglob), 
                                                              Tacentries.TyIdent (")", 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_hloc), 
                                                              Tacentries.TyNil))))))), 
          (fun i c hl ist -> 
# 356 "plugins/ltac/extratactics.mlg"
      instantiate_tac i c hl 
# 1040 "plugins/ltac/extratactics.ml"
)))]


# 362 "plugins/ltac/extratactics.mlg"
 

open Tactics
open Libobject

(* Registered lemmas are expected to be of the form
     x R y -> y == z -> x R z    (in the right table)
     x R y -> x == z -> z R y    (in the left table)
*)

let transitivity_right_table = Summary.ref [] ~name:"transitivity-steps-r"
let transitivity_left_table = Summary.ref [] ~name:"transitivity-steps-l"

(* [step] tries to apply a rewriting lemma; then apply [tac] intended to
   complete to proof of the last hypothesis (assumed to state an equality) *)

let step left x tac =
  let l =
    List.map (fun lem ->
      let lem = EConstr.of_constr lem in
      Tacticals.tclTHENLAST
        (apply_with_bindings (lem, ImplicitBindings [x]))
        tac)
      !(if left then transitivity_left_table else transitivity_right_table)
  in
  Tacticals.tclFIRST l

(* Main function to push lemmas in persistent environment *)

let cache_transitivity_lemma (left,lem) =
  if left then
    transitivity_left_table  := lem :: !transitivity_left_table
  else
    transitivity_right_table := lem :: !transitivity_right_table

let subst_transitivity_lemma (subst,(b,ref)) = (b,subst_mps subst ref)

let inTransitivity : bool * Constr.t -> obj =
  declare_object @@ global_object_nodischarge "TRANSITIVITY-STEPS"
    ~cache:cache_transitivity_lemma
    ~subst:(Some subst_transitivity_lemma)

(* Main entry points *)

let add_transitivity_lemma left lem =
  let env = Global.env () in
  let sigma = Evd.from_env env in
  let lem',ctx (*FIXME*) = Constrintern.interp_constr env sigma lem in
  let lem' = EConstr.to_constr sigma lem' in
  Lib.add_leaf (inTransitivity (left,lem'))


# 1097 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "stepl" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("stepl", Tacentries.TyArg (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                         Tacentries.TyIdent ("by", 
                                                         Tacentries.TyArg (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_tactic), 
                                                         Tacentries.TyNil)))), 
           (fun c tac ist -> 
# 418 "plugins/ltac/extratactics.mlg"
                                             step true c (Tacinterp.tactic_of_value ist tac) 
# 1109 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("stepl", Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                        Tacentries.TyNil)), 
          (fun c ist -> 
# 419 "plugins/ltac/extratactics.mlg"
                            step true c (Proofview.tclUNIT ()) 
# 1117 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "stepr" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("stepr", Tacentries.TyArg (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                         Tacentries.TyIdent ("by", 
                                                         Tacentries.TyArg (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_tactic), 
                                                         Tacentries.TyNil)))), 
           (fun c tac ist -> 
# 423 "plugins/ltac/extratactics.mlg"
                                             step false c (Tacinterp.tactic_of_value ist tac) 
# 1130 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("stepr", Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                        Tacentries.TyNil)), 
          (fun c ist -> 
# 424 "plugins/ltac/extratactics.mlg"
                            step false c (Proofview.tclUNIT ()) 
# 1138 "plugins/ltac/extratactics.ml"
)))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"AddStepl" ~classifier:(fun ~atts:_ _ -> Vernacextend.classify_as_sideeff) ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Declare",
           Vernacextend.TyTerminal
           ("Left",
            Vernacextend.TyTerminal
            ("Step",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyNil)))),
          (let coqpp_body t () = Vernactypes.vtdefault (fun () -> 
# 429 "plugins/ltac/extratactics.mlg"
      add_transitivity_lemma true t 
# 1155 "plugins/ltac/extratactics.ml"
) in
            fun t ?loc ~atts () ->
            coqpp_body t (Attributes.unsupported_attributes atts)),
          None))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"AddStepr" ~classifier:(fun ~atts:_ _ -> Vernacextend.classify_as_sideeff) ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Declare",
           Vernacextend.TyTerminal
           ("Right",
            Vernacextend.TyTerminal
            ("Step",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyNil)))),
          (let coqpp_body t () = Vernactypes.vtdefault (fun () -> 
# 434 "plugins/ltac/extratactics.mlg"
      add_transitivity_lemma false t 
# 1175 "plugins/ltac/extratactics.ml"
) in
            fun t ?loc ~atts () ->
            coqpp_body t (Attributes.unsupported_attributes atts)),
          None))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "generalize_eqs" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("generalize_eqs", Tacentries.TyArg (
                                                                  Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                                  Tacentries.TyNil)), 
           (fun id ist -> 
# 441 "plugins/ltac/extratactics.mlg"
                                   Generalize.abstract_generalize ~generalize_vars:false id 
# 1188 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "dep_generalize_eqs" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("generalize_eqs", 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                             Tacentries.TyNil))), 
           (fun id ist -> 
# 444 "plugins/ltac/extratactics.mlg"
                                               Generalize.abstract_generalize ~generalize_vars:false ~force_dep:true id 
# 1199 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "generalize_eqs_vars" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("generalize_eqs_vars", 
                            Tacentries.TyArg (Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                            Tacentries.TyNil)), (fun id ist -> 
# 447 "plugins/ltac/extratactics.mlg"
                                        Generalize.abstract_generalize ~generalize_vars:true id 
# 1208 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "dep_generalize_eqs_vars" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("generalize_eqs_vars", 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                             Tacentries.TyNil))), 
           (fun id ist -> 
# 450 "plugins/ltac/extratactics.mlg"
                                                    Generalize.abstract_generalize ~force_dep:true ~generalize_vars:true id 
# 1219 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "specialize_eqs" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("specialize_eqs", Tacentries.TyArg (
                                                                  Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                                  Tacentries.TyNil)), 
           (fun id ist -> 
# 458 "plugins/ltac/extratactics.mlg"
                                    specialize_eqs id 
# 1229 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "destauto" ~level:0 ~deprecation:( Deprecation.make ~since:"8.20" () ) 
         [(Tacentries.TyML (Tacentries.TyIdent ("destauto", Tacentries.TyNil), 
           (fun ist -> 
# 462 "plugins/ltac/extratactics.mlg"
                      Internals.destauto 
# 1237 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("destauto", Tacentries.TyIdent ("in", 
                                                           Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_hyp), 
                                                           Tacentries.TyNil))), 
          (fun id ist -> 
# 463 "plugins/ltac/extratactics.mlg"
                                   Internals.destauto_in id 
# 1246 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "transparent_abstract" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("transparent_abstract", 
                            Tacentries.TyArg (Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 3), 
                            Tacentries.TyNil)), (fun t ist -> 
# 474 "plugins/ltac/extratactics.mlg"
                                             Proofview.Goal.enter begin fun gl ->
    Abstract.tclABSTRACT ~opaque:false None (Tacinterp.tactic_of_value ist t) end; 
# 1256 "plugins/ltac/extratactics.ml"
)));
         (Tacentries.TyML (Tacentries.TyIdent ("transparent_abstract", 
                           Tacentries.TyArg (Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 3), 
                           Tacentries.TyIdent ("using", Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_ident), 
                                                        Tacentries.TyNil)))), 
          (fun t id ist -> 
# 476 "plugins/ltac/extratactics.mlg"
                                                               Proofview.Goal.enter begin fun gl ->
    Abstract.tclABSTRACT ~opaque:false (Some id) (Tacinterp.tactic_of_value ist t) end; 
# 1267 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "constr_eq" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("constr_eq", Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                             Tacentries.TyNil))), 
           (fun x y ist -> 
# 483 "plugins/ltac/extratactics.mlg"
                                           Tactics.constr_eq ~strict:false x y 
# 1279 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "constr_eq_strict" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("constr_eq_strict", Tacentries.TyArg (
                                                                    Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                                    Tacentries.TyArg (
                                                                    Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                                    Tacentries.TyNil))), 
           (fun x y ist -> 
# 487 "plugins/ltac/extratactics.mlg"
                                                  Tactics.constr_eq ~strict:true x y 
# 1291 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "constr_eq_nounivs" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("constr_eq_nounivs", 
                            Tacentries.TyArg (Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                            Tacentries.TyArg (Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                            Tacentries.TyNil))), (fun x y ist -> 
# 491 "plugins/ltac/extratactics.mlg"
                                                  
    Proofview.tclEVARMAP >>= fun sigma ->
    if EConstr.eq_constr_nounivs sigma x y then Proofview.tclUNIT () else Tacticals.tclFAIL (str "Not equal") 
# 1303 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_evar" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_evar", Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                           Tacentries.TyNil)), 
           (fun x ist -> 
# 497 "plugins/ltac/extratactics.mlg"
                               Internals.is_evar x 
# 1313 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "has_evar" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("has_evar", Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                            Tacentries.TyNil)), 
           (fun x ist -> 
# 501 "plugins/ltac/extratactics.mlg"
                                Internals.has_evar x 
# 1323 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_hyp" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_var", Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                          Tacentries.TyNil)), 
           (fun x ist -> 
# 505 "plugins/ltac/extratactics.mlg"
                              Internals.is_var x 
# 1333 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_fix" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_fix", Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                          Tacentries.TyNil)), 
           (fun x ist -> 
# 509 "plugins/ltac/extratactics.mlg"
                              Internals.is_fix x 
# 1343 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_cofix" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_cofix", Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                            Tacentries.TyNil)), 
           (fun x ist -> 
# 513 "plugins/ltac/extratactics.mlg"
                                Internals.is_cofix x 
# 1353 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_ind" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_ind", Tacentries.TyArg (
                                                          Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                          Tacentries.TyNil)), 
           (fun x ist -> 
# 517 "plugins/ltac/extratactics.mlg"
                              Internals.is_ind x 
# 1363 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_constructor" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_constructor", Tacentries.TyArg (
                                                                  Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                                  Tacentries.TyNil)), 
           (fun x ist -> 
# 521 "plugins/ltac/extratactics.mlg"
                                      Internals.is_constructor x 
# 1373 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_proj" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_proj", Tacentries.TyArg (
                                                           Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                           Tacentries.TyNil)), 
           (fun x ist -> 
# 525 "plugins/ltac/extratactics.mlg"
                               Internals.is_proj x 
# 1383 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "is_const" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("is_const", Tacentries.TyArg (
                                                            Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                            Tacentries.TyNil)), 
           (fun x ist -> 
# 529 "plugins/ltac/extratactics.mlg"
                                Internals.is_const x 
# 1393 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "shelve" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("shelve", Tacentries.TyNil), 
           (fun ist -> 
# 534 "plugins/ltac/extratactics.mlg"
                    Proofview.shelve 
# 1401 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "shelve_unifiable" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("shelve_unifiable", Tacentries.TyNil), 
           (fun ist -> 
# 541 "plugins/ltac/extratactics.mlg"
                              Proofview.shelve_unifiable 
# 1409 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "unshelve" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("unshelve", Tacentries.TyArg (
                                                            Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 1), 
                                                            Tacentries.TyNil)), 
           (fun t ist -> 
# 546 "plugins/ltac/extratactics.mlg"
                                 Internals.unshelve ist t 
# 1419 "plugins/ltac/extratactics.ml"
)))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"Unshelve"  ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal ("Unshelve", Vernacextend.TyNil),
          (let coqpp_body () =
            Vernactypes.vtmodifyproof (fun ~pstate -> (
# 553 "plugins/ltac/extratactics.mlg"
       fun ~pstate -> Declare.Proof.map ~f:(fun p  -> Proof.unshelve p) pstate  
# 1430 "plugins/ltac/extratactics.ml"
) ~pstate) in
            fun ?loc ~atts () ->
            coqpp_body (Attributes.unsupported_attributes atts)),
          Some (fun ~atts -> 
# 552 "plugins/ltac/extratactics.mlg"
       classify_as_proofstep 
# 1437 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "give_up" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("give_up", Tacentries.TyNil), 
           (fun ist -> 
# 561 "plugins/ltac/extratactics.mlg"
      Proofview.give_up 
# 1445 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "cycle" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("cycle", Tacentries.TyArg (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), 
                                                         Tacentries.TyNil)), 
           (fun n ist -> 
# 566 "plugins/ltac/extratactics.mlg"
                                 Proofview.cycle n 
# 1455 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "swap" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("swap", Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), 
                                                        Tacentries.TyArg (
                                                        Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), 
                                                        Tacentries.TyNil))), 
           (fun i j ist -> 
# 571 "plugins/ltac/extratactics.mlg"
                                              Proofview.swap i j 
# 1467 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "revgoals" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("revgoals", Tacentries.TyNil), 
           (fun ist -> 
# 576 "plugins/ltac/extratactics.mlg"
                      Proofview.revgoals 
# 1475 "plugins/ltac/extratactics.ml"
)))]


# 579 "plugins/ltac/extratactics.mlg"
 

type cmp =
  | Eq
  | Lt | Le
  | Gt | Ge

type 'i test =
  | Test of cmp * 'i * 'i

let pr_cmp = function
  | Eq -> Pp.str"="
  | Lt -> Pp.str"<"
  | Le -> Pp.str"<="
  | Gt -> Pp.str">"
  | Ge -> Pp.str">="

let pr_cmp' _prc _prlc _prt = pr_cmp

let pr_test_gen f (Test(c,x,y)) =
  Pp.(f x ++ pr_cmp c ++ f y)

let pr_test = pr_test_gen (Pputils.pr_or_var Pp.int)

let pr_test' _prc _prlc _prt = pr_test

let pr_itest = pr_test_gen Pp.int

let pr_itest' _prc _prlc _prt = pr_itest


# 1511 "plugins/ltac/extratactics.ml"

let (wit_comparison, comparison) = Tacentries.argument_extend ~plugin:"rocq-runtime.plugins.ltac" ~name:"comparison" 
                                   {
                                   Tacentries.arg_parsing = Vernacextend.Arg_rules
                                                            ([(Procq.Production.make
                                                               (Procq.Rule.next
                                                                (Procq.Rule.stop)
                                                                ((Procq.Symbol.token (Procq.terminal ">="))))
                                                               (fun _ loc ->
                                                               
# 616 "plugins/ltac/extratactics.mlg"
                Ge 
# 1524 "plugins/ltac/extratactics.ml"
));
                                                             (Procq.Production.make
                                                              (Procq.Rule.next
                                                               (Procq.Rule.stop)
                                                               ((Procq.Symbol.token (Procq.terminal ">"))))
                                                              (fun _ loc -> 
# 615 "plugins/ltac/extratactics.mlg"
                Gt 
# 1533 "plugins/ltac/extratactics.ml"
));
                                                             (Procq.Production.make
                                                              (Procq.Rule.next
                                                               (Procq.Rule.stop)
                                                               ((Procq.Symbol.token (Procq.terminal "<="))))
                                                              (fun _ loc -> 
# 614 "plugins/ltac/extratactics.mlg"
                Le 
# 1542 "plugins/ltac/extratactics.ml"
));
                                                             (Procq.Production.make
                                                              (Procq.Rule.next
                                                               (Procq.Rule.stop)
                                                               ((Procq.Symbol.token (Procq.terminal "<"))))
                                                              (fun _ loc -> 
# 613 "plugins/ltac/extratactics.mlg"
                Lt 
# 1551 "plugins/ltac/extratactics.ml"
));
                                                             (Procq.Production.make
                                                              (Procq.Rule.next
                                                               (Procq.Rule.stop)
                                                               ((Procq.Symbol.token (Procq.terminal "="))))
                                                              (fun _ loc -> 
# 612 "plugins/ltac/extratactics.mlg"
                Eq 
# 1560 "plugins/ltac/extratactics.ml"
))]);
                                   Tacentries.arg_tag = None;
                                   Tacentries.arg_intern = Tacentries.ArgInternFun (fun ist v -> (ist, v));
                                   Tacentries.arg_subst = Tacentries.ArgSubstFun (fun s v -> v);
                                   Tacentries.arg_interp = Tacentries.ArgInterpRet;
                                   Tacentries.arg_printer = ((fun env sigma -> 
                                                            
# 611 "plugins/ltac/extratactics.mlg"
                                        pr_cmp' 
# 1570 "plugins/ltac/extratactics.ml"
), (fun env sigma -> 
                                                            
# 611 "plugins/ltac/extratactics.mlg"
                                        pr_cmp' 
# 1575 "plugins/ltac/extratactics.ml"
), (fun env sigma -> 
                                                            
# 611 "plugins/ltac/extratactics.mlg"
                                        pr_cmp' 
# 1580 "plugins/ltac/extratactics.ml"
));
                                   }
let _ = (wit_comparison, comparison)


# 619 "plugins/ltac/extratactics.mlg"
 

let interp_test ist env sigma = function
  | Test (c,x,y) ->
      Test(c,Tacinterp.interp_int_or_var ist x,Tacinterp.interp_int_or_var ist y)


# 1594 "plugins/ltac/extratactics.ml"

let (wit_test, test) = Tacentries.argument_extend ~plugin:"rocq-runtime.plugins.ltac" ~name:"test" 
                       {
                       Tacentries.arg_parsing = Vernacextend.Arg_rules
                                                ([(Procq.Production.make
                                                   (Procq.Rule.next
                                                    (Procq.Rule.next
                                                     (Procq.Rule.next
                                                      (Procq.Rule.stop)
                                                      ((Procq.Symbol.nterm int_or_var)))
                                                     ((Procq.Symbol.nterm comparison)))
                                                    ((Procq.Symbol.nterm int_or_var)))
                                                   (fun y c x loc -> 
# 632 "plugins/ltac/extratactics.mlg"
                                                     Test(c,x,y) 
# 1610 "plugins/ltac/extratactics.ml"
))]);
                       Tacentries.arg_tag = None;
                       Tacentries.arg_intern = Tacentries.ArgInternFun (fun ist v -> (ist, v));
                       Tacentries.arg_subst = Tacentries.ArgSubstFun (fun s v -> v);
                       Tacentries.arg_interp = Tacentries.ArgInterpSimple (
# 629 "plugins/ltac/extratactics.mlg"
                   interp_test 
# 1618 "plugins/ltac/extratactics.ml"
);
                       Tacentries.arg_printer = ((fun env sigma -> 
# 630 "plugins/ltac/extratactics.mlg"
                   pr_test' 
# 1623 "plugins/ltac/extratactics.ml"
), (fun env sigma -> 
                                                
# 631 "plugins/ltac/extratactics.mlg"
                    pr_test' 
# 1628 "plugins/ltac/extratactics.ml"
), (fun env sigma -> 
                                                
# 628 "plugins/ltac/extratactics.mlg"
               pr_itest' 
# 1633 "plugins/ltac/extratactics.ml"
));
                       }
let _ = (wit_test, test)


# 635 "plugins/ltac/extratactics.mlg"
 

let interp_cmp = function
  | Eq -> Int.equal
  | Lt -> ((<):int->int->bool)
  | Le -> ((<=):int->int->bool)
  | Gt -> ((>):int->int->bool)
  | Ge -> ((>=):int->int->bool)

let run_test = function
  | Test(c,x,y) -> interp_cmp c x y

let guard tst =
  if run_test tst then
    Proofview.tclUNIT ()
  else
    let msg = Pp.(str"Condition not satisfied:"++ws 1++(pr_itest tst)) in
    Tacticals.tclZEROMSG msg


# 1660 "plugins/ltac/extratactics.ml"

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "guard" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("guard", Tacentries.TyArg (
                                                         Extend.TUentry (Genarg.get_arg_tag wit_test), 
                                                         Tacentries.TyNil)), 
           (fun tst ist -> 
# 657 "plugins/ltac/extratactics.mlg"
                             guard tst 
# 1669 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "decompose" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("decompose", Tacentries.TyIdent ("[", 
                                                             Tacentries.TyArg (
                                                             Extend.TUlist1 (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_constr)), 
                                                             Tacentries.TyIdent ("]", 
                                                             Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                             Tacentries.TyNil))))), 
           (fun l c ist -> 
# 661 "plugins/ltac/extratactics.mlg"
                                                           Internals.decompose l c 
# 1684 "plugins/ltac/extratactics.ml"
)))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"Declare_keys" ~classifier:(fun ~atts:_ _ -> Vernacextend.classify_as_sideeff) ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Declare",
           Vernacextend.TyTerminal
           ("Equivalent",
            Vernacextend.TyTerminal
            ("Keys",
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr),
             Vernacextend.TyNil))))),
          (let coqpp_body c c' () = Vernactypes.vtdefault (fun () -> 
# 667 "plugins/ltac/extratactics.mlg"
                                                              Internals.declare_equivalent_keys c c' 
# 1702 "plugins/ltac/extratactics.ml"
) in
            fun c c' ?loc ~atts () ->
            coqpp_body c c' (Attributes.unsupported_attributes atts)),
          None))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"Print_keys" ~classifier:(fun ~atts:_ _ -> Vernacextend.classify_as_query) ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Print",
           Vernacextend.TyTerminal
           ("Equivalent",
            Vernacextend.TyTerminal ("Keys", Vernacextend.TyNil))),
          (let coqpp_body () = Vernactypes.vtdefault (fun () -> 
# 671 "plugins/ltac/extratactics.mlg"
                                       Feedback.msg_notice (Keys.pr_keys Printer.pr_global) 
# 1719 "plugins/ltac/extratactics.ml"
) in
            fun ?loc ~atts () ->
            coqpp_body (Attributes.unsupported_attributes atts)),
          None))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"OptimizeProof"  ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Optimize", Vernacextend.TyTerminal ("Proof", Vernacextend.TyNil)),
          (let coqpp_body () =
            Vernactypes.vtmodifyproof (fun ~pstate -> (
# 676 "plugins/ltac/extratactics.mlg"
    fun ~pstate -> Declare.Proof.compact pstate 
# 1734 "plugins/ltac/extratactics.ml"
) ~pstate) in
            fun ?loc ~atts () ->
            coqpp_body (Attributes.unsupported_attributes atts)),
          Some (fun ~atts -> 
# 675 "plugins/ltac/extratactics.mlg"
                                         classify_as_proofstep 
# 1741 "plugins/ltac/extratactics.ml"
)));
         (Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("Optimize", Vernacextend.TyTerminal ("Heap", Vernacextend.TyNil)),
          (let coqpp_body () = Vernactypes.vtdefault (fun () -> 
# 678 "plugins/ltac/extratactics.mlg"
    Gc.compact () 
# 1750 "plugins/ltac/extratactics.ml"
) in
            fun ?loc ~atts () ->
            coqpp_body (Attributes.unsupported_attributes atts)),
          Some (fun ~atts -> 
# 677 "plugins/ltac/extratactics.mlg"
                             classify_as_proofstep 
# 1757 "plugins/ltac/extratactics.ml"
)))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "optimize_heap" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("optimize_heap", Tacentries.TyNil), 
           (fun ist -> 
# 682 "plugins/ltac/extratactics.mlg"
                           Internals.tclOPTIMIZE_HEAP 
# 1765 "plugins/ltac/extratactics.ml"
)))]

let () = Vernacextend.static_vernac_extend ~plugin:(Some "rocq-runtime.plugins.ltac") ~command:"infoH" ~classifier:(fun ~atts:_ _ -> Vernacextend.classify_as_query) ?entry:None 
         [(Vernacextend.TyML
         (false,
          Vernacextend.TyTerminal
          ("infoH",
           Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_tactic),
           Vernacextend.TyNil)),
          (let coqpp_body tac () =
            Vernactypes.vtreadproof (fun ~pstate -> (
# 686 "plugins/ltac/extratactics.mlg"
                                                Internals.infoH tac 
# 1779 "plugins/ltac/extratactics.ml"
) ~pstate) in
            fun tac ?loc ~atts () ->
            coqpp_body tac (Attributes.unsupported_attributes atts)),
          None))]

let () = Tacentries.tactic_extend "rocq-runtime.plugins.ltac" "with_strategy" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("with_strategy", Tacentries.TyArg (
                                                                 Extend.TUentry (Genarg.get_arg_tag wit_strategy_level_or_var), 
                                                                 Tacentries.TyIdent ("[", 
                                                                 Tacentries.TyArg (
                                                                 Extend.TUlist1 (
                                                                 Extend.TUentry (Genarg.get_arg_tag wit_smart_global)), 
                                                                 Tacentries.TyIdent ("]", 
                                                                 Tacentries.TyArg (
                                                                 Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 3), 
                                                                 Tacentries.TyNil)))))), 
           (fun v q tac ist -> 
# 692 "plugins/ltac/extratactics.mlg"
                                                                                                
  with_set_strategy [(v, q)] (Tacinterp.tactic_of_value ist tac)

# 1801 "plugins/ltac/extratactics.ml"
)))]

