ct214 – logical foundations of computing lecture 9 revision

26
CT214 – Logical Foundations of Computing CT214 – Logical Foundations of Computing Lecture 9 Lecture 9 Revision Revision

Upload: justin-lindsey

Post on 04-Jan-2016

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CT214 – Logical Foundations of Computing Lecture 9 Revision

CT214 – Logical Foundations of ComputingCT214 – Logical Foundations of Computing

Lecture 9Lecture 9

RevisionRevision

Page 2: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (i) Consider a generic operator on some set S. Explain what is meant by saying

a. has a right identity element AR

b. is commutative

c. is idempotent

Prove that if all three properties hold, then

( ( a AR ) a ) b = b a a, b S

Page 3: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (i) Consider a generic operator on some set S. Explain what is meant by saying

a. has a right identity element AR

Answer:

A right identity element AR means that if any premise is connected with the element AR

using the generic operator then that premise can be concluded.

i.e. a AR = a

Page 4: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (i) Consider a generic operator on some set S. Explain what is meant by saying

b. is commutative

Answer:

The generic operator is commutative means that all premises connected using the generic operator are interchangeable.

i.e. a b = b a

Page 5: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (i) Consider a generic operator on some set S. Explain what is meant by saying

c. is idempotent

Answer:

Idempotent means that if a premise is connected with itself using the generic operator then that premise can be concluded on its own.

i.e. a a = a

Page 6: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (i) Consider a generic operator on some set S.

Prove that if the operator is commutative, idempotent and has a right identity element AR, then

( ( a AR ) a ) b = b a a, b S

Answer:

Take LHS ( ( a AR ) a ) b

= ( a a ) b Identity

= a b Idempotent

= b a Commutative

Page 7: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (ii) Using the laws of Propositional Calculus, prove the following:

a. ( p ^ q ) -> r = p -> ( q -> r )

b. ( p ^ ( q v r ) ) ^ ¬q = p ^ ¬q ^ r

c. p ^ ( ( p ^ q ) v ¬p ) = p ^ q

d. p ^ ( ( p ^ q ) v r ) = p ^ ( q v r )

Page 8: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (ii) Using the laws of Propositional Calculus prove:

a. ( p ^ q ) -> r = p -> ( q -> r )

Answer:

Take LHS ( p ^ q ) -> r

= ¬( p ^ q ) v r Definition of ->

= ¬p v ¬q v r De Morgan

= p -> ( ¬q v r )Definition of ->

= p -> ( q -> r )Definition of ->

Page 9: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (ii) Using the laws of Propositional Calculus prove:

b. ( p ^ ( q v r ) ) ^ ¬q = p ^ ¬q ^ r

Answer: ( p ^ ( q v r ) ) ^ ¬q

= ( ( p ^ q ) v ( p ^ r ) ) ^ ¬q Distribution

= ( p ^ q ^ ¬q ) v ( p ^ r ^ ¬q ) Distribution

= ( p ^ F ) v ( p ^ r ^ ¬q ) Compliment

= F v ( p ^ r ^ ¬q ) Absorption

= p ^ ¬q ^ r Identity and Commutative

Page 10: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (ii) Using the laws of Propositional Calculus prove:

c. 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 11: CT214 – Logical Foundations of Computing Lecture 9 Revision

B1. (ii) Using the laws of Propositional Calculus prove:

d. p ^ ( ( p ^ q ) v r ) = p ^ ( q v r )

Answer: p ^ ( ( p ^ q ) v r )

= ( p ^ p ^ q ) v (p ^ r ) Distribution

= ( p ^ q ) v (p ^ r ) Idempotent

= p ^ ( q v r ) Distribution

Page 12: CT214 – Logical Foundations of Computing Lecture 9 Revision

B2. (i) Consider the following argument:

“If the lecturer is hard to understand and the material is complicated then the students will find it difficult to pass

the exam. However, if the lecturer is in a good mood when setting the exam then the exam will be easy. If the exam is easy then the students should not find it difficult to pass the exam. The lecturer is hard to understand but is in a good mood when setting the exam, therefore, the students should not find it difficult to pass the exam.”

Using two alternative proofs, one using the Deduction Theorem and one using Reductio Ad Absurdum, show that this is a valid argument, stating the laws used at each step.

Page 13: CT214 – Logical Foundations of Computing Lecture 9 Revision

“If the lecturer is hard to understand and the material is complicated then the students will find it difficult to pass the exam. However, if the lecturer is in a good mood when setting the exam then the exam will be easy. If the exam is easy then the students should not find it difficult to pass the exam. The lecturer is hard to understand but is in a good mood when setting the exam, therefore, the students should not find it difficult to pass the exam.”

The lecturer is hard to understand U

The material is complicated M

Students find it difficult to pass exam D

Lecturer in a good mood when setting exam G

The exam will be easy E

Page 14: CT214 – Logical Foundations of Computing Lecture 9 Revision

“If the lecturer is hard to understand and the material is complicated then the students will find it difficult to pass the exam. However, if the lecturer is in a good mood when setting the exam then the exam will be easy. If the exam is easy then the students should not find it difficult to pass the exam. The lecturer is hard to understand but is in a good mood when setting the exam, therefore, the students should not find it difficult to pass the exam.”

