Reputation: 22530
I have some equalities (=
) and unequalities (<>
) in the hypotheses such as:
e : x2 = x1
n : x3 <> x1
I want to use tactics like assumption
, but sometimes the expected (un)equality in the goal is in the other direction like:
x1 = x2
x1 <> x3
My question is:
Is it possible to automatically introduce the symmetric forms of (un)equality above into the hypotheses?
If not, is it possible to use Notation to write a tactical to do this.
So far, I can do this manually like this:
assert (x1 = x2) by (symmetry in e; assumption).
assert (x1 <> x3) by (unfold not; intro Hnot;
symmetry in Hnot; unfold not in n; apply n in Hnot; inversion Hnot).
But it is really tedious and noisy. I don't know enough about how to automate this or if there is a better way.
Upvotes: 0
Views: 178
Reputation: 5811
Perhaps this tactic can help:
Ltac maybe_intro_sym A B :=
match goal with
|[H:B=A|-_] => fail 1
|[H:A=B|-_] => assert (B=A) by auto
end.
Ltac maybe_intro_sym_neg A B :=
match goal with
|[H:B<>A|-_] => fail 1
|[H:A<>B|-_] => assert (B<>A) by auto
end.
Ltac intro_sym :=
repeat match goal with
|[H:?A=?B|-_] => maybe_intro_sym A B
|[H:?A<>?B|-_] => maybe_intro_sym_neg A B
end.
Here's an example:
Parameters a b c d:nat.
Goal a=b -> c=d -> c<>d -> True.
intros.
intro_sym.
Now the context is
H : a = b
H0 : c = d
H1 : c <> d
H2 : d = c
H3 : b = a
H4 : d <> c
============================
True
Upvotes: 1