| 1 |
From Coq Require Import Setoid. |
| 2 |
Require Import Crypto.Util.FixCoqMistakes. |
| 3 |
Require Import Crypto.Util.Tactics.DestructHead. |
| 4 |
|
| 5 |
Local Ltac t := |
| 6 |
repeat first [ progress destruct_head'_ex |
| 7 |
| progress destruct_head'_and |
| 8 |
| progress intros |
| 9 |
| progress subst |
| 10 |
| assumption |
| 11 |
| progress repeat esplit ]. |
| 12 |
|
| 13 |
Lemma ex_and_eq_l_iff {A P x} |
| 14 |
: (exists y : A, y = x /\ P y) <-> P x. |
| 15 |
Proof. t. Qed. |
| 16 |
|
| 17 |
Lemma ex_and_eq_r_iff {A P x} |
| 18 |
: (exists y : A, x = y /\ P y) <-> P x. |
| 19 |
Proof. t. Qed. |
| 20 |
|
| 21 |
Lemma ex_eq_and_l_iff {A P x} |
| 22 |
: (exists y : A, P y /\ y = x) <-> P x. |
| 23 |
Proof. t. Qed. |
| 24 |
|
| 25 |
Lemma ex_eq_and_r_iff {A P x} |
| 26 |
: (exists y : A, P y /\ x = y) <-> P x. |
| 27 |
Proof. t. Qed. |
| 28 |
|
| 29 |
Ltac ex_eq_and_step := |
| 30 |
let rew lem := (rewrite lem || setoid_rewrite lem) in |
| 31 |
let rew_in lem H := (rewrite lem in H || setoid_rewrite lem in H) in |
| 32 |
match goal with |
| 33 |
| [ |- context[exists y, _ = y /\ _] ] |
| 34 |
=> rew (@ex_and_eq_r_iff) |
| 35 |
| [ |- context[exists y, y = _ /\ _] ] |
| 36 |
=> rew (@ex_and_eq_l_iff) |
| 37 |
| [ |- context[exists y, _ /\ _ = y] ] |
| 38 |
=> rew (@ex_eq_and_r_iff) |
| 39 |
| [ |- context[exists y, _ /\ y = _] ] |
| 40 |
=> rew (@ex_eq_and_l_iff) |
| 41 |
| [ H : context[exists y, _ = y /\ _] |- _ ] |
| 42 |
=> rew_in (@ex_and_eq_r_iff) H |
| 43 |
| [ H : context[exists y, y = _ /\ _] |- _ ] |
| 44 |
=> rew_in (@ex_and_eq_l_iff) H |
| 45 |
| [ H : context[exists y, _ /\ _ = y] |- _ ] |
| 46 |
=> rew_in (@ex_eq_and_r_iff) H |
| 47 |
| [ H : context[exists y, _ /\ y = _] |- _ ] |
| 48 |
=> rew_in (@ex_eq_and_l_iff) H |
| 49 |
end. |
| 50 |
|
| 51 |
Ltac ex_eq_and := repeat ex_eq_and_step. |