[英]Coq unable to unify -- how to change hypothesis?
Coq beginner here. Coq初学者在这里。
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:但是,当我尝试运行apply
行时,出现错误:
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?我如何将这里的plus_same
应用于advanced_commutivity
证明中的参数?
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))
.你误读了你的目标: x + y + (z + w)
代表(x + y) + (z + w)
,因为+
被注册为左结合,这与x + (y + (z + w))
。
So in order to apply your lemma, you should first reassociate your +
by rewriting with another Lemma plus_assoc : forall xyz, x + y + z = x + (y + z).
所以为了应用你的引理,你应该首先通过重写另一个Lemma plus_assoc : forall xyz, x + y + z = x + (y + z).
重新关联你的+
Lemma plus_assoc : forall xyz, x + y + z = x + (y + z).
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.