(1) U ^ M -> D

(2) G -> E ¬D

(3) E -> ¬D

(4) U ^ G

Page 15: CT214 – Logical Foundations of Computing Lecture 9 Revision

(1)U ^ M -> D

(2)G -> E ¬D

(3)E -> ¬D

(4)U ^ G

Proof using Deduction Theorem

U ^ G (4)

G Simplification (5)

G -> E, G (2 + 5)

E Modus Ponens (6)

E -> ¬D, E (3 + 6)

¬D Modus Ponens

Page 16: CT214 – Logical Foundations of Computing Lecture 9 Revision

(1) U ^ M -> D

(2) G -> E ¬D

(3) E -> ¬D

(4) U ^ G

Reductio Ad Absurdum, assume ¬¬D and prove contradiction

(1) U ^ M -> D

(2) G -> E

(3) E -> ¬D False

(4) U ^ G

(5) ¬¬D

Page 17: CT214 – Logical Foundations of Computing Lecture 9 Revision

(1)U ^ M -> D

(2)G -> E

(3)E -> ¬D False

(4)U ^ G

(5)¬¬D

Proof using Reductio Ad Absurdum

U ^ G (4)

G Simplification (6)

G -> E, G (2 + 6)

E Modus Ponens (7)

Page 18: CT214 – Logical Foundations of Computing Lecture 9 Revision

E -> ¬D, E (3 + 7)

¬D Modus Ponens (8)

¬¬D (5)

D Double Negative (9)

D, ¬D (8 + 9)

D ^ ¬D Conjunction

False Compliment

Page 19: CT214 – Logical Foundations of Computing Lecture 9 Revision

B2. (ii) (a) Modus Ponens

Prove: ((P -> Q) ^ P) -> Q is a tautology

Answer: ((P -> Q) ^ P) -> Q

= ((¬P v Q) ^ P) -> Q Definition

= ¬((¬P v Q) ^ P) v Q Definition

= ¬(P ^ (¬P v Q)) v Q Commutative

= ¬((P ^ ¬P) v (P ^ Q)) v Q Distribution

= ¬(F v (P ^ Q)) v Q Complement

.....

Page 20: CT214 – Logical Foundations of Computing Lecture 9 Revision

.....

= ¬(F v (P ^ Q)) v Q Complement

= ¬(P ^ Q) v Q Identity

= (¬P v ¬Q) v Q De Morgan Law 1

= ¬P v (¬Q v Q) Associative

= ¬P v T Complement

= T Absorption

Page 21: CT214 – Logical Foundations of Computing Lecture 9 Revision

B2. (ii) (b) Disjunctive Syllogism

Prove: ((P v Q) ^ ¬ P) -> Q is a tautology

Answer: ((P v Q) ^ ¬ P) -> Q

= ¬((P v Q) ^ ¬ P) v Q Definition

= ¬(P v Q) v ¬(¬ P) v Q De Morgan Law1

= ¬(P v Q) v P v Q Double Negative

= (¬P ^ ¬Q) v P v Q De Morgan Law 2

= P v (¬P ^ ¬Q) v Q Commutative

.....

Page 22: CT214 – Logical Foundations of Computing Lecture 9 Revision

.....

= P v (¬P ^ ¬Q) v Q Commutative

= (P v (¬P ^ ¬Q)) v Q Associative

= ((P v ¬P) ^ (P v ¬Q)) v QDistribution

= (T ^ (P v ¬Q)) v Q Compliment

= (P v ¬Q) v Q Identity

= P v (¬Q v Q) Associative

= P v T Compliment

= T Absorption

Page 23: CT214 – Logical Foundations of Computing Lecture 9 Revision

B3. (i) On the set of integers consider the predicates:

P1(X) : X > 3, P2(X, Y) : X = Y, P3(X, Y, Z) : X - Y = Z

where X, Y, Z State if the following are true:

(a) X : Y : P2(X, Y)

Answer: False as all integers are not equal.

(b) X : Y : P3(X, Y, 8)

Answer: True as there exists two integers that can be subtracted that result in 8.

Page 24: CT214 – Logical Foundations of Computing Lecture 9 Revision

(c) X : Y : P1(X) ^ P2(X, Y)

Answer: False as every integer > 3 is not equal to every other integer.

(d) X : Y : P1(X) ^ P2(X, Y)

Answer: True as every integer > 3 is equal itself.

(e) X : Y : P3(5, X, Y)

Answer: True as every integer can be subtracted from 5 to give some other integer value.

Page 25: CT214 – Logical Foundations of Computing Lecture 9 Revision

B3. (ii) P( X, Y ) means X is a parent of Y, S( X, Y ) means X is a sibling of Y, O( X, Y ) means X is older than Y,

write the following using predicate calculus:

1. “Everyone has a parent”

X : U Y : U P( Y, X )

2. “Every parent is older than their child”

X : U Y : U P( X, Y ) -> O( X, Y )

Page 26: CT214 – Logical Foundations of Computing Lecture 9 Revision

3. “John has no older siblings”

X : U S( john, X ) -> ¬O( X, john )

4. “Nobody who is a parent has an older sibling”

X : U Y Y : U Z : U P(X, Y) -> ¬( S(X, Z) ^ O(Z, X) )