Top Banner
CSC 201: Discrete Mathematics 1
41

CSC 201 Unit 1 Logic

Dec 07, 2015

Download

Documents

Mashruk Kabir

CSC 201 Unit 1 Logic
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSC 201 Unit 1 Logic

1

CSC 201: Discrete Mathematics

Page 2: CSC 201 Unit 1 Logic

2

Unit 1 Logic

Page 3: CSC 201 Unit 1 Logic

3

Subunit 1(a): Propositional logic

Page 4: CSC 201 Unit 1 Logic

4

Propositional Logic

• Propositional logic deals with propositions.• A proposition is a declarative sentence (i. e.

a sentence that declares a fact) that is either true or false but not both.

• A propositional variable is a variable that represents propositions.

• Propositional variables are usually denoted by letters such as p, q, r, s etc.

Page 5: CSC 201 Unit 1 Logic

5

Logical operators stands for “Not”, ˅ stands for “or”, ˄ stands for “and”. These are defined using truth tables as follows:

pT FF T

p q p˅qT T TT F TF T TF F F

p q p˄qT T TT F FF T FF F F

Page 6: CSC 201 Unit 1 Logic

6

More logical operators: Implications

• → stands for “implies” , ↔ stands for “if and only if”

• is also read as “if p then q”

p q p → qT T TT F FF T TF F T

p q p ↔ qT T TT F FF T FF F T

Page 7: CSC 201 Unit 1 Logic

7

Exclusive or ( )

This is defined as follows:

p q p qT T FT F TF T TF F F

Page 8: CSC 201 Unit 1 Logic

8

Some terminology

• The converse of is • The contrapositive of is • A compound proposition is an expression

formed from propositional variables using logical operators

qp qp )()( pq

pq

Page 9: CSC 201 Unit 1 Logic

9

Precedence

.)( means

).(mean not doesIt

.)( means eg.,

,.3

,.2

.1

rqprqp

qp

qpqp

Page 10: CSC 201 Unit 1 Logic

10

An example of finding a truth table of a compound proposition

Find the truth table of

Answer:

p qT T TT F FF T TF F F

)()( qpqp

)()( qpqp

Page 11: CSC 201 Unit 1 Logic

11

A logical puzzle

An island has two kinds of inhabitants: “knights” who always tell the truth and “knaves” who always lie. On the island, you encounter two of its inhabitants, A and B. A says “B is a knight” and B says “the two of us are of opposite types”. Determine the identities of A and B if possible.

Answer: A and B are both knaves

Page 12: CSC 201 Unit 1 Logic

12

Subunit 1(b) : Propositional equivalences

Page 13: CSC 201 Unit 1 Logic

13

Tautology and Contradiction

• A tautology is a compound proposition that is always true irrespective of the truth values of the propositional variables that occur in it

• A contradiction is a compound proposition that is always false irrespective of the truth values of the propositional variables that occur in it

• is a tautology and is a contradiction

pp pp

Page 14: CSC 201 Unit 1 Logic

14

Equivalence of compound propositions

Two compound propositions are said to be logically equivalent provided that they have the same truth value in all possible cases. We use the symbol for logical equivalence.

Page 15: CSC 201 Unit 1 Logic

15

Some examples of logical equivalence

• Show that

Solution: Constructing the truth tables, we see that both compound propositions are true when p and q are false and false in all other cases.

qpqp )(

Page 16: CSC 201 Unit 1 Logic

16

eg. Show that p q r A, B

T T T TT T F TT F T TT F F TF T T TF T F FF F T F

F F F F

right. on theshown as same the

are B andA both of les truth tabThe

).()( denote BLet

).( denoteA Let :Solution

)()()(

rpqp

rqp

rpqprqp

Page 17: CSC 201 Unit 1 Logic

17

Some obvious equivalences

pp

pqqp

pqqp

ppp

ppp

)(

Page 18: CSC 201 Unit 1 Logic

18

Some important equivalences

laws veDistributi )()()(

)()()(

laws eAssociativ )()(

)()(

)equivalent are tivecontraposi its andn implicatio(An

laws sMorgan' De )(

)(

rpqprqp

rpqprqp

rqprqp

rqprqp

pqqp

qpqp

qpqp

qpqp

Page 19: CSC 201 Unit 1 Logic

19

Equivalences involving tautolgies and contradictions

Let T stand for a tautology and let F stand for a contradiction. We have the following

T T

T F F F

T

F

p p pp pp

pp pp

Page 20: CSC 201 Unit 1 Logic

20

Proving an equivalence using known equivalences

Prove that using known equivalences

Solution: We have

F

qpqpp ))((

qp

qp

qppp

qpp

qpp

qppqpp

)(

)()(

)(

))((

)())((

Page 21: CSC 201 Unit 1 Logic

21

Some remarks about implications and equivalences

Let P and Q be compound propositions. • To prove that , it is sufficient to prove

that (a) if P is true then Q is true and (b) if Q is true then P is true.

• To prove that is a tautology, it is sufficient to prove that if P is true then Q is true.

QP

QP

Page 22: CSC 201 Unit 1 Logic

22

Proving that an equivalence is a tautology using logical reasoning

Show that is a tautology

Solution: Suppose that is true. Then, p and q are both true. Therefore is true. We have shown that if is true then must be true. Therefore, is a tautology.

qpqp qp

qp qp qp

qpqp

Page 23: CSC 201 Unit 1 Logic

23

Generalized “or” and “and”

• Because of the associative laws, we can talk about and

• The idea can be extended to any number of propositional variables.

• Thus, we can talk about and

rqp .rqp

nppp 21

.21 nppp

true.are ,,,

ofeach ifonly and if trueis Also,

true.is ,,,

of oneleast at ifonly and if trueis that Note

21

21

21

21

n

n

n

n

ppp

ppp

ppp

ppp

Page 24: CSC 201 Unit 1 Logic

24

The Liar Paradox

• The earliest attribution is to Eubulides of Miletus (~ 4th century B.C., contemporary of Aristotle) who said “A man says that he is lying. Is what he says true or false?”.

• Alternate version: “This sentence is false”• In symbols : L is the sentence “L is false”. This

means that L is true if and only if L is false. • In propositional logic, such sentences are not

considered.

Page 25: CSC 201 Unit 1 Logic

25

Subunit 1(c): Predicates and quantifiers

Page 26: CSC 201 Unit 1 Logic

26

Predicates

• A predicate or propositional function is a statement about one or more variables (of any kind). If the values of the variables are specified, the statement becomes a proposition.

• For example let

Here, P is a predicate of one variable.• Let

Here Q is predicate of two variables.

".0"statement thebe )( xxP

".10"statement thebe ),( yxyxQ

Page 27: CSC 201 Unit 1 Logic

27

Quantifiers ,

• The universal quantifier stands for “for all”.

• The existential quantifier stands for “there exists”

)"( , allfor " means )( xPxxPx

")(such that an exists there" means )( xPxxPx

Page 28: CSC 201 Unit 1 Logic

28

Domain of discourse

Statements involving quantifiers are understood to be with respect to a certain set called the “universe or domain of discourse” which must be specified in order for the statement to become a proposition.

Page 29: CSC 201 Unit 1 Logic

29

Some important sets of numbers

• The set of all natural numbers is the set

{0, 1, 2, 3, 4, ……}• The set of all integers is the set

• Some authors do not include 0 among the

natural numbers.

},3,3,2,2,1,1,0{

Page 30: CSC 201 Unit 1 Logic

30

Rational numbers

• A rational number is a ratio of two integers. • For example, are rational numbers.• It is clear that every integer is a rational

number but there are rational numbers which are not integers.

2

0,

1

2,

2

5,

5

3

Page 31: CSC 201 Unit 1 Logic

31

Real numbers

• A number which corresponds to a “signed distance” on the number line is called a real number.

• It is clear that every rational number is a real number.

• However, there are real numbers which are not rational. Such numbers are called irrational.

• Examples of irrational numbers are .,,2 e

Page 32: CSC 201 Unit 1 Logic

32

Some examples of statements involving predicates and quantifiers

• The statement > 0) is false if the domain of discourse is the set of all real numbers. However, it is true if the domain of discourse is the set of all positive real numbers.

