简体   繁体   中英

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

How does one prove (R->P) in Coq. 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:

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. So if you destruct H1, you get 3 goals. 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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