[英]Why can't Coq unify goal and hypothesis?
After some work on an exercise, I've reached the following proof state:经过一些练习,我得到了以下证明 state:
(tail1 is a nat list pattern generator, lng
is generalized) (tail1 是一个 nat 列表模式生成器,
lng
是泛化的)
1 subgoal
n' : nat
IH_n' : forall lng : nat, lng > n' -> nth n' (update (tail1 lng) 0 1) 9 = 1
lng : nat
H : S lng > S n'
______________________________________(1/1)
nth (S n') (update (tail1 (S lng)) 0 1) 9 = 1
Using apply IH_n'
fails with the following error:使用
apply IH_n'
失败并出现以下错误:
Unable to unify "nth n' (update (tail1?M1305) 0 1) 9 = 1" with "nth (S n') (update (tail1 (S lng)) 0 1) 9 = 1".
无法将“nth n' (update (tail1?M1305) 0 1) 9 = 1”与“nth (S n') (update (tail1 (S lng)) 0 1) 9 = 1”统一起来。
?M1305 - (S lng)
pair that can't be unified??M1305 - (S lng)
不能统一的对吗??M1305
exactly??M1305
? The problem here is that you are trying to apply an hypothesis on n'
for S n'
, whereas n' is not quantified in IH_n'.这里的问题是您试图在
n'
上对S n'
应用假设,而 n' 在 IH_n' 中没有量化。
It would only work if your hypothesis was:只有当你的假设是:
IH_n' : forall n' lng : nat, lng > n' -> nth n' (update (tail1 lng) 0 1) 9 = 1
To answer your other question, ?_
is the existential variable which would be replaced if your hypothesis was applicable, because the variable lng is quantified in the hypothesis.要回答您的另一个问题,
?_
是存在变量,如果您的假设适用,它将被替换,因为变量 lng 在假设中被量化。
If you want some help on how to prove this goal, could you share the code please?如果您需要有关如何证明此目标的帮助,请分享代码吗? (even though I think you should do
unfold nth, update; simpl
to see if you can apply your hypothesis somewhere. (即使我认为你应该
unfold nth, update; simpl
看看你是否可以在某个地方应用你的假设。
Hypothesis IH_n'
is universally quantified by lng:nat
.假设
IH_n'
被lng:nat
普遍量化。 To apply it to the goal, Coq needs to instantiate it.要将其应用于目标,Coq 需要实例化它。
?M1305
is the name it gives to the value of lng
it has yet to find. ?M1305
是它为尚未找到的lng
值赋予的名称。
The error message does not necessarily mean that ?M1305
and (S lng)
cannot be unified.错误信息不一定表示
?M1305
和(S lng)
不能统一。 The issue might come from elsewhere.这个问题可能来自其他地方。 For example, your goal starts with
nth (S n')
, while the hypothesis starts with nth n'
.例如,您的目标以
nth (S n')
开始,而假设以nth n'
开始。 Obviously, (S n')
and n'
cannot be unified.显然,
(S n')
和n'
不能统一。
Your first step, assuming the goal is provable, is to make sure it starts with nth n'
.假设目标是可证明的,您的第一步是确保它以
nth n'
开头。 To do so, you need the second argument of nth
to be of the form (cons foo bar)
.为此,您需要
nth
的第二个参数为(cons foo bar)
形式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.