I'm trying to work through some foundational logic stuff, mainly from the book Using Z: Specification, Refinement, Proof but also trying to learn more about Coq. One of the first proofs in the book Using Z mentioned above is that logical-or is commutative, P \/ Q => Q \/ P
. The book uses natural deduction tree notation, so it suffices to assume P, then introduce Q or P, or else assume Q and then introduce Q or P. I have translated this to Coq with whatever you'd call the standard library like so:
Theorem disj_comm : forall P Q : Prop, P \/ Q -> Q \/ P.
Proof.
intros P Q H.
destruct H. right. apply H.
left. apply H.
Qed.
You see something similar here. Anyway, trying to translate this to SSReflect, I got kind of stuck:
Theorem disj_comm' : forall P Q : Prop, P \/ Q -> Q \/ P.
Proof.
move => P Q H.
case H.
right. (* isn't there a better approach here? *)
Abort.
I looked through the SSReflect reference I found and didn't see anything that obviously looked like it was trying to replace use of left
and right
. What's the right way to encode this proof in SSReflect?
Edit: I have the following proof now using SSreflect:
(* And here's disj_comm in ssreflect *)
Theorem disj_comm' : forall P Q : Prop, P \/ Q -> Q \/ P.
Proof.
move => P Q H.
destruct H.
right.
by [].
left.
by [].
Qed.
I feel like this is rather wordy. Is there a better way to do this with SSreflect?
apply or_introl
. But there's no reason not to useleft
/right
in such cases. – Ptivalor_introl
while attempting the proof? (Actually, in trying to apply your advice, I still got stuck, so if you have time to give a more detailed answer, I would appreciate it!) – Daniel Lyonsleft
andright
are idiomatic in SSReflect proofs,or_into(l/r)
are not. – Anton TrunovLocate "\/".
which will tell you that it stands for "Logic.or". Then you canPrint Logic.or.
which will show you the definition, including the two constructors. – Ptival