简体   繁体   English

在 Coq 中如何证明或证伪 `forall (PQ : Prop), (P -> Q) -> (Q -> P) -> P = Q.`?

[英]How or is that possible to prove or falsify `forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q.` in Coq?

I want to prove or falsify forall (PQ : Prop), (P -> Q) -> (Q -> P) -> P = Q. in Coq.我想证明或证伪forall (PQ : Prop), (P -> Q) -> (Q -> P) -> P = Q. in Coq。 Here is my approach.这是我的方法。

Inductive True2 : Prop :=
 | One : True2
 | Two : True2.

Lemma True_has_one : forall (t0 t1 : True), t0 = t1.
Proof.
  intros.
  destruct t0. destruct t1.
  reflexivity.
Qed.

Lemma not_True2_has_one : (forall (t0 t1 : True2), t0 = t1) -> False.
Proof.
  intros.
  specialize (H One Two).
  inversion H.

But, inversion H does nothing.但是, inversion H没有任何作用。 I think maybe it's because the coq's proof independence (I'm not a native English speaker, and I don't know the exact words, please forgive my ignorance), and coq makes it impossible to prove One = Two -> False.我想可能是因为coq的证明独立性(我不是英语母语者,我不知道确切的单词,请原谅我的无知),而coq使得无法证明One = Two -> False。 But if so why has to coq eliminate the content of a proof?但如果是这样,为什么必须用 coq 消除证明的内容?

Without the above proposition, I can't prove the followings or their negations.没有上述命题,我无法证明以下或它们的否定。

Lemma True_neq_True2 : True = True2 -> False.

Theorem iff_eq : forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q.

So my question is:所以我的问题是:

  1. How to or is that possible to prove or falsify forall (PQ : Prop), (P -> Q) -> (Q -> P) -> P = Q. in Coq?在 Coq 中,如何或是否可以证明或证伪forall (PQ : Prop), (P -> Q) -> (Q -> P) -> P = Q.
  2. Why inversion H does nothing;为什么inversion H什么都不做; does it's because the coq's proof independence, and if so, why does Coq waste energy in doing this.是不是因为 coq 的证明独立性,如果是这样,为什么 Coq 这样做会浪费精力。
  1. The principle you're mentioning, forall PQ : Prop, (P <-> Q) -> P = Q , is usually known as propositional extensionality .你提到的原则,对于所有forall PQ : Prop, (P <-> Q) -> P = Q ,通常被称为命题外延性 This principle is not provable in Coq's logic, and originally the logic had been designed so that it could be added as an axiom with no harm.这个原理在 Coq 的逻辑中是无法证明的,最初这个逻辑被设计成可以作为公理添加而不会造成伤害。 Thus, in the standard library ( Coq.Logic.ClassicalFacts ), one can find many theorems about this principle, relating it to other well-known logical principles of classical reasoning.因此,在标准库 ( Coq.Logic.ClassicalFacts ) 中,可以找到许多关于这一原则的定理,并将其与其他著名的经典推理逻辑原则联系起来。 Surprisingly, it wasrecently found out that Coq's logic is incompatible with this principle, but for a very subtle reason.令人惊讶的是,最近发现 Coq 的逻辑与此原则不兼容,但原因很微妙。 This is considered a bug, since the logic had been designed so that this could be added as an axiom with no harm.这被认为是一个错误,因为逻辑已经设计为可以将其添加为公理而不会造成伤害。 They wanted to fix this problem in the new version of Coq, but I don't know what the current status of that is.他们想在新版本的 Coq 中解决这个问题,但我不知道它的当前状态是什么。 As of version 8.4, propositional extensionality is inconsistent in Coq.从 8.4 版本开始,Coq 中的命题扩展性是不一致的。

    In any case, if this bug is fixed in future versions of Coq, it should not be possible to prove nor disprove this principle in Coq.无论如何,如果这个错误在 Coq 的未来版本中被修复,那么在 Coq 中应该不可能证明或反驳这个原则。 In other words, the Coq team wants this principle to be independent of Coq's logic.换句话说,Coq 团队希望这个原则独立于 Coq 的逻辑。

  2. inversion H doesn't do anything there because the rules for reasoning about proofs (things whose type is a Prop ) are different from the ones for reasoning about non-proofs (things whose type is a Type ). inversion H在那里没有做任何事情,因为推理证明(类型为Prop事物)的规则与推理非证明(类型为Type事物)的规则不同。 You may know that proofs in Coq are just terms.你可能知道 Coq 中的证明只是术语。 Under the hood, inversion is essentially constructing the following term:在幕后, inversion本质上是构建以下术语:

     Definition true_not_false : true <> false := fun H => match H in _ = b return if b then True else False with | eq_refl => I end.

    If you try to do the same with a version of bool in Prop , you get a more informative error:如果您尝试对Propbool版本执行相同操作,则会收到一个信息量更大的错误:

     Inductive Pbool : Prop := | Ptrue : Pbool | Pfalse : Pbool. Fail Definition Ptrue_not_Pfalse : Ptrue <> Pfalse := fun H => match H in _ = b return if b then True else False with | eq_refl => I end. (* The command has indeed failed with message: *) (* => Error: *) (* Incorrect elimination of "b" in the inductive type "Pbool": *) (* the return type has sort "Type" while it should be "Prop". *) (* Elimination of an inductive object of sort Prop *) (* is not allowed on a predicate in sort Type *) (* because proofs can be eliminated only to build proofs. *)

    Indeed, one of the reasons for this is that Coq was designed to be compatible with another principle called proof irrelevance (I think that's what you meant by "proof independence").事实上,其中一个原因是 Coq 被设计为与另一个称为证明无关性的原则兼容(我认为这就是你所说的“证明独立性”)。

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

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