I think by this point I've read most if not all of the 81 questions tagged coq. Being very new to coq, I was unable to find an answer to this very simple question (which I'm fairly certain has not been asked on SO because of how basic it is).
I am working on a homework assignment, for which I need to use coq to prove:
- Given: P/Q. ~Q
- Prove: P
This is a simple enough proof for me to do on paper, but I can't seem to get coq to do this for me.
My strategy is to assume each of P
and Q
, to show P
and therefore conclude that P
must hold:
- P / Q [Premise]
~Q [Premise]
- P [Assumption]
P [Copy Previous Line]
Q [Assumption]
- ~Q [Copy Previous Line]
- [Contradiction]
- P [Contradiction Elimination]
- P [Elimination of
\/
]
Given that this is how I would prove it on paper, I was able to come up with the following coq code to prove it in coq. Sadly my effort to assume P
, Q
, or ~P
don't come through:
Section Q5.
Variables P Q : Prop.
Hypothesis premise1 : P \/ Q.
Hypothesis premise2 : ~Q.
Goal P.
Here are my attempts for the next line, along with the errors they produce:
+-----------------+---------------------------------------------------------------------+
| Code | Error |
+-----------------+---------------------------------------------------------------------+
| assumption. | Error: No such assumption. |
| exact P. | The term "P" has type "Prop" while it is expected to have type "P". |
| apply premise1. | Error: Impossible to unify "P \/ Q" with "P". |
| apply P. | Error: Impossible to unify "Prop" with "P". |
+-----------------+---------------------------------------------------------------------+
I'd appreciate any help with this since I've exhausted everything that I can think of at this point.