简体   繁体   English

如何证明(R-> P)[在Coq证明助手中]?

[英]How to prove (R -> P) [in the Coq proof assistant]?

How does one prove (R->P) in Coq. 如何证明Coq中的(R-> P)。 I'm a beginner at this and don't know much of this tool. 我是一个初学者,对这个工具不太了解。 This is what I wrote: 这是我写的:

Require Import Classical.

Theorem intro_neg : forall P Q : Prop,(P -> Q /\ ~Q) -> ~P.
Proof.
 intros P Q H.
 intro HP.
 apply H in HP.
 inversion HP.
 apply H1.
 assumption.
Qed.

Section Question1.
Variables P Q R: Prop.
Hypotheses H1 : R -> P \/ Q.
Hypotheses H2 : R -> ~Q.
Theorem trans : R -> P.
Proof.
 intro HR.
 apply NNPP.
 apply intro_neg with (Q := Q).
 intro HNP.

I can only get to this point. 我只能说到这一点。

The subgoals at this point are: 此时的子目标为:

1 subgoals
P : Prop
Q : Prop
R : Prop
H1 : R -> P \/ Q
H2 : R -> ~ Q
HR : R
HNP : ~ P
______________________________________(1/1)
Q /\ ~ Q

You can use tauto to prove it automatically: 您可以使用tauto来自动证明:

Section Question1.
Variables P Q R: Prop.
Hypotheses H1 : R -> P \/ Q.
Hypotheses H2 : R -> ~Q.
Theorem trans : R -> P.
Proof.
 intro HR.
 tauto.
Qed.

If you want to prove it manually, H1 says that given R, either P or Q is true. 如果要手动证明​​,则H1说给定R,则P或Q为真。 So if you destruct H1, you get 3 goals. 因此,如果破坏H1,您将获得3个目标。 One to prove the premise (R), one to prove the goal (P) using the left conclusion (P) of the or, and one to prove the goal (P) using the right conclusion (Q). 一种是证明前提(R),一种是使用or的左结论(P)证明目标(P),另一种是使用正确的结论(Q)证明目标(P)。

Theorem trans' : R -> P.
Proof.
 intro HR.
 destruct H1.
 - (* Prove the premise, R *)
   assumption.
 - (* Prove that P is true given that P is true *)
   assumption.
 - (* Prove that P is true given that Q is false *)
   contradiction H2.
Qed.
End Question1.

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

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