Created
May 19, 2015 00:39
-
-
Save nkaretnikov/2ed2cbdefd666b1ca0c8 to your computer and use it in GitHub Desktop.
conj_fact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** **** Exercise: 2 stars, optional (conj_fact) *) | |
(** Construct a proof object demonstrating the following proposition. *) | |
Theorem conj_fact : forall P Q R, P /\ Q -> Q /\ R -> P /\ R. | |
Proof. | |
intros P Q R HPQ HQR. | |
apply conj. | |
(* Case "left". *) | |
inversion HPQ as [HP HQ]. | |
apply HP. | |
(* Case "right". *) | |
inversion HQR as [HQ HR]. | |
apply HR. | |
Qed. | |
(* Print conj_fact. *) | |
Definition conj_fact : forall P Q R, P /\ Q -> Q /\ R -> P /\ R := | |
(* This is the output of the above [Print], which is not accepted by Coq. *) | |
fun (P Q R : Prop) (HPQ : P /\ Q) (HQR : Q /\ R) => | |
conj P R | |
((fun H : P => H) | |
match HPQ with | |
| conj HP HQ => (fun (HP0 : P) (_ : Q) => HP0) HP HQ | |
end) | |
((fun H : R => H) | |
match HQR with | |
| conj HQ HR => (fun (_ : Q) (HR0 : R) => HR0) HQ HR | |
end) | |
: forall P Q R : Prop, P /\ Q -> Q /\ R -> P /\ R. |
The solution is to parenthesize everything between :=
and : forall
.
With beta-reduction, the generated output can be simplified to
Definition conj_fact : forall P Q R, P /\ Q -> Q /\ R -> P /\ R :=
( fun (P Q R : Prop) (HPQ : P /\ Q) (HQR : Q /\ R) =>
conj P R
((fun H : P => H)
match HPQ with
| conj HP HQ => HP
end)
((fun H : R => H)
match HQR with
| conj HQ HR => HR
end)
) : forall P Q R : Prop, P /\ Q -> Q /\ R -> P /\ R.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error: