| 1 |
(* coq-prog-args: ("-async-proofs" "off") *) |
| 2 |
(* Wish #2154 by E. van der Weegen *) |
| 3 |
|
| 4 |
(* auto was not using f_equal-style lemmas with metavariables occurring |
| 5 |
only in the type of an evar of the concl, but not directly in the |
| 6 |
concl itself *) |
| 7 |
|
| 8 |
Parameters |
| 9 |
(F: Prop -> Prop) |
| 10 |
(G: forall T, (T -> Prop) -> Type) |
| 11 |
(L: forall A (P: A -> Prop), G A P -> forall x, F (P x)) |
| 12 |
(Q: unit -> Prop). |
| 13 |
|
| 14 |
#[export] Hint Resolve L. |
| 15 |
|
| 16 |
Goal G unit Q -> F (Q tt). |
| 17 |
intro. |
| 18 |
eauto. |
| 19 |
Qed. |
| 20 |
|
| 21 |
(* Test implicit arguments in "using" clause *) |
| 22 |
|
| 23 |
Goal forall n:nat, nat * nat. |
| 24 |
epose (H := pair O). |
| 25 |
auto using H. |
| 26 |
Undo. |
| 27 |
eauto using H. |
| 28 |
Qed. |
| 29 |
|
| 30 |
Create HintDb test discriminated. |
| 31 |
|
| 32 |
Parameter foo : forall x, x = x + 0. |
| 33 |
#[export] Hint Resolve foo : test. |
| 34 |
|
| 35 |
Parameter C : nat -> Type -> Prop. |
| 36 |
|
| 37 |
Parameter c_inst : C 0 nat. |
| 38 |
|
| 39 |
#[export] Hint Resolve c_inst : test. |
| 40 |
|
| 41 |
#[export] Hint Mode C - + : test. |
| 42 |
#[export] Hint Resolve c_inst : test2. |
| 43 |
#[export] Hint Mode C + + : test2. |
| 44 |
|
| 45 |
Goal exists n, C n nat. |
| 46 |
Proof. |
| 47 |
eexists. Fail progress debug eauto with test2. |
| 48 |
progress eauto with test. |
| 49 |
Qed. |
| 50 |
|
| 51 |
(** Patterns of Extern have a "matching" semantics. |
| 52 |
It is not so for apply/exact hints *) |
| 53 |
|
| 54 |
Class B (A : Type). |
| 55 |
Class I. |
| 56 |
#[export] Instance i : I := {}. |
| 57 |
|
| 58 |
Definition flip {A B C : Type} (f : A -> B -> C) := fun y x => f x y. |
| 59 |
Class D (f : nat -> nat -> nat). |
| 60 |
Definition ftest (x y : nat) := x + y. |
| 61 |
Definition flipD (f : nat -> nat -> nat) : D f -> D (flip f). |
| 62 |
Admitted. |
| 63 |
Module Instnopat. |
| 64 |
Local Instance: B nat := {}. |
| 65 |
(* pattern_of_constr -> B nat *) |
| 66 |
(* exact hint *) |
| 67 |
Check (_ : B nat). |
| 68 |
(* map_eauto -> B_instance0 *) |
| 69 |
(* NO Constr_matching.matches !!! *) |
| 70 |
Check (_ : B _). |
| 71 |
|
| 72 |
Goal exists T, B T. |
| 73 |
eexists. |
| 74 |
eauto with typeclass_instances. |
| 75 |
Qed. |
| 76 |
|
| 77 |
Local Instance: D ftest := {}. |
| 78 |
Local Hint Resolve flipD | 0 : typeclass_instances. |
| 79 |
(* pattern: D (flip _) *) |
| 80 |
Fail Timeout 1 Check (_ : D _). (* loops applying flipD *) |
| 81 |
|
| 82 |
End Instnopat. |
| 83 |
|
| 84 |
Module InstnopatApply. |
| 85 |
Local Instance: I -> B nat := {}. |
| 86 |
(* pattern_of_constr -> B nat *) |
| 87 |
(* apply hint *) |
| 88 |
Check (_ : B nat). |
| 89 |
(* map_eauto -> B_instance0 *) |
| 90 |
(* NO Constr_matching.matches !!! *) |
| 91 |
Check (_ : B _). |
| 92 |
|
| 93 |
Goal exists T, B T. |
| 94 |
eexists. |
| 95 |
eauto with typeclass_instances. |
| 96 |
Qed. |
| 97 |
End InstnopatApply. |
| 98 |
|
| 99 |
Module InstPat. |
| 100 |
#[export] Hint Extern 3 (B nat) => split : typeclass_instances. |
| 101 |
(* map_eauto -> Extern hint *) |
| 102 |
(* Constr_matching.matches -> true *) |
| 103 |
Check (_ : B nat). |
| 104 |
(* map_eauto -> Extern hint *) |
| 105 |
(* Constr_matching.matches -> false: |
| 106 |
Because an inductive in the pattern does not match an evar in the goal *) |
| 107 |
Check (_ : B _). |
| 108 |
|
| 109 |
Goal exists T, B T. |
| 110 |
eexists. |
| 111 |
(* map_existential -> Extern hint *) |
| 112 |
(* Constr_matching.matches -> false *) |
| 113 |
Fail progress eauto with typeclass_instances. |
| 114 |
(* map_eauto -> Extern hint *) |
| 115 |
(* Constr_matching.matches -> false *) |
| 116 |
Fail typeclasses eauto. |
| 117 |
Abort. |
| 118 |
|
| 119 |
#[export] Hint Extern 0 (D (flip _)) => apply flipD : typeclass_instances. |
| 120 |
Module withftest. |
| 121 |
Local Instance: D ftest := {}. |
| 122 |
|
| 123 |
Check (_ : D _). |
| 124 |
(* D_instance_0 : D ftest *) |
| 125 |
Check (_ : D (flip _)). |
| 126 |
(* ... : D (flip ftest) *) |
| 127 |
End withftest. |
| 128 |
Module withoutftest. |
| 129 |
#[export] Hint Extern 0 (D ftest) => split : typeclass_instances. |
| 130 |
Check (_ : D _). |
| 131 |
(* ? : D ?, _not_ looping *) |
| 132 |
Check (_ : D (flip _)). |
| 133 |
(* ? : D (flip ?), _not_ looping *) |
| 134 |
|
| 135 |
Check (_ : D (flip ftest)). |
| 136 |
(* flipD ftest {| |} : D (flip ftest) *) |
| 137 |
End withoutftest. |
| 138 |
End InstPat. |