| 1 |
Set Keyed Unification. |
| 2 |
|
| 3 |
Section foo. |
| 4 |
Variable f : nat -> nat. |
| 5 |
|
| 6 |
Definition g := f. |
| 7 |
|
| 8 |
Variable lem : g 0 = 0. |
| 9 |
|
| 10 |
Goal f 0 = 0. |
| 11 |
Proof. |
| 12 |
Fail rewrite lem. |
| 13 |
Abort. |
| 14 |
|
| 15 |
Declare Equivalent Keys @g @f. |
| 16 |
(** Now f and g are considered equivalent heads for subterm selection *) |
| 17 |
Goal f 0 = 0. |
| 18 |
Proof. |
| 19 |
rewrite lem. |
| 20 |
reflexivity. |
| 21 |
Qed. |
| 22 |
|
| 23 |
Print Equivalent Keys. |
| 24 |
End foo. |
| 25 |
|
| 26 |
Require Import TestSuite.list. |
| 27 |
|
| 28 |
Definition G {A} (f : A -> A -> A) (x : A) := f x x. |
| 29 |
|
| 30 |
Lemma list_foo A (l : list A) : G (@app A) (app l nil) = G (@app A) l. |
| 31 |
Proof. unfold G; rewrite app_nil_r; reflexivity. Qed. |
| 32 |
|
| 33 |
(* Bundled version of a magma *) |
| 34 |
Structure magma := Magma { b_car :> Type; op : b_car -> b_car -> b_car }. |
| 35 |
Arguments op {_} _ _. |
| 36 |
|
| 37 |
(* Instance for lists *) |
| 38 |
Canonical Structure list_magma A := Magma (list A) (@app A). |
| 39 |
|
| 40 |
(* Basically like list_foo, but now uses the op projection instead of app for |
| 41 |
the argument of G *) |
| 42 |
Lemma test1 A (l : list A) : G op (app l nil) = G op l. |
| 43 |
|
| 44 |
(* Ensure that conversion of terms with evars is allowed once a keyed candidate unifier is found *) |
| 45 |
rewrite -> list_foo. |
| 46 |
reflexivity. |
| 47 |
Qed. |
| 48 |
|
| 49 |
(* Basically like list_foo, but now uses the op projection for everything *) |
| 50 |
Lemma test2 A (l : list A) : G op (op l nil) = G op l. |
| 51 |
Proof. |
| 52 |
rewrite ->list_foo. |
| 53 |
reflexivity. |
| 54 |
Qed. |
| 55 |
|
| 56 |
Set Keyed Unification. |
| 57 |
|
| 58 |
Lemma test b : andb b true = b. |
| 59 |
Fail rewrite andb_true_l. |
| 60 |
Admitted. |