简体   繁体   English

Coq:使用“重写”或“应用”将(negb(neqb true)简化为true?

[英]Coq: Simplify (negb (neqb true) to true using “rewrite” or “apply”?

In proofs, I want to simplify (negb (negb true)) to true (likewise with false ). 在证明中,我想将(negb (negb true))简化为true (同样使用false )。

I know of Coq's negb_involutive procedure, but since my textbook hasn't introduced it, I think that I should somehow manage to imitate its functionality using only rewrite or apply . 我知道Coq的negb_involutive过程,但是由于我的教科书没有介绍它,因此我认为我应该以某种方式设法仅使用rewriteapply来模仿其功能。

As Anton said, the typical procedure to solve this goal would be to use reflexivity , or its lower-level version apply eq_refl . 正如Anton所说,解决此目标的典型过程是使用reflexivity ,或者其较低版本apply eq_refl

Recall that Coq is based on a programming language and in this case indeed the execution of ~~ (~~ true) is easily seen to be true (where I abbreviate ~~ x = negb x ), in the same way it would return true in Python or C. 回想一下Coq是基于一种编程语言的,在这种情况下, ~~ (~~ true)的执行确实很容易被视为是true (在这里我缩写~~ x = negb x ),就像返回true在Python或C中。

apply eq_refl will solve the goal as Coq will try to "compute" or "reduce" terms when tying to make things match. apply eq_refl将解决目标,因为Coq会在试图使事物匹配时尝试“计算”或“减少”术语。 The type of eq_refl is forall x, x = x , thus when ~~ (~~ true) is reduced to true your goal now becomes true = true and it can be solved. eq_refl的类型为forall x, x = x ,因此当~~ (~~ true)减小为true您的目标现在变为true = true且可以解决。 In this case, simpl will just reduce the goal for you to see it but it is technically not needed in the proof. 在这种情况下, simpl只会降低目标的可见性,但从技术上讲,不需要证明。

It is not idiomatic to apply negb_involutive in your case, this lemma is useful when the argument to negb is a variable, like in ~~ (~~ (~~ x)) = ~~ x . 在您的情况下应用negb_involutive不是惯用的,当negb的参数是变量时,例如~~ (~~ (~~ x)) = ~~ x ,此引理很有用。

You'll find yourself using rewrite in most goals involving equality. 您会发现自己在涉及平等的大多数目标中都使用了rewrite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM