| 1 |
Require Import Setoid CMorphisms. |
| 2 |
|
| 3 |
Set Implicit Arguments. |
| 4 |
|
| 5 |
Inductive R A : A -> A -> Type := |
| 6 |
(* with A -> A -> Prop here and Morphisms on top: no failure *) |
| 7 |
(* with relation A here and Morphisms on top: no failure *) |
| 8 |
(* with crelation A here and CMorphisms on top: no failure *) |
| 9 |
| cR1 l : R l l |
| 10 |
| cR2 l : R l l. (* with only one constructor, only Fail 1 fails *) |
| 11 |
#[export] Hint Constructors R : core. |
| 12 |
|
| 13 |
#[export] Instance R_refl A : Reflexive (@R A). |
| 14 |
Proof. auto. Qed. |
| 15 |
#[export] Instance R_trans A : Transitive (@R A). |
| 16 |
Proof. intros x y z HR1 HR2; destruct HR1, HR2; auto. Qed. |
| 17 |
|
| 18 |
Goal forall (a b : nat), R a b -> R (id a) (id b). |
| 19 |
Proof. intros a b H. |
| 20 |
(** This still fails but should be fixed when #7675 is. *) |
| 21 |
Fail rewrite H; reflexivity. (* does not fail with nat inlined in the definition of R *) |
| 22 |
(* Fail 1 *) |
| 23 |
(* Tactic failure: setoid rewrite failed: ... *) |
| 24 |
Abort. |
| 25 |
|
| 26 |
Goal forall A (a b : A), R a b -> R (id a) (id b). |
| 27 |
Proof. intros A a b H. |
| 28 |
rewrite H; reflexivity. |
| 29 |
Abort. |
| 30 |
|
| 31 |
Definition GuR A (uu : unit) := match uu with unit => @R A end. |
| 32 |
|
| 33 |
#[export] Instance GuR_refl A uu : Reflexive (@GuR A uu). |
| 34 |
Proof. destruct uu; apply R_refl. Qed. |
| 35 |
#[export] Instance GuR_trans A uu : Transitive (@GuR A uu). |
| 36 |
Proof. destruct uu; apply R_trans. Qed. |
| 37 |
|
| 38 |
Goal forall uu (a b : nat), GuR uu a b -> GuR uu (id a) (id b). |
| 39 |
Proof. intros uu a b H. |
| 40 |
rewrite H; reflexivity. |
| 41 |
Abort. |
| 42 |
|
| 43 |
Goal forall A uu (a b : A), GuR uu a b -> GuR uu (id a) (id b). |
| 44 |
Proof. intros A uu a b H. |
| 45 |
rewrite H; reflexivity. |
| 46 |
Abort. |
| 47 |
|
| 48 |
Definition GbR A (bb : bool) := if bb then @R A else @R A. |
| 49 |
|
| 50 |
#[export] Instance GbR_refl A bb : Reflexive (@GbR A bb). |
| 51 |
Proof. destruct bb; apply R_refl. Qed. |
| 52 |
#[export] Instance GbR_trans A bb : Transitive (@GbR A bb). |
| 53 |
Proof. destruct bb; apply R_trans. Qed. |
| 54 |
|
| 55 |
Goal forall bb (a b : nat), GbR bb a b -> GbR bb (id a) (id b). |
| 56 |
Proof. intros bb a b H. |
| 57 |
rewrite H; reflexivity. |
| 58 |
Qed. |
| 59 |
|
| 60 |
Goal forall A bb (a b : A), GbR bb a b -> GbR bb (id a) (id b). |
| 61 |
Proof. intros A bb a b H. |
| 62 |
rewrite H; reflexivity. |
| 63 |
Qed. |