CT214 – Logical Foundations of ComputingCT214 – Logical Foundations of Computing
Lecture 2Lecture 2
Propositional CalculusPropositional Calculus
Prove: P ^ ¬(P ^ Q) = P ^ ¬Q
Answer: P ^ ¬(P ^ Q)
= P ^ (¬P v ¬Q) De Morgan Law 1
= (P ^ ¬P) v (P ^ ¬Q)Distribution
= F v (P ^ ¬Q) Complement
= P ^ ¬Q Identity
Prove: P ^ ((P ^ Q) v ¬P) = P ^ Q
Answer: P ^ ((P ^ Q) v ¬P)
= (P ^ (P ^ Q)) v (P ^ ¬P)Distribution
= (P ^ (P ^ Q)) v F Complement
= P ^ (P ^ Q)Identity
= (P ^ P) ^ Q Associative
= P ^ Q Idempotent
Prove: (P ^ (Q v R)) ^ ¬Q = (P ^ ¬Q) ^ R
Answer: (P ^ (Q v R)) ^ ¬Q
= P ^ ((Q v R)) ^ ¬Q) Associative
= P ^ (¬Q ^ (Q v R)) Commutative
= P ^ ((¬Q ^ Q) v (¬Q ^ R)) Distribution
= P ^ (F v (¬Q ^ R)) Complement
= P ^ (¬Q ^ R) Identity
= (P ^ ¬Q) ^ R Associative
A -> B means if A is true then B is also true
i.e. A implies B
Converse of A -> B is B -> A
Contrapositive of A -> B is ¬A -> ¬B
Can use implication to prove equivalence of programming constructs
1. If (A and B) Then C A ^ B -> C
2. If (A or B) Then C A v B -> C
3. If A Then { If B Then C} A -> (B -> C)
Definition A -> B = ¬A v B
Reflexive A -> A = T
Right Absorber of T A -> T = T
Left Identity of T T -> A = A
Contrapositive A -> B = ¬A -> ¬B
Note that:
-> is not commutative, associative or idempotent
Prove: (P ^ Q) -> R = P -> (Q -> R)
Answer: RHS P -> (Q -> R)
= ¬P v (Q -> R) Definition
= ¬P v (¬Q v R) Definition
= (¬P v ¬Q) v R Associative
= ¬(P ^ Q) v R De Morgan Law 1
= (P ^ Q) -> R Definition
Prove: P -> (Q -> R) = (P -> Q) -> (P -> R)
Answer: RHS (P -> Q) -> (P -> R)
= (¬P v Q) -> (¬P v R) Definition
= ¬(¬P v Q) v (¬P v R) Definition
= (¬¬P ^ ¬Q) v (¬P v R) De Morgan Law 2
= (P ^ ¬Q) v (¬P v R) Double Negative
= ((P ^ ¬Q) v ¬P) v RAssociative .....
.....
= ((P ^ ¬Q) v ¬P) v R Associative
= (¬P v (P ^ ¬Q)) v RCommutative
= ((¬P v P) ^ (¬P v ¬Q)) v R Distribution
= (T ^ (¬P v ¬Q)) v RComplement
= (¬P v ¬Q) v R Identity
= ¬P v (¬Q v R) Associative
= P -> (¬Q v R) Definition
= P -> (Q -> R) Definition
A B means that A is equivalent to B
Define A B to mean (A ^ B) v (¬A ^ ¬B)
A B means that A is not equivalent to B
Define A B to mean (A ^ ¬B) v (¬A ^ B)
Definition A B = (A ^ B) v (¬A ^ ¬B)
Reflexive A A = T
Associative (A B) C = A (B C)
Commutative A B = B A
Identity A T = A
Complement A ¬A = F
Distribution ¬(A B) = A B
¬(A B) = A B
Prove alternative definition of P Q:
(P -> Q) ^ (Q -> P)
Definition of P Q = (P ^ Q) v (¬P ^ ¬Q)
Answer is to start with
(P -> Q) ^ (Q -> P) and get to (P ^ Q) v (¬P ^ ¬Q)
Answer: Show (P -> Q) ^ (Q -> P) = (P ^ Q) v (¬P ^ ¬Q)
(¬P v Q) ^ (¬Q v P) Definition
((¬P v Q) ^ ¬Q) v ((¬P v Q) ^ P) Distribution
(¬Q ^ (¬P v Q)) v (P ^ (¬P v Q)) Commutative
((¬Q ^ ¬P) v (¬Q ^ Q)) v ((P ^ ¬P) v (P ^ Q))Distribution
((¬Q ^ ¬P) v F) v (F v (P ^ Q)) Complement
(¬Q ^ ¬P) v (P ^ Q) Identity
(P ^ Q) v (¬P ^ ¬Q) Commutative