14
CT214 – Logical Foundations of Computing CT214 – Logical Foundations of Computing Lecture 2 Lecture 2 Propositional Calculus Propositional Calculus

CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

CT214 – Logical Foundations of ComputingCT214 – Logical Foundations of Computing

Lecture 2Lecture 2

Propositional CalculusPropositional Calculus

Page 2: CT214 – Logical Foundations of Computing Lecture 2 Propositional 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

Page 3: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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

Page 4: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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

Page 5: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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

Page 6: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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)

Page 7: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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

Page 8: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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

Page 9: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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 .....

Page 10: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

.....

= ((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

Page 11: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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)

Page 12: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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

Page 13: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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)

Page 14: CT214 – Logical Foundations of Computing Lecture 2 Propositional Calculus

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