简体   繁体   English

Coq:评估/简化 `Prop` 重言式

[英]Coq: evaluating/simplifying `Prop` tautologies

I'm proving some basic facts about ultrafilters in Coq, and many of my proofs eventually get to the stage where I have to prove a goal such as我在 Coq 中证明了一些关于超滤器的基本事实,我的许多证明最终都到了我必须证明一个目标的阶段,例如

(False -> False) = True

or或者

False /\ P = False

or或者

True

or some other trivial tautology.或其他一些琐碎的重言式。 Neither simpl nor auto seem to do anything, so how can I solve these Prop goals? simplauto似乎都没有做任何事情,那么我该如何解决这些Prop目标呢?

I am not sure how you encoded your ultrafilters, but your first two goals are not provable.我不确定您是如何对超滤器进行编码的,但您的前两个目标无法证明。 Indeed, they assert equalities between different types , which there is no way to prove in vanilla Coq.事实上,他们断言不同类型之间的相等性,这在 vanilla Coq 中无法证明。 There are multiple different ways to go around the problem, however.然而,有多种不同的方法可以解决这个问题。

The easiest (and in my opinion best) solution is to replace equality of propositions with logical equivalence in all your definitions.最简单(并且在我看来最好的)解决方案是在所有定义中用逻辑等价替换命题的相等性。 In your first case for instance, you would obtain (False -> False) <-> True which is indeed a tautology.例如,在您的第一种情况下,您将获得(False -> False) <-> True这确实是一个重言式。

Alternatively, you can replace propositions by booleans altogether, ie use bool instead of Prop in the definition ultrafilter, and rely on boolean connectives instead of propositional ones.或者,您可以完全用布尔值替换命题,即在定义超滤器中使用bool代替Prop ,并依赖 boolean 连接词而不是命题连接词。 Your second case would become something like false && P = false , which is again provable, because your are dealing with equality between elements of an inductive type rather than between propositions.您的第二种情况会变成类似false && P = false的东西,这又是可证明的,因为您正在处理归纳类型的元素之间的相等性,而不是命题之间的相等性。 But this change is quite heavier than the previous one as it would imply much more changes to your development to reason with booleans rather than propositions.但是这种变化比以前的变化要重得多,因为它意味着对你的开发进行更多的更改,以使用布尔而不是命题进行推理。 If you go this path, you might want to look at MathComp, which plays a lot with booleans in this kind of settings.如果你是 go 这个路径,你可能想看看 MathComp,它在这种设置中与布尔值有很大关系。

The last possibility is a bit more tricky, it relies on the so-called propositional extensionality axiom, which states that two propositions are equal whenever they are equivalent.最后一种可能性有点棘手,它依赖于所谓的命题外延公理,即只要两个命题等价,它们就等价。 In Coq, it corresponds to在 Coq 中,它对应于

prop_ext : forall P Q : Prop, (P <-> Q) -> P = Q.

Using this axiom you can reduce your various equality goals to equivalences, which are true as mentioned in the first solution.使用这个公理,您可以将各种平等目标简化为等价,正如第一个解决方案中提到的那样。 A similar axiom appears in the context of Homotopy Type Theory (HoTT), as a consequence of the univalence axiom that is central there, although the notion of proposition in Coq and in HoTT are somewhat different.一个类似的公理出现在同伦类型理论 (HoTT) 的上下文中,这是作为中心的单价公理的结果,尽管 Coq 和 HoTT 中的命题概念有些不同。 If you are curious about the difference between equality and equivalence you might want to check it up, which is why I mention it, but I would recommand going for the first solution instead, as it avoids having to rely on an unneeded axiom.如果您对相等和等价之间的区别感到好奇,您可能想检查一下,这就是我提到它的原因,但我建议您改用第一个解决方案,因为它避免了依赖不需要的公理。

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

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