I am trying to prove the below case for a homework assignment and have been working hours on it, still no luck.
Any suggestions or comments as to what I am doing wrong?
I am trying to prove the below case for a homework assignment and have been working hours on it, still no luck.
Any suggestions or comments as to what I am doing wrong?
On
We have a Coq proof thanks to @Aadit, and it would only be fair ---ethical?--- to present an Agda proof.
An immediate and simple proof is
open import Data.Product
portation : {P Q R : Set} → (P × Q → R) → (P → Q → R)
portation P×Q→R = λ p q → P×Q→R (p , q)
Of course this may not at all be clear if the asker is not familiar with Agda and is seeking a formalisation. So let's throw in some detail!!
In constructive logic, propositions can be seen as the small types:
ℙrop = Set
Then pairing is the usual way to form conjugation,
data _∧_ (P Q : ℙrop) : Set where
∧I : P → Q → P ∧ Q
In constructive logic, implication is just function space: to say one thing implies another is tantamount to yielding a procedure that with input of the first kind returns output of the second kind.
_⇒_ : (P Q : ℙrop) → Set
_⇒_ = λ P Q → (P → Q)
Implication introduction is then just usual function-definition, and implication elimination is then nothing more than function application.
⇒I : ∀ {P Q} → (P → Q) → P ⇒ Q
⇒I P→Q = P→Q
⇒E : ∀ {P Q} → P ⇒ Q → P → Q
⇒E P→Q p = P→Q p
Now the asker is using natural-deduction style of proofs, so let us introduce some syntactic sugar to bridge the gap from the paper-and-pencil proof to the Agda formalisation.
syntax ⇒I {P} {Q} (λ p → q) = ⇒-I-assuming-proof p of P we-have Q proved-by q
Now the proof!
shunting : (P Q R : ℙrop) → (P ∧ Q) ⇒ R → P ⇒ (Q ⇒ R)
shunting P Q R P∧Q⇒R =
⇒-I-assuming-proof p of P
we-have Q ⇒ R proved-by
⇒-I-assuming-proof q of Q
we-have R proved-by
⇒E P∧Q⇒R (∧I p q)
Which is not only quite readable, but also somewhat close to the asker's presentation!
Agda is such a joy!
On
This is a proof using Klement's Fitch-style natural deduction proof checker and the forallx textbook providing explanation. (The links are below.)
The main problem with the original attempt is that lines 8 and 9 did not discharge the assumptions. They appeared to stay in the same subproofs based on the indents and braces.
Otherwise the proof is the same as what I provided. On my line 6 I discharged the assumption I made of "Q" on line 3 by introducing the conditional (lines 3-5). On my line 7 I discharged the assumption "P" made on line 2 by introducing the conditional (lines 2-6).
Reference
Kevin Klement's JavaScript/PHP Fitch-style natural deduction proof editor and checker http://proofs.openlogicproject.org/
P. D. Magnus, Tim Button with additions by J. Robert Loftis remixed and revised by Aaron Thomas-Bolduc, Richard Zach, forallx Calgary Remix: An Introduction to Formal Logic, Winter 2018. http://forallx.openlogicproject.org/
This is how you'd prove it in Coq:
First, we name all the premises:
The only premise that produces the subgoal
risf:To apply
fwe first need to satisfy the subgoalsqandp:The premise
yis a proof for subgoalq:The premise
xis a proof of subgoalp:We're done. Here's the full proof:
In function programming languages like Haskell you'd have:
Everything works out due to the Curry-Howard correspondence.