重写适用于=但不适用于<-&燃气轮机;(iff)在Coq中
在证明过程中,我有以下内容,其中我需要用重写适用于=但不适用于<-&燃气轮机;(iff)在Coq中,coq,coq-tactic,Coq,Coq Tactic,在证明过程中,我有以下内容,其中我需要用值t替换正规形式的步骤t,因为有一个已证明的定理,即存在等价物 H1 : t1 ==>* t1' /\ normal_form step t1' t2' : tm H2 : t2 ==>* t2' /\ normal_form step t2' ______________________________________(1/1) exists t' : tm, P t1 t2 ==>* t' /\ normal_form step t'
值t
替换正规形式的步骤t
,因为有一个已证明的定理,即存在等价物
H1 : t1 ==>* t1' /\ normal_form step t1'
t2' : tm
H2 : t2 ==>* t2' /\ normal_form step t2'
______________________________________(1/1)
exists t' : tm, P t1 t2 ==>* t' /\ normal_form step t'
等价定理是:
Theorem nf_same_as_value
: forall t : tm, normal_form step t <-> value t
对假设有效,但将nf\u重写为与值相同的值。
对目标给出:
Error:
Found no subterm matching "normal_form step ?4345" in the current goal.
在这里,对目标进行重写在理论上是不可能的,还是一个实现问题
--编辑--
我在这里的困惑是,如果我们定义normal\u form step=value
,重写就会起作用。如果我们为所有t定义,正常形式的步骤t值t
,那么重写
在正常形式的步骤
未在存在句中引用时有效,但在存在句中无效
改编@Matt的例子
Require Export Coq.Setoids.Setoid.
Inductive R1 : Prop -> Prop -> Prop :=
|T1_refl : forall P, R1 P P.
Inductive R2 : Prop -> Prop -> Prop :=
|T2_refl : forall P, R2 P P.
Theorem Requal : R1 = R2.
Admitted.
Theorem Requiv : forall x y, R1 x y <-> R2 x y.
Admitted.
Theorem test0 : forall y, R2 y y -> exists x, R1 x x.
Proof.
intros. rewrite <- Requal in H. (*works*) rewrite Requal. (*works as well*)
Theorem test2 : forall y, R2 y y -> exists x, R1 x x.
Proof.
intros. rewrite <- Requiv in H. (*works*) rewrite Requiv. (*fails*)
此故障是否与功能扩展性有关
错误消息尤其令人困惑:
Error:
Found no subterm matching "R1 ?P ?P0" in the current goal.
正好有一个子项与R1匹配,即R1 x x
此外,根据@larsr,如果使用eexists
,则重写工作正常
Theorem test1 : forall y, R2 y y -> exists x, R1 x x.
Proof.
intros. eexists. rewrite Requiv. (*works as well*) apply H. Qed.
eexists
在这里添加了什么?重写不能放在存在量词下。在重写之前,您需要先实例化t'
。注意,econstuctor
在这种情况下可能是一种有用的策略,它可以用统一变量替换存在量词
根据OP的评论进行编辑
这仍然不利于平等。例如,请尝试:
Inductive R1 : Prop -> Prop -> Prop :=
|T1_refl : forall P, R1 P P.
Inductive R2 : Prop -> Prop -> Prop :=
|T2_refl : forall P, R2 P P.
Theorem Req : forall x y, R1 x y = R2 x y.
Admitted.
Theorem test : forall y, R2 y y -> exists x, R1 x x.
Proof.
intros. rewrite Req. (*rewrite still fails*)
这个问题实际上不是关于equality vs.iff,而是关于绑定下的重写(在本例中是lambda)。对于
存在x:A,P
实际上只是exa(funx=>px)
的语法,因此重写失败不是因为iff,而是因为重写策略不想在(funx=>px)
中绑定x
。似乎有一种方法可以做到这一点,但是,我没有这方面的经验。谢谢。但我的部分问题是,我不明白为什么重写不应该进入存在量词。我想如果它是一个等式而不是iff,rewrite
会在这里工作,不是吗?@tinlyx我添加了一个编辑,可能会把事情弄清楚。@马特,谢谢,我用你的例子添加了一个更新。需要导入Coq.Setoids.Setoid。
然后Setoid\u rewrite requirev。
应该在存在量词下工作。
Theorem test1 : forall y, R2 y y -> exists x, R1 x x.
Proof.
intros. eexists. rewrite Requiv. (*works as well*) apply H. Qed.
Inductive R1 : Prop -> Prop -> Prop :=
|T1_refl : forall P, R1 P P.
Inductive R2 : Prop -> Prop -> Prop :=
|T2_refl : forall P, R2 P P.
Theorem Req : forall x y, R1 x y = R2 x y.
Admitted.
Theorem test : forall y, R2 y y -> exists x, R1 x x.
Proof.
intros. rewrite Req. (*rewrite still fails*)