Reputation: 945
Coq beginner here.
I have the following silly theorems:
Theorem plus_same : forall a b c : nat,
a+b=a+c -> b=c.
Proof. Admitted.
Theorem advanced_commutivity:
forall x y z w : nat, x + y + (z+w) = x + z + (y + w).
Proof.
intros x y z w.
apply (plus_same x (y + (z+w)) (z + (y + w))).
However, when I try to run the apply
line, I get an error:
Unable to unify "y + (z + w) = z + (y + w)" with
"x + y + (z + w) = x + z + (y + w)".
Do I need to change my hypothesis here? How can I apply plus_same
here to the arguments in advanced_commutivity
proof?
Upvotes: 1
Views: 774
Reputation: 1217
You are misreading your goal: x + y + (z + w)
stands for (x + y) + (z + w)
, because +
is registered as left-associative, which is different from x + (y + (z + w))
.
So in order to apply your lemma, you should first reassociate your +
by rewriting with another Lemma plus_assoc : forall x y z, x + y + z = x + (y + z).
Upvotes: 2