• The statement is true if the domain of discourse is the set of all integers but it is false if the domain of discourse is the set of all positive integers.

xx (

)0( xx

Page 33: CSC 201 Unit 1 Logic

33

Counterexamples

To show that a statement of the form is false, we need to show that there is a value of x in the domain of discourse for which is false. Such an x is called a counterexample to the statement .

For example, is a counterexample to the statement > when the domain of discourse is the set of all real numbers.

)(xPx

)(xP

)(xPx

0x0) (xx

Page 34: CSC 201 Unit 1 Logic

34

Equivalence of statements involving predicates and quantifiers

• Two statements involving predicates and quantifiers are said to be logically equivalent, provided that they have the same truth value irrespective of which predicates are substituted into these statements and which domain of discourse is used for the variables. We use the same symbol as before.

• For example,

(It is understood that the same domain is used throughout)

))(())(())()(( xQxxPxxQxPx

Page 35: CSC 201 Unit 1 Logic

35

Negation of statements involving predicates and quantifiers

)0(

)0()0(

example,For

)()(

)()(

xx

xxxx

xPxxPx

xPxxPx

Page 36: CSC 201 Unit 1 Logic

36

The politician puzzle

A certain convention numbered 100 politicians. Each politician was either crooked or honest. We are given the following two facts:

• At least one of the politicians was honest.• For every choice of two of the politicians, at least one of the two was crooked.

Can it be determined from these two facts how many of the politicians were honest and how many of them were crooked?

Page 37: CSC 201 Unit 1 Logic

37

Solution to the Politician Puzzle

Let A be an honest politician. Let B be any other politician. Since at least one of A and B is crooked, it follows that B is crooked. This applies to any politician other than A. Therefore, there is one honest politician and the other 99 are crooked.

Page 38: CSC 201 Unit 1 Logic

38

Subunit 1(d): Nested quantifiers

Page 39: CSC 201 Unit 1 Logic

39

Order of quantifiers

Suppose that the domain of discourse for all variables below is the set of all real numbers.

• The statement is false since there is no real number y such that for every real number x, we have .

• The statement is true since for every real number x, there is a real number y (i. e. ) such that .

)0( yxxy

0 yx

)0( yxyx

xy 0 yx

Page 40: CSC 201 Unit 1 Logic

40

Negation of statements involving nested quantifiers

eg. Find the negation of the statement

Solution: We have

)1( xyyx

)1(

)1(

)1()1(

xyyx

xyyx

xyyxxyyx

Page 41: CSC 201 Unit 1 Logic

41

Translating sentences in english into statements involving quantifiers

Consider the sentence “The sum of two non-negative integers is always non-negative”. This can be translated into a statement involving quantifiers as follows:

• where the domain for both variables is the set of all integers.

• Another possibility is where the domain for both variables is the set of all non-negative integers.

)0()0()0(( yxyxyx

)0( yxyx