140 likes | 262 Views
CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus. Manipulating Logical Expressions. 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
E N D
CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus
Manipulating Logical Expressions 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
Manipulating Logical Expressions 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
Manipulating Logical Expressions 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
Implication 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
Implication Can use implication to prove equivalence of programming constructs • If (A and B) Then C A ^ B -> C • If (A or B) Then C A v B -> C • If A Then { If B Then C} A -> (B -> C)
Implication Properties • 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
Manipulating Logical Expressions 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
Manipulating Logical Expressions 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 R Associative .....
Manipulating Logical Expressions ..... = ((P ^ ¬Q) v ¬P) v R Associative = (¬P v (P ^ ¬Q)) v R Commutative = ((¬P v P) ^ (¬P v ¬Q)) v R Distribution = (T ^ (¬P v ¬Q)) v R Complement = (¬P v ¬Q) v R Identity = ¬P v (¬Q v R) Associative = P -> (¬Q v R) Definition = P -> (Q -> R) Definition
Equivalence 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)
Equivalence Properties • 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
Equivalence Alternative Definition 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)
Equivalence Alternative Definition 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