| 1 |
(** Rewrite with the commutative property to ensure that all appearences of an identifier show up the same way *) |
| 2 |
|
| 3 |
Ltac rewrite_with_comm id clem x y := |
| 4 |
first [ constr_eq x y; fail 1 |
| 5 |
| repeat match goal with |
| 6 |
| [ H' : context[id y x] |- _ ] |
| 7 |
=> rewrite clem in H' |
| 8 |
| [ |- context[id y x] ] |
| 9 |
=> rewrite clem |
| 10 |
end ]. |
| 11 |
|
| 12 |
Ltac normalize_commutative_identifier id id_comm := |
| 13 |
repeat match goal with |
| 14 |
| [ |- context[id ?x ?y] ] => progress rewrite_with_comm id (id_comm y x) x y |
| 15 |
| [ H : context[id ?x ?y] |- _ ] => progress rewrite_with_comm id (id_comm y x) x y |
| 16 |
end. |