簡體   English   中英

Coq:在沒有 `contradiction` 策略的情況下證明 `P -> ~P -> Q`?

[英]Coq: proving `P -> ~P -> Q` without `contradiction` tactic?

我正在學習 Coq,我剛剛發現它是有建設性的。

這是我可以證明“矛盾意味着一切”並且它有效的一種方式:

Theorem contradiction_implies_anything: forall P Q : Prop, P -> ~P -> Q.
Proof.
  intros P Q p not_p.
  contradiction.
  Qed.

請注意,沒有構造Q ,因此我假設 Coq 證明引擎中內置了contradiction 在我看來,否則必須證明Q是如何構造的,而任何Q都不可能,因此無法證明上述定理。 特別是我無法在以下(偽)代碼中證明上述定理:

intros P Q p not_p.
introduce P \/ Q. # here I have to construct Q, right?.. that's the point where Coq's "constructivity" becomes an obstruction
introduce ~P \/ Q. # same here
run case analysis on both and figure out that Q must be true.
Qed.

我對嗎?

這里實際上並不需要contradiction ,主要有兩個原因:

  1. ~ PP -> False的標准庫符號,這意味着如果你有假設P~ P ,你可以應用~ PP得到False

  2. 標准庫像這樣定義FalseInductive False : Prop :=. 這意味着,如果您destruct類型為False的假設,則生成的案例分析將有零個案例。 也就是說,你的證明就完成了!

所以,總而言之,你可以像這樣證明你的定理:

Theorem contradiction_implies_anything: forall P Q : Prop, P -> ~P -> Q.
Proof.
  intros P Q p not_p.
  apply not_p in p.
  destruct p.
Qed.

在 Coq 中,否定定義如下:

Inductive False : Prop := 
  (* An inductive proposition with no constructors *). 
Definition not (P : Prop) : Prop := P -> False.

您證明的引理是以下更原始原則的結果:

Lemma exfalso (Q : Prop) : False -> Q.
Proof. intros contra. destruct contra. Qed.

直觀地說,如果我們知道一個歸納命題P成立,並且我們想證明其他一些Q成立,我們需要做的就是考慮所有可以應用來建立P的構造函數。 這就是destruct策略的作用。 但是當PFalse ,沒有構造函數,所以我們不必做任何事情。

我喜歡對這種情況的看法如下:這個過程並不是構造了Q的證明,而是我們在那里展示了我們不需要構造任何東西。

鑒於exfalso ,很容易用更原始的術語證明你的原始陳述(我建議你通過這個證明來看看發生了什么!):

Goal forall P Q : Prop, P -> ~P -> Q.
Proof.
intros P Q Hyes Hno.
apply exfalso. apply Hno. apply Hyes.
Qed.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM