| 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 Class_tactics |
| 14 |
open Stdarg |
| 15 |
open Classes |
| 16 |
|
| 17 |
} |
| 18 |
|
| 19 |
DECLARE PLUGIN "rocq-runtime.plugins.ltac" |
| 20 |
|
| 21 |
(** Options: depth, debug and transparency settings. *) |
| 22 |
|
| 23 |
VERNAC COMMAND EXTEND Typeclasses_Unfold_Settings CLASSIFIED AS SIDEFF |
| 24 |
| #[ locality = Attributes.hint_locality ] |
| 25 |
[ "Typeclasses" "Transparent" ne_reference_list(cl) ] -> { |
| 26 |
set_typeclass_transparency_com ~locality cl true |
| 27 |
} |
| 28 |
END |
| 29 |
|
| 30 |
VERNAC COMMAND EXTEND Typeclasses_Rigid_Settings CLASSIFIED AS SIDEFF |
| 31 |
| #[ locality = Attributes.hint_locality ] |
| 32 |
[ "Typeclasses" "Opaque" ne_reference_list(cl) ] -> { |
| 33 |
set_typeclass_transparency_com ~locality cl false |
| 34 |
} |
| 35 |
END |
| 36 |
|
| 37 |
{ |
| 38 |
|
| 39 |
let pr_debug _prc _prlc _prt b = |
| 40 |
if b then Pp.str "debug" else Pp.mt() |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
ARGUMENT EXTEND debug TYPED AS bool PRINTED BY { pr_debug } |
| 45 |
| [ "debug" ] -> { true } |
| 46 |
| [ ] -> { false } |
| 47 |
END |
| 48 |
|
| 49 |
{ |
| 50 |
|
| 51 |
let pr_search_strategy_name _prc _prlc _prt = function |
| 52 |
| Dfs -> Pp.str "dfs" |
| 53 |
| Bfs -> Pp.str "bfs" |
| 54 |
|
| 55 |
let pr_search_strategy _prc _prlc _prt = function |
| 56 |
| Some s -> pr_search_strategy_name _prc _prlc _prt s |
| 57 |
| None -> Pp.mt () |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
ARGUMENT EXTEND eauto_search_strategy_name PRINTED BY { pr_search_strategy_name } |
| 62 |
| [ "bfs" ] -> { Bfs } |
| 63 |
| [ "dfs" ] -> { Dfs } |
| 64 |
END |
| 65 |
|
| 66 |
ARGUMENT EXTEND eauto_search_strategy PRINTED BY { pr_search_strategy } |
| 67 |
| [ "(" eauto_search_strategy_name(s) ")" ] -> { Some s } |
| 68 |
| [ ] -> { None } |
| 69 |
END |
| 70 |
|
| 71 |
(* true = All transparent, false = Opaque if possible *) |
| 72 |
|
| 73 |
VERNAC COMMAND EXTEND Typeclasses_Settings CLASSIFIED AS SIDEFF |
| 74 |
| [ "Typeclasses" "eauto" ":=" debug(d) eauto_search_strategy(s) natural_opt(depth) ] -> { |
| 75 |
set_typeclasses_debug d; |
| 76 |
Option.iter set_typeclasses_strategy s; |
| 77 |
set_typeclasses_depth depth |
| 78 |
} |
| 79 |
END |
| 80 |
|
| 81 |
TACTIC EXTEND typeclasses_eauto |
| 82 |
| [ "typeclasses" "eauto" "dfs" nat_or_var_opt(d) "with" ne_preident_list(l) ] -> |
| 83 |
{ typeclasses_eauto ~depth:d ~strategy:Dfs l } |
| 84 |
| [ "typeclasses" "eauto" "bfs" nat_or_var_opt(d) "with" ne_preident_list(l) ] -> |
| 85 |
{ typeclasses_eauto ~depth:d ~strategy:Bfs l } |
| 86 |
| [ "typeclasses" "eauto" "best_effort" nat_or_var_opt(d) "with" ne_preident_list(l) ] -> |
| 87 |
{ typeclasses_eauto ~depth:d ~best_effort:true l } |
| 88 |
| [ "typeclasses" "eauto" nat_or_var_opt(d) "with" ne_preident_list(l) ] -> |
| 89 |
{ typeclasses_eauto ~depth:d l } |
| 90 |
| [ "typeclasses" "eauto" "bfs" nat_or_var_opt(d) ] -> { |
| 91 |
typeclasses_eauto ~depth:d ~strategy:Bfs ~only_classes:true [Class_tactics.typeclasses_db] } |
| 92 |
| [ "typeclasses" "eauto" "dfs" nat_or_var_opt(d) ] -> { |
| 93 |
typeclasses_eauto ~depth:d ~strategy:Dfs ~only_classes:true [Class_tactics.typeclasses_db] } |
| 94 |
| [ "typeclasses" "eauto" "best_effort" nat_or_var_opt(d) ] -> { |
| 95 |
typeclasses_eauto ~depth:d ~only_classes:true ~best_effort:true [Class_tactics.typeclasses_db] } |
| 96 |
| [ "typeclasses" "eauto" nat_or_var_opt(d) ] -> { |
| 97 |
typeclasses_eauto ~depth:d ~only_classes:true [Class_tactics.typeclasses_db] } |
| 98 |
END |
| 99 |
|
| 100 |
{ |
| 101 |
|
| 102 |
let head_of_constr id c = |
| 103 |
let open Proofview.Notations in |
| 104 |
Proofview.tclEVARMAP >>= fun sigma -> |
| 105 |
let id = Taccoerce.coerce_to_ident_not_fresh sigma id in |
| 106 |
let c = Option.get @@ Tacinterp.Value.to_constr c in |
| 107 |
Class_tactics.head_of_constr id c |
| 108 |
|
| 109 |
let () = Tacentries.ml_tactic_extend ~plugin:"rocq-runtime.plugins.ltac" ~name:"head_of_constr" |
| 110 |
~local:true (MLTyArg (MLTyArg MLTyNil)) head_of_constr |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
TACTIC EXTEND not_evar |
| 115 |
| [ "not_evar" constr(ty) ] -> { not_evar ty } |
| 116 |
END |
| 117 |
|
| 118 |
TACTIC EXTEND is_ground |
| 119 |
| [ "is_ground" constr(ty) ] -> { is_ground ty } |
| 120 |
END |
| 121 |
|
| 122 |
TACTIC EXTEND autoapply |
| 123 |
| [ "autoapply" constr(c) "with" preident(i) ] -> { autoapply c i } |
| 124 |
END |