| 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 |
{ |
| 12 |
|
| 13 |
open Pp |
| 14 |
open Stdarg |
| 15 |
open Procq |
| 16 |
open Procq.Prim |
| 17 |
open Procq.Constr |
| 18 |
open Pltac |
| 19 |
open Hints |
| 20 |
|
| 21 |
} |
| 22 |
|
| 23 |
DECLARE PLUGIN "rocq-runtime.plugins.ltac" |
| 24 |
|
| 25 |
(* Hint bases *) |
| 26 |
|
| 27 |
|
| 28 |
TACTIC EXTEND eassumption |
| 29 |
| [ "eassumption" ] -> { Eauto.e_assumption } |
| 30 |
END |
| 31 |
|
| 32 |
TACTIC EXTEND eexact |
| 33 |
| [ "eexact" constr(c) ] -> { Eauto.e_give_exact c } |
| 34 |
END |
| 35 |
|
| 36 |
{ |
| 37 |
|
| 38 |
let pr_hintbases _prc _prlc _prt = Pptactic.pr_hintbases |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
ARGUMENT EXTEND hintbases |
| 43 |
TYPED AS preident list option |
| 44 |
PRINTED BY { pr_hintbases } |
| 45 |
| [ "with" "*" ] -> { None } |
| 46 |
| [ "with" ne_preident_list(l) ] -> { Some l } |
| 47 |
| [ ] -> { Some [] } |
| 48 |
END |
| 49 |
|
| 50 |
{ |
| 51 |
|
| 52 |
let eval_uconstrs ist cs = |
| 53 |
let flags = Pretyping.{ |
| 54 |
use_coercions = true; |
| 55 |
use_typeclasses = NoUseTC; |
| 56 |
solve_unification_constraints = true; |
| 57 |
fail_evar = false; |
| 58 |
expand_evars = true; |
| 59 |
program_mode = false; |
| 60 |
poly = PolyFlags.default; |
| 61 |
undeclared_evars_rr = false; |
| 62 |
unconstrained_sorts = false; |
| 63 |
} in |
| 64 |
let map c env sigma = c env sigma in |
| 65 |
List.map (fun c -> map (Tacinterp.type_uconstr ~flags ist c)) cs |
| 66 |
|
| 67 |
let pr_auto_using_raw env sigma _ _ _ = Pptactic.pr_auto_using @@ Ppconstr.(pr_constr_expr ~flags:(current_flags())) env sigma |
| 68 |
let pr_auto_using_glob env sigma _ _ _ = Pptactic.pr_auto_using (fun (c,_) -> |
| 69 |
Printer.pr_glob_constr_env env sigma c) |
| 70 |
let pr_auto_using env sigma _ _ _ = Pptactic.pr_auto_using @@ |
| 71 |
Printer.pr_closed_glob_env env sigma |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
ARGUMENT EXTEND auto_using |
| 76 |
TYPED AS uconstr list |
| 77 |
PRINTED BY { pr_auto_using env sigma } |
| 78 |
RAW_PRINTED BY { pr_auto_using_raw env sigma } |
| 79 |
GLOB_PRINTED BY { pr_auto_using_glob env sigma } |
| 80 |
| [ "using" ne_uconstr_list_sep(l, ",") ] -> { l } |
| 81 |
| [ ] -> { [] } |
| 82 |
END |
| 83 |
|
| 84 |
(** Auto *) |
| 85 |
|
| 86 |
TACTIC EXTEND trivial |
| 87 |
| [ "trivial" auto_using(lems) hintbases(db) ] -> |
| 88 |
{ Auto.gen_trivial (eval_uconstrs ist lems) db } |
| 89 |
END |
| 90 |
|
| 91 |
TACTIC EXTEND info_trivial |
| 92 |
| [ "info_trivial" auto_using(lems) hintbases(db) ] -> |
| 93 |
{ Auto.gen_trivial ~debug:Info (eval_uconstrs ist lems) db } |
| 94 |
END |
| 95 |
|
| 96 |
TACTIC EXTEND debug_trivial |
| 97 |
| [ "debug" "trivial" auto_using(lems) hintbases(db) ] -> |
| 98 |
{ Auto.gen_trivial ~debug:Debug (eval_uconstrs ist lems) db } |
| 99 |
END |
| 100 |
|
| 101 |
TACTIC EXTEND auto |
| 102 |
| [ "auto" nat_or_var_opt(n) auto_using(lems) hintbases(db) ] -> |
| 103 |
{ Auto.gen_auto n (eval_uconstrs ist lems) db } |
| 104 |
END |
| 105 |
|
| 106 |
TACTIC EXTEND info_auto |
| 107 |
| [ "info_auto" nat_or_var_opt(n) auto_using(lems) hintbases(db) ] -> |
| 108 |
{ Auto.gen_auto ~debug:Info n (eval_uconstrs ist lems) db } |
| 109 |
END |
| 110 |
|
| 111 |
TACTIC EXTEND debug_auto |
| 112 |
| [ "debug" "auto" nat_or_var_opt(n) auto_using(lems) hintbases(db) ] -> |
| 113 |
{ Auto.gen_auto ~debug:Debug n (eval_uconstrs ist lems) db } |
| 114 |
END |
| 115 |
|
| 116 |
(** Eauto *) |
| 117 |
|
| 118 |
TACTIC EXTEND eauto |
| 119 |
| [ "eauto" nat_or_var_opt(depth) auto_using(lems) hintbases(db) ] -> |
| 120 |
{ Eauto.gen_eauto ?depth (eval_uconstrs ist lems) db } |
| 121 |
END |
| 122 |
|
| 123 |
TACTIC EXTEND debug_eauto |
| 124 |
| [ "debug" "eauto" nat_or_var_opt(depth) auto_using(lems) hintbases(db) ] -> |
| 125 |
{ Eauto.gen_eauto ~debug:Debug ?depth (eval_uconstrs ist lems) db } |
| 126 |
END |
| 127 |
|
| 128 |
TACTIC EXTEND info_eauto |
| 129 |
| [ "info_eauto" nat_or_var_opt(depth) auto_using(lems) hintbases(db) ] -> |
| 130 |
{ Eauto.gen_eauto ~debug:Info ?depth (eval_uconstrs ist lems) db } |
| 131 |
END |
| 132 |
|
| 133 |
TACTIC EXTEND autounfold |
| 134 |
| [ "autounfold" hintbases(db) clause_dft_concl(cl) ] -> { Eauto.autounfold_tac db cl } |
| 135 |
END |
| 136 |
|
| 137 |
TACTIC EXTEND autounfold_one |
| 138 |
| [ "autounfold_one" hintbases(db) "in" hyp(id) ] -> |
| 139 |
{ Eauto.autounfold_one (match db with None -> ["core"] | Some x -> "core"::x) (Some (id, Locus.InHyp)) } |
| 140 |
| [ "autounfold_one" hintbases(db) ] -> |
| 141 |
{ Eauto.autounfold_one (match db with None -> ["core"] | Some x -> "core"::x) None } |
| 142 |
END |
| 143 |
|
| 144 |
TACTIC EXTEND unify |
| 145 |
| ["unify" constr(x) constr(y) ] -> { Tactics.unify x y } |
| 146 |
| ["unify" constr(x) constr(y) "with" preident(base) ] -> { |
| 147 |
let table = try Some (Hints.searchtable_map base) with Not_found -> None in |
| 148 |
match table with |
| 149 |
| None -> |
| 150 |
let msg = str "Hint table " ++ str base ++ str " not found" in |
| 151 |
Tacticals.tclZEROMSG msg |
| 152 |
| Some t -> |
| 153 |
let state = Hints.Hint_db.transparent_state t in |
| 154 |
Tactics.unify ~state x y |
| 155 |
} |
| 156 |
END |
| 157 |
|
| 158 |
TACTIC EXTEND convert |
| 159 |
| ["convert" constr(x) constr(y) ] -> { Tactics.convert x y } |
| 160 |
END |
| 161 |
|
| 162 |
{ |
| 163 |
|
| 164 |
let pr_pre_hints_path c = Hints.pp_hints_path_gen Libnames.pr_qualid c |
| 165 |
|
| 166 |
let hints_path = Entry.make "hints_path" |
| 167 |
|
| 168 |
} |
| 169 |
|
| 170 |
VERNAC ARGUMENT EXTEND hints_path_entry |
| 171 |
PRINTED BY { pr_pre_hints_path } |
| 172 |
| [ hints_path(p) ] -> { p } |
| 173 |
END |
| 174 |
|
| 175 |
GRAMMAR EXTEND Gram |
| 176 |
GLOBAL: hints_path; |
| 177 |
hints_path: |
| 178 |
[ "1" LEFTA |
| 179 |
[ p = hints_path; "*" -> { Hints.PathStar p } |
| 180 |
| p = hints_path; "|"; q = hints_path LEVEL "0" -> { Hints.PathOr (p, q) } |
| 181 |
| p = hints_path; q = hints_path LEVEL "0" -> { Hints.PathSeq (p, q) } |
| 182 |
] |
| 183 |
| "0" NONA |
| 184 |
[ "("; p = hints_path; ")" -> { p } |
| 185 |
| IDENT "emp" -> { Hints.PathEmpty } |
| 186 |
| IDENT "eps" -> { Hints.PathEpsilon } |
| 187 |
| g = LIST1 global -> { Hints.PathAtom (Hints.PathHints g) } |
| 188 |
| "_" -> { Hints.PathAtom Hints.PathAny } |
| 189 |
] |
| 190 |
]; |
| 191 |
END |
| 192 |
|
| 193 |
ARGUMENT EXTEND opthints |
| 194 |
TYPED AS preident list option |
| 195 |
PRINTED BY { pr_hintbases } |
| 196 |
| [ ":" ne_preident_list(l) ] -> { Some l } |
| 197 |
| [ ] -> { None } |
| 198 |
END |
| 199 |
|
| 200 |
VERNAC COMMAND EXTEND HintCut CLASSIFIED AS SIDEFF |
| 201 |
| #[ locality = Attributes.hint_locality; ] [ "Hint" "Cut" "[" hints_path_entry(p) "]" opthints(dbnames) ] -> { |
| 202 |
let entry = Hints.HintsCutEntry (Hints.glob_hints_path p) in |
| 203 |
Hints.add_hints ~locality |
| 204 |
(match dbnames with None -> ["core"] | Some l -> l) entry; |
| 205 |
} |
| 206 |
END |