+ All Categories
Home > Documents > Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

Date post: 06-Jan-2016
Category:
Upload: darrin
View: 36 times
Download: 0 times
Share this document with a friend
Description:
King ABDUL AZIZ University Faculty Of Computing and Information Technology. CPCS 222 Discrete Structures I The Foundations: Logic and Proofs. Dr. Eng. Farag Elnagahy [email protected] Office Phone: 67967. Propositional Logic. Propositional logic is - PowerPoint PPT Presentation
143
1 Dr. Eng. Farag Elnagahy [email protected] m Office Phone: 67967 King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222 Discrete Structures I The Foundations: Logic and The Foundations: Logic and Proofs Proofs
Transcript
Page 1: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

1

Dr. Eng. Farag [email protected]

omOffice Phone: 67967

King ABDUL AZIZ University

Faculty Of Computing and Information Technology

CPCS 222Discrete Structures I

The Foundations: Logic and The Foundations: Logic and ProofsProofs

Page 2: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

2

Propositional LogicPropositional Logic• Propositional logicPropositional logic is the studystudy of propositions (true or false statements) and

The ways of combining themways of combining them (logical operators) to get new propositionsget new propositions.

It is effectively an algebra of propositions.

Page 3: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

3

Propositional LogicPropositional Logic

In this algebra, the variablesvariables stand for unknown unknown propositionspropositions (instead of unknown real numbers) and the operatorsoperators are andand, oror, notnot, impliesimplies, and if and only ifif and only if (rather than plus, minus, negative, times, and divided by). Just as middle/high school students learn the notation of algebra and how to manipulate it properly, we want to learn the notation of propositional logic and how to manipulate it properly.

Page 4: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

4

Propositional LogicPropositional Logic

A propositionproposition is a declarative statement that’s either truetrue (TT) or false false (FF), but not bothPropositionsPropositions Every cow has 4 legs Riyadh is the capital of Saudi Arabia 1+1=2 2+2=3

Not PropositionsNot Propositions What time is it? X+1=2 Answer this question

Page 5: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

5

Propositional LogicPropositional Logic

New propositions, called compound compound propositionspropositions are formed from existing propositions using logical Operatorslogical Operators

Page 6: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

6

Propositional Logic Propositional Logic negationnegationSuppose p is a proposition The negation of p is written as p and has meaning:

“It is not the case that p.”

The proposition p is read “not Pnot P”

pp pp

FF TT

TT FF

Truth table for the negation of propositionp

Page 7: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

7

Propositional Logic Propositional Logic negationnegation“ today is Friday”“ it is not the case that today is Friday” or“today is not Friday”“it is not Friday today”

Page 8: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

8

Propositional Logic Propositional Logic conjunctionconjunctionSuppose p and qq are propositions The conjunction of p and q is written as pq

The proposition pq is read “p and q”

Truth table for the Conjunction of two propositionspq

pp qq ppqqFF FF FF

FF TT FF

TT FF FF

TT TT TT

Page 9: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

9

Propositional Logic Propositional Logic conjunctionconjunctionpp is the proposition “Today is Friday”qq is the proposition “It is raining today”

The conjunction of p and q is proposition “ Today is Friday andand it is raining today”

This proposition Is truetrue on rainy Fridays Is falsefalse on any day that is not a Friday on Fridays when it does not rain

Page 10: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

10

Propositional Logic Propositional Logic disjunctiondisjunction Inclusive OrSuppose p and qq are propositions The disjunction of p and q is written as pq

The proposition pq is read “p or q”

Truth table for the Disjunction (Inclusive Or) of two propositionspq

pp qq ppqqFF FF FF

FF TT TT

TT FF TT

TT TT TT

Page 11: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

11

Propositional Logic Propositional Logic disjunctiondisjunctionpp is the proposition “Today is Friday”qq is the proposition “It is raining today”

The disjunction of p and q is proposition “ Today is Friday oror it is raining today”

This propositionIs truetrue on any day that is either a Friday or a rainy day(including rainy

Fridays)Is falsefalse on days that are not Fridays when it also does not rain

Page 12: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

12

Propositional Logic Propositional Logic disjunctiondisjunction Exclusive OrSuppose p and qq are propositions The Exclusive Or of p and q is written as pq

The proposition pq is read “p or q but not both”

Truth table for the Exclusive OrExclusive Or of two propositionspq

pp qq ppqq

FF FF FF

FF TT TT

TT FF TT

TT TT FF((ppq) q) (p (pq) q)

Page 13: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

13

Propositional Logic Propositional Logic disjunctiondisjunction Exclusive Or

“Tonight I will stay home or go out to a Tonight I will stay home or go out to a moviemovie.”

Page 14: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

14

Propositional Logic Propositional Logic implicationimplicationSuppose p and qq are propositions

The conditional statementconditional statement (implicationimplication) ppqqThe proposition ppqq is read “ ifif p, then qp, then q”PP hypothesis – antecedent – premiseqq conclusion -consequence

Truth table for the ImplicationImplicationppqq

pp qq ppqq

FF FF TT

FF TT TT

TT FF FF

TT TT TTpp q q

Page 15: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

15

Propositional Logic Propositional Logic implicationimplication

Terminology used to express ppqq“if p, then q”“p is sufficient for q”“q if p” “q when p”“a necessary condition for p is q”“q unless p““p implies q”“p only if q”“a sufficient condition for q is p”“q whenever p”“q is necessary for p”“q follows from p”“if p, q”

Page 16: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

16

Propositional Logic Propositional Logic implicationimplicationpp is the proposition “Ahmed learns

discrete mathematics”qq is the proposition “Ahmed will find a

good job”The ppqq is proposition “ if Ahmed learns discrete mathematics,

then he will find a good job”

This propositionIs falsefalse when pp is true and qq is falseOtherwise it is true

Page 17: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

17

Propositional Logic Propositional Logic implicationimplicationpp is the proposition “today is Friday”qq is the proposition “2+3=5”The ppqq is proposition “ if today is Friday, then 2+3=5”

This propositionIs true true becausebecause its its Conclusion (Conclusion (qq) is true) is true ““

pp qq ppqq

FF FF TT

FF TT TT

TT FF FF

TT TT TT

Page 18: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

18

Propositional Logic Propositional Logic implicationimplicationpp is the proposition “today is Friday”qq is the proposition “2+3=6”The ppqq is proposition “ if today is Friday, then 2+3=6”

This propositionIs true true every day every day except Fridayexcept Friday

pp qq ppqq

FF FF TT

FF TT TT

TT FF FF

TT TT TT

Page 19: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

19

Propositional Logic Propositional Logic implicationimplicationThe conditional statementconditional statement (implication) implication)

ppqq““if it is raining, then the home team if it is raining, then the home team

winswins””

qq p p is calledis called contrapositive contrapositive ofof p pqq““if the home team does not win, then it is if the home team does not win, then it is

not rainingnot raining””

The proposition qqp p is calledis called converse converse ofof ppqq

““if the home team wins, then it is if the home team wins, then it is rainingraining””

pp q q is calledis called inverse inverse ofof p pqq““if it is not raining, then the home team if it is not raining, then the home team

does not windoes not win””

Page 20: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

20

Propositional Logic Propositional Logic bi-bi-implicationimplicationSuppose p and qq are propositions The biconditional statementbiconditional statement (bi-bi-implicationimplication) ppqqThe proposition p p q q is read “ p if and p if and only if qonly if q”p p q is true if both q is true if both ppq q q qp are truep are trueppq q p pq -------q ------- ppqq

Truth table for the Bi-implicationBi-implicationppqq

pp qq ppqq

FF FF TT

FF TT FF

TT FF FF

TT TT TT

(p(p q ) q ) ( ( pp q ) q )

Page 21: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

21

Propositional Logic Propositional Logic bi-bi-implicationimplicationThe proposition p p q q has the same truth

value as ppq q q qpp

pp qq ppqq

qqpp ppq q q qpp ppqq

FF FF TT TT TT TT

FF TT TT FF FF FF

TT FF FF TT FF FF

TT TT TT TT TT TT

Page 22: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

22

Propositional Logic Propositional Logic bi-bi-implicationimplication

pp is the proposition “You can take the flight”qq is the proposition “You buy a ticket”

The p p q q is proposition “You can take the flight if and only if You buy a ticket”

This propositionIs true true if p and q are either both true or if p and q are either both true or both false”both false”

Page 23: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

23

Propositional LogicPropositional Logic

Truth table of compound Truth table of compound propositionspropositions Precedence of logical Precedence of logical operatorsoperators

Page 24: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

24

Propositional LogicPropositional Logic

Truth table of compound Truth table of compound propositionspropositionsConstruct the Construct the Truth table of compound Truth table of compound propositionspropositions

(p (p q) q) (p (p q) q)

pp qq qq ppqq ppqq (p(pq) q) (p(pq)q)

FF FF TT TT FF FF

FF TT FF FF FF TT

TT FF TT TT FF FF

TT TT FF TT TT TT

Page 25: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

25

Propositional LogicPropositional Logic

Translating English sentence into a Translating English sentence into a logicallogical expressionexpression ““You can access the internet from You can access the internet from campus campus only ifonly if you are a computer you are a computer science major science major oror you are not a you are not a freshmanfreshman””a: “You can access the internet from a: “You can access the internet from campus”campus”b: “you are a computer science major”b: “you are a computer science major”c: “you are a freshman”c: “you are a freshman” Where a,b,c are propositional variablesWhere a,b,c are propositional variables

a a (b (b c)c)

Page 26: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

26

Propositional LogicPropositional Logic

Translating English sentence into a Translating English sentence into a logicallogical expressionexpression (System specifications) (System specifications) Translating sentences in natural Translating sentences in natural language into logical expressions is an language into logical expressions is an essential part of specifying both essential part of specifying both hardware and software systems.hardware and software systems.

System and software engineers take System and software engineers take requirements in natural language and requirements in natural language and produce precise and unambiguous produce precise and unambiguous specifications that can be used as the specifications that can be used as the basis for system development.basis for system development.

Page 27: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

27

Propositional LogicPropositional Logic

Translating English sentence into a Translating English sentence into a logicallogical expressionexpression (System specifications) (System specifications) Express the specification ”Express the specification ”The The automated reply cannot be sent when automated reply cannot be sent when the file system is fullthe file system is full“ using logical “ using logical connectives.connectives.

P: “P: “The automated reply can be sentThe automated reply can be sent””q: “q: “The file system is fullThe file system is full””

q q pp

System specifications should be System specifications should be consistentconsistent

They should not contain conflicting They should not contain conflicting requirements that could be used to requirements that could be used to drive a contradictiondrive a contradiction

Page 28: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

28

Propositional LogicPropositional Logic

Translating English sentence into a Translating English sentence into a logicallogical expressionexpression (System specifications) (System specifications) determine whether these system determine whether these system specifications are consistent :specifications are consistent :

““The diagnostic message is stored in the buffer The diagnostic message is stored in the buffer or it is retransmitted”or it is retransmitted”

““The diagnostic message is not stored in the The diagnostic message is not stored in the buffer”buffer”

““if the diagnostic message is stored in the if the diagnostic message is stored in the buffer, then it is retransmitted”buffer, then it is retransmitted”

P: “The diagnostic message is stored in the P: “The diagnostic message is stored in the buffer”buffer”

q: “The diagnostic message is retransmitted”q: “The diagnostic message is retransmitted”

p p q q p pp pq q

Page 29: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

29

Propositional LogicPropositional Logic

Translating English sentence into a Translating English sentence into a logicallogical expressionexpression (System specifications) (System specifications)p p q q p pp pq q

pp qq pp ppqq p p qq

FF FF TT FF TT

FF TT TT TT TT

TT FF FF TT FF

TT TT FF TT TT

system specifications are system specifications are consistentconsistent

Page 30: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

30

Propositional LogicPropositional Logic

Translating English sentence into a Translating English sentence into a logicallogical expressionexpression (System specifications) (System specifications) determine whether these system determine whether these system specification are consistent :specification are consistent :

““The diagnostic message is stored in the The diagnostic message is stored in the buffer or it is retransmitted”buffer or it is retransmitted”

““The diagnostic message is not stored in the The diagnostic message is not stored in the buffer”buffer”

““if the diagnostic message is stored in the if the diagnostic message is stored in the buffer, then it is retransmitted”buffer, then it is retransmitted”

““The diagnostic message is not The diagnostic message is not retransmitted”retransmitted”

P: “The diagnostic message is stored in the P: “The diagnostic message is stored in the buffer”buffer”

q: “The diagnostic message is retransmitted”q: “The diagnostic message is retransmitted”

p p q q p pp pq q qq

Page 31: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

31

Propositional LogicPropositional Logic

Translating English sentence into a Translating English sentence into a logicallogical expressionexpression (System specifications) (System specifications)p p q q p pp pq q qq

pp qq pp ppqq p p qq qq

FF FF TT FF TT TT

FF TT TT TT TT FF

TT FF FF TT FF TT

TT TT FF TT TT FF

system specifications are system specifications are inconsistentinconsistent

Page 32: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

32

Propositional LogicPropositional Logic

Boolean SearchesBoolean Searches Logical connectives are used Logical connectives are used

extensively in searches of large extensively in searches of large collections of information:collections of information:

Indexes of Web pagesIndexes of Web pages, these searches , these searches employ techniques from propositional employ techniques from propositional logiclogic..

The connectiveThe connective ANDAND is used to match records that is used to match records that

contain both of the two search items.contain both of the two search items.OROR is used to match one or both of two is used to match one or both of two

search items.search items.NOTNOT is used to exclude a particular is used to exclude a particular

search item (search item (-- is used in Google). is used in Google).

Page 33: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

33

Propositional LogicPropositional Logic

Logic PuzzlesLogic Puzzles puzzles that can be solved using puzzles that can be solved using

logical reasoning are known as logic logical reasoning are known as logic puzzles.puzzles.

Knight “always tell the truth”Knight “always tell the truth”Knave “always lie”Knave “always lie”

You encounter two people A and B,What You encounter two people A and B,What are A and B ifare A and B if

A says “B is a knight”A says “B is a knight”B says “ the two of us are opposite”B says “ the two of us are opposite”

Page 34: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

34

Propositional LogicPropositional Logic

Logic PuzzlesLogic PuzzlesLet:Let: p: “A is a knight“ q: “B is a knight“ p: “A is a knight“ q: “B is a knight“ p : “ A is a knave”p : “ A is a knave” q: “ B is a knave”q: “ B is a knave”A says “B is a knight” A says “B is a knight” qqB says “ the two of us are opposite”B says “ the two of us are opposite” (p (p q) q) (( p p q)q) If A is a knightIf A is a knightThen Then qq is true and is true and (p (p q) q) (( p p q)q) is true is trueBut But (p (p q) q) (( p p q)q) is false is falseWe can conclude that A is a knaveWe can conclude that A is a knave

Page 35: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

35

Propositional LogicPropositional Logic

Logic PuzzlesLogic PuzzlesLet:Let: p: “A is a knight“ q: “B is a knight“ p: “A is a knight“ q: “B is a knight“ p : “ A is a knave”p : “ A is a knave” q: “ B is a knave”q: “ B is a knave”A says “B is a knight” A says “B is a knight” qqB says “ the two of us are opposite”B says “ the two of us are opposite” (p (p q) q) (( p p q)q) If B is a knightIf B is a knight (q is true)(q is true)Then Then (p (p q) q) (( p p q)q) is true and is true and qq is is

false false We can conclude that B is a knaveWe can conclude that B is a knave

A and B are knavesA and B are knaves

Page 36: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

36

Propositional LogicPropositional Logic

Logic and Bit operationsLogic and Bit operationsA bit string is a sequence of zero or A bit string is a sequence of zero or

more bits. The length of this string is more bits. The length of this string is the number of bits in the string.the number of bits in the string.

101010011101010011 is a bit string of length is a bit string of length ninenine Bitwise OR(Bitwise OR(), Bitwise AND (), Bitwise AND (), Bitwise ), Bitwise

XOR(XOR() ) 0 1 1 0 1 1 0 1 1 00 1 1 0 1 1 0 1 1 0 1 1 0 0 0 1 1 1 0 11 1 0 0 0 1 1 1 0 1Bitwise OR Bitwise OR 1 1 1 0 1 1 1 1 1 11 1 1 0 1 1 1 1 1 1Bitwise AND Bitwise AND 0 1 0 0 0 1 0 1 0 00 1 0 0 0 1 0 1 0 0Bitwise XOR Bitwise XOR 1 0 1 0 1 0 1 0 1 11 0 1 0 1 0 1 0 1 1

Page 37: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

37

Chapter 1 ExercisesChapter 1 Exercises

Pages (16-20)Pages (16-20)1,3,6,7,9,101,3,6,7,9,1012-14 (b,c)12-14 (b,c)15,1715,1720,22,24,25,2620,22,24,25,2627-33 (e)27-33 (e)36-3836-3848485050

Page 38: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

38

Propositional EquivalencesPropositional Equivalences

Classification of compound propositionsClassification of compound propositions

A compound proposition that is always A compound proposition that is always truetrue is called a is called a tautologytautology.. ((p p p)p)

A compound proposition that is always A compound proposition that is always falsefalse is called a is called a contradictioncontradiction. (. (pp pp))

A compound proposition that is neither A compound proposition that is neither a a tautologytautology nor a nor a contradiction contradiction is called is called a a contingencycontingency..

Page 39: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

39

Propositional EquivalencesPropositional Equivalences

Logical equivalencesLogical equivalences compound propositions that have the compound propositions that have the samesame truth values in all possible cases are truth values in all possible cases are calledcalled Logically equivalentLogically equivalentCompound propositions p and q are Compound propositions p and q are Logically equivalent Logically equivalent ifif ppq q isis a a tautologytautology..

logical equivalence logical equivalence

Note and and are are not logical operators(connectives). Rather they indicate a kind of logical equality.

Page 40: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

40

Propositional EquivalencesPropositional Equivalences

Prove that Prove that [r[r(q(q((r r p ))] p ))] rr(p(pq)q)by using a truth table.by using a truth table.

Page 41: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

41

Propositional EquivalencesPropositional Equivalences

Identity lawsIdentity laws p p T T p p p p F F p pDomination lawsDomination laws p p F F F F p p T T T TIdempIdempootent lawstent laws p p p p p p p p p p p p

Double negation lawDouble negation law ((p) p) p p Negation lawsNegation laws p p p p T T p p p p F FAbsorption lawsAbsorption laws p p(p(pq) q) p p pp(p (p q) q) p pCommutative lawsCommutative laws p p q q q q p p p p q q q q p p Associative lawsAssociative laws (p (pq)q)r r p p(q(qr) r) (p(pq)q)r r pp(q(qr)r)De Morgan’s lawsDe Morgan’s laws (p(pq) q) ppq q (p(pq) q) ppqqDistributive lawsDistributive laws p p(q(qr) r) (p(pq)q)((ppr) r) pp(q(qr) r) (p(pq)q)((ppr)r)T denotes the compound proposition that is always T denotes the compound proposition that is always truetrueF denotes the compound proposition that is always F denotes the compound proposition that is always falsefalse

Page 42: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

42

Propositional EquivalencesPropositional Equivalences

p p q q pp q q (p (p q) q) pp qqp p q q qq p p

pp q q pp qqpp q q (p(p q)q)

(p (p q) q) (p (p r) r) p p (q (q r ) r )(p (p q) q) (p (p r) r) p p (q (q r ) r )

(p (p r) r) (q (q r) r) (p(p q ) q ) r r(p (p r) r) (q (q r) r) (p(p q ) q ) r r

p p q q (p (p q) q) (q (q p) p) p p q q p p q qp p q q (p(p q ) q ) ( ( pp q ) q ) (p (p q) q) p p q q

Page 43: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

43

Propositional EquivalencesPropositional Equivalences

Use De Morgan’s law to express the Use De Morgan’s law to express the negation of “negation of “Ahmed has a mobile Ahmed has a mobile andand he has a laptophe has a laptop””p: “Ahmed has a mobile”p: “Ahmed has a mobile”q: “Ahmed has a laptop”q: “Ahmed has a laptop”

p p q q(p(pq) q) p p qq p: “Ahmed has not a mobile”p: “Ahmed has not a mobile” q: “Ahmed has not a laptop”q: “Ahmed has not a laptop”““Ahmed has not a mobile Ahmed has not a mobile oror he has not he has not a laptopa laptop””

Page 44: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

44

Propositional EquivalencesPropositional Equivalences

Show thatShow that (p (p q) q) pp qqShow that Show that (p(p ( ( p p q)) q)) pp qqShow that Show that ((p p q) q) ( (p p q) is a q) is a tautologytautology

Page 45: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

45

Chapter 1 ExercisesChapter 1 Exercises

Pages (28-30)Pages (28-30)1(a,b,f)1(a,b,f)4(b)4(b)7,87,89(a,f)9(a,f)11(a,f)11(a,f)151526,2726,27

Page 46: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

46

Predicates and QuantifiersPredicates and Quantifiers

PredicatesPredicates “ “x is greater than 3”x is greater than 3”This statement is neither true nor false This statement is neither true nor false when the value of the variable is not when the value of the variable is not specified.specified.This statement has two patsThis statement has two pats The fist part (subject) is the variable xThe fist part (subject) is the variable x The second (predicate) is “is greater The second (predicate) is “is greater than 3”than 3”We can denote this statement by P(x)We can denote this statement by P(x)Where P denotes the Where P denotes the predicatepredicate “is greater “is greater than 3”than 3”Once a value has been assigned to x, the Once a value has been assigned to x, the statement P(x) becomes a proposition and statement P(x) becomes a proposition and has a truth value. P is called Proposition has a truth value. P is called Proposition function.function.

Page 47: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

47

Predicates and QuantifiersPredicates and Quantifiers

PredicatesPredicates let let PP(x) denote “(x) denote “is greater than 3is greater than 3””What are the truth values of What are the truth values of PP(4) and (4) and PP(2)?(2)?

let let QQ(x,y) denote “x=y+3”(x,y) denote “x=y+3”What are the truth values of What are the truth values of QQ(1,2) and (1,2) and QQ(3,0)?(3,0)?

let let RR(x,y,z) denote “x+y=z”(x,y,z) denote “x+y=z”What are the truth values of What are the truth values of RR(1,2,3) and (1,2,3) and RR(0,0,1)?(0,0,1)?

P(xP(x11,x,x22,x,x33,………,x,………,xnn) ) P is called n-place(n-ary) predicate.P is called n-place(n-ary) predicate.

Page 48: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

48

Predicates and QuantifiersPredicates and Quantifiers

PredicatesPredicates let let AA(c,n) denote “computer c is (c,n) denote “computer c is connected to network n”connected to network n”

Suppose that the computer Suppose that the computer MATH1MATH1 is is connected connected to network to network CAMPUS2CAMPUS2, but not to network , but not to network CAMPUS1CAMPUS1

What are the truth values of What are the truth values of AA(MATH1, CAMPUS1) and (MATH1, CAMPUS1) and AA(MATH1, CAMPUS2) ?(MATH1, CAMPUS2) ?

Page 49: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

49

Predicates and QuantifiersPredicates and Quantifiers

PredicatesPredicatesProposition functions(Proposition functions(PredicatesPredicates) occur in ) occur in computer programs.computer programs. If x>0 then x:=x+1If x>0 then x:=x+1P(x) : “x>0”P(x) : “x>0”If P(x) is true the assignment is executed If P(x) is true the assignment is executed If P(x) is false the assignment is not If P(x) is false the assignment is not executedexecuted

Page 50: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

50

Predicates and QuantifiersPredicates and Quantifiers

Universal quantificationUniversal quantificationWhich tell us that a predicate is true for Which tell us that a predicate is true for every element under consideration.every element under consideration. existential quantificationexistential quantificationWhich tell us that there is one or more Which tell us that there is one or more element under consideration for which the element under consideration for which the predicate is true.predicate is true.

The The area of logicarea of logic that deals with that deals with predicatespredicates and and quantifiersquantifiers is called is called predicate calculuspredicate calculus..

Page 51: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

51

Predicates and QuantifiersPredicates and Quantifiers

The The universal quantificationuniversal quantification of P(x) is the of P(x) is the statement “P(x) for all values of x in the statement “P(x) for all values of x in the domain”domain” ∀ ∀x P(x) read as “for all x P(x)”x P(x) read as “for all x P(x)” “ “for every x P(x)”for every x P(x)”∀ ∀ is called is called universal quantifieruniversal quantifier

The The existential quantificationexistential quantification of P(x) is the of P(x) is the statement “there exists an element x in statement “there exists an element x in the domain such that P(x)”the domain such that P(x)” ∃∃x P(x) read as “there is an x such that x P(x) read as “there is an x such that P(x)”P(x)” “ “there is at least one x such that there is at least one x such that P(x)”P(x)” “ “for some x P(x)”for some x P(x)”∃∃ is called is called existential quantifierexistential quantifier

Page 52: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

52

Predicates and QuantifiersPredicates and Quantifiers

∀∀x P(x)x P(x)When trueWhen true P(x) is true for every x. P(x) is true for every x.When falseWhen false there is an x for which P(x) is there is an x for which P(x) is false.false.

∃∃x P(x)x P(x)When trueWhen true there is an x for which P(x) is there is an x for which P(x) is true. true. When falseWhen false P(x) is false for every x. P(x) is false for every x.

Page 53: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

53

Predicates and QuantifiersPredicates and Quantifiers

Let Q(x) “x<2”Let Q(x) “x<2”What is the truth value of ∀x Q(x) when the What is the truth value of ∀x Q(x) when the domain consists of all real numbers?domain consists of all real numbers?

Q(x) is not true for every real number x, for Q(x) is not true for every real number x, for example Q(3) is false.example Q(3) is false.

x=3 is a x=3 is a counterexamplecounterexample for the statement for the statement ∀∀x Q(x) x Q(x)

Thus Thus ∀x Q(x) is false.∀x Q(x) is false.

Page 54: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

54

Predicates and QuantifiersPredicates and Quantifiers

Let Q(x) “xLet Q(x) “x22>0”>0”What is the truth value of ∀x Q(x) when the What is the truth value of ∀x Q(x) when the domain consists of all integers?domain consists of all integers?

Q(x) is not true for every integer number x, Q(x) is not true for every integer number x, for example Q(0) is false.for example Q(0) is false.

x=0 is a x=0 is a counterexamplecounterexample for the statement for the statement ∀∀x Q(x) x Q(x)

Thus Thus ∀x Q(x) is false.∀x Q(x) is false.

Page 55: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

55

Predicates and QuantifiersPredicates and Quantifiers

What is the truth value of ∀x (xWhat is the truth value of ∀x (x22 x) when x) when the domainthe domain

a) consists of all real number?a) consists of all real number?b) consists of all integers?b) consists of all integers?

a)a) is is falsefalse because (0.5) because (0.5)22 0.5 0.5 xx22 x is false for all real numbers in the x is false for all real numbers in the

range 0<x<1 range 0<x<1 b) is b) is truetrue because there are no integer x because there are no integer x

withwith0<x<10<x<1

Page 56: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

56

Predicates and QuantifiersPredicates and Quantifiers

Let Q(x) “x>3”Let Q(x) “x>3”What is the truth value of What is the truth value of ∃∃x Q(x) when the x Q(x) when the domain consists of all real numbers?domain consists of all real numbers?

Q(x) is sometimes true , for example Q(4) Q(x) is sometimes true , for example Q(4) is true.is true.

Thus ∃Thus ∃x Q(x) is true.x Q(x) is true.

∃∃x Q(x) is x Q(x) is falsefalse iif there is iif there is no elementsno elements in in the domain for which the domain for which Q(x) is trueQ(x) is true..

Page 57: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

57

Predicates and QuantifiersPredicates and Quantifiers

Let Q(x) “x=x+1”Let Q(x) “x=x+1”What is the truth value of What is the truth value of ∃∃x Q(x) when the x Q(x) when the domain consists of all real numbers?domain consists of all real numbers?

Q(x) is false for every real number.Q(x) is false for every real number.

Thus ∃Thus ∃x Q(x) is x Q(x) is falsefalse..

∃∃x Q(x) is x Q(x) is falsefalse iif there is iif there is no elementsno elements in in the domain for which the domain for which Q(x) is trueQ(x) is true or the or the domaindomain is is emptyempty..

Page 58: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

58

Predicates and QuantifiersPredicates and Quantifiers

When all the elements in the domain can When all the elements in the domain can be listed xbe listed x11, x, x22 ,x ,x33, x, x44, ……., x, ……., xnn

∀∀x Q(x) is the same as the conjunction x Q(x) is the same as the conjunction Q(xQ(x11) ) Q(xQ(x22) ) …. …. Q(xQ(xnn) ) ∃∃x Q(x) is the same as the disjunctionx Q(x) is the same as the disjunction

Q(xQ(x11) ) Q(xQ(x22) ) …. …. Q(xQ(xnn))

Page 59: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

59

Predicates and QuantifiersPredicates and Quantifiers

Let Q(x) “xLet Q(x) “x22<10”<10”What is the truth value of ∀x Q(x) when the What is the truth value of ∀x Q(x) when the domain consists of the positive integers domain consists of the positive integers not exceeding 4?not exceeding 4?

∀∀x Q(x) is the same as the conjunction x Q(x) is the same as the conjunction Q(1) Q(1) Q(2) Q(2) Q(3) Q(3) Q(4).Q(4).Q(4) is falseQ(4) is falseThus Thus ∀x Q(x) is false.∀x Q(x) is false.

Page 60: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

60

Predicates and QuantifiersPredicates and Quantifiers

Let Q(x) “xLet Q(x) “x22>10”>10”What is the truth value of What is the truth value of ∃∃x Q(x) when the x Q(x) when the domain consists of the positive integers domain consists of the positive integers not exceeding 4?not exceeding 4?

∃∃x Q(x) is the same as the disjunction x Q(x) is the same as the disjunction Q(1) Q(1) Q(2) Q(2) Q(3) Q(3) Q(4).Q(4).Q(4) is trueQ(4) is trueThus ∃Thus ∃x Q(x) is true.x Q(x) is true.

Page 61: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

61

Predicates and QuantifiersPredicates and Quantifiers

If domain consists of If domain consists of n (n (finitefinite) ) object and object and we need to determine the we need to determine the truth valuetruth value of of∀∀x Q(x)x Q(x) Loop through Loop through allall nn values of values of xx to see if to see if Q(x)Q(x) is is alwaysalways truetrue If you encounter a value x for which If you encounter a value x for which Q(x)Q(x) is is falsefalse, exit the loop, exit the loop withwith ∀x Q(x) is ∀x Q(x) is falsefalse otherwiseotherwise ∀x Q(x) ∀x Q(x) is trueis true

∃∃x Q(x)x Q(x) Loop through Loop through all nall n values of values of xx to see if to see if Q(x)Q(x) is is truetrue If you encounter a value x for which If you encounter a value x for which Q(x)Q(x) is is truetrue, exit the loop, exit the loop withwith ∃∃x Q(x)x Q(x) is true is true OtherwiseOtherwise ∃ ∃x Q(x)x Q(x) is false is false

Page 62: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

62

Predicates and QuantifiersPredicates and Quantifiers

You can define other quantifiers, for You can define other quantifiers, for exampleexample““there are exactly two”there are exactly two”““there are at least 100”there are at least 100”

Uniqueness quantifier Uniqueness quantifier ∃! ∃1 ∃! ∃1 ““there exists a unique x such that P(x) is there exists a unique x such that P(x) is true”true”““there is exactly one”there is exactly one”““there is one and only one”there is one and only one”

Precedence of quantifiersPrecedence of quantifiers∀∀ ∃ ∃ have higher phave higher precedencerecedence than all logical than all logical operators operators

Page 63: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

63

Quantifiers with restricted Quantifiers with restricted domaindomainWhat do these statements mean (domain What do these statements mean (domain

real)real)

∀∀x<0 (xx<0 (x22>0) >0) same assame as ∀x (x<0 ∀x (x<0 x x22>0)>0)““the square of a negative real number is the square of a negative real number is positivepositive””

∀∀yy0 (y0 (y33 0) 0) same assame as ∀y(y ∀y(y0 0 y y33 0) 0) ““the cube of every nonzero real number is the cube of every nonzero real number is nonzerononzero””

∃∃z >0 (zz >0 (z22=2) =2) same assame as ∃z(z>0 ∃z(z>0 z z22=2) =2) ““there is a positive square root of 2there is a positive square root of 2””

Page 64: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

64

Binding variablesBinding variables

∃∃x (x+y=1) x (x+y=1) The variable The variable xx is is boundedbounded by the by the existential quantification ∃x and the existential quantification ∃x and the variable y is variable y is freefree

∃∃x (P(x) x (P(x) Q(x)) Q(x)) ∀x R(x) ∀x R(x) All variables are boundedAll variables are boundedThe The scopescope of the of the firstfirst quantifier ∃x is the expression P(x) quantifier ∃x is the expression P(x) Q(x) Q(x) secondsecond quantifier ∀x is the expression R(x) quantifier ∀x is the expression R(x) existential quantifier existential quantifier bindsbinds the variable x the variable x in P(x) in P(x) Q(x) Q(x) Universal quantifier Universal quantifier bindsbinds the variable x in the variable x in R(x)R(x)

Page 65: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

65

Logical equivalence involving Logical equivalence involving quantifiersquantifiersStatements involving predicates and Statements involving predicates and quantifier are quantifier are logically equivalentlogically equivalent iff they iff they have the have the same truth valuesame truth value

Show that Show that ∀x (P(x) ∀x (P(x) Q(x)) Q(x)) ∀x P(x) ∀x P(x) ∀x ∀x Q(x)Q(x)

suppose that suppose that ∀x (P(x) ∀x (P(x) Q(x)) Q(x)) is true, this is true, this means that if a is in the domain then P(a) means that if a is in the domain then P(a) Q(a) is true Q(a) is true Hence, both P(a) and Q(a) are true for Hence, both P(a) and Q(a) are true for every element in the domain every element in the domain So ∀x P(x) and ∀x Q(x) are both true.So ∀x P(x) and ∀x Q(x) are both true.This means that This means that ∀x P(x) ∀x P(x) ∀x Q(x) ∀x Q(x) is true. is true.

Page 66: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

66

Logical equivalence involving Logical equivalence involving quantifiersquantifiersShow that Show that ∀x (P(x) ∀x (P(x) Q(x)) Q(x)) ∀x P(x) ∀x P(x) ∀x ∀x Q(x)Q(x)

suppose that suppose that ∀x P(x) ∀x P(x) ∀x Q(x) ∀x Q(x) is true, it is true, it follows that both follows that both ∀x P(x) ∀x P(x) andand ∀x Q(x) ∀x Q(x) are are true hence, if a is in the domain then P(a) true hence, if a is in the domain then P(a) is true and Q(a) is true is true and Q(a) is true This means that This means that ∀x (P(x) ∀x (P(x) Q(x)) Q(x)) is true. is true.

Now we can conclude thatNow we can conclude that∀∀x (P(x) x (P(x) Q(x)) Q(x)) ∀x P(x) ∀x P(x) ∀x Q(x) ∀x Q(x)

Page 67: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

67

Logical equivalence involving Logical equivalence involving quantifiersquantifiers∀∀x (P(x) x (P(x) Q(x)) Q(x)) ∀x P(x) ∀x P(x) ∀x Q(x) ∀x Q(x)

The universal quantifier The universal quantifier can be distributedcan be distributed over the a conjunction (over the a conjunction ().).

The universal quantifier The universal quantifier can be distributedcan be distributed over the a disjunction (over the a disjunction ().).

The existential quantifier The existential quantifier can not be can not be distributeddistributed over the a conjunction ( over the a conjunction () and ) and disjunction (disjunction ().).

Page 68: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

68

Negating quantified expressionNegating quantified expression

““Every student in your class has taken a Every student in your class has taken a course in calculus” course in calculus” ∀x P(x)∀x P(x)Where, Where, P(x)P(x) is “x has taken a course in is “x has taken a course in calculus”calculus”and the and the domaindomain consists of the student in consists of the student in your class your class NegationNegation““It is not the case that every student in It is not the case that every student in your class has taken a course in calculus”your class has taken a course in calculus”oror““There is a student in your class who has There is a student in your class who has not taken a course in calculus” not taken a course in calculus” ∃x ∃x P(x)P(x) ∀∀x P(x) x P(x) ∃x ∃x P(x)P(x)

Page 69: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

69

Negating quantified expressionNegating quantified expression

““There is a student in this class who has There is a student in this class who has taken a course in calculus” taken a course in calculus” ∃x Q(x)∃x Q(x)Where, Where, Q(x)Q(x) is “x has taken a course in is “x has taken a course in calculus”calculus”and the and the domaindomain consists of the student in consists of the student in your class your class NegationNegation““It is not the case that there is a student in It is not the case that there is a student in this class who has taken a course in this class who has taken a course in calculus”calculus”oror““Every student in this class has not taken a Every student in this class has not taken a course in calculus” course in calculus” ∀x ∀x Q(x)Q(x)““Not all students in this class have taken a course in Not all students in this class have taken a course in

calculus” calculus” isis not used. not used. ∃x Q(x)∃x Q(x) ∀x ∀x Q(x)Q(x)

Page 70: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

70

Negating quantified expressionNegating quantified expression

Show that (Show that (homeworkhomework))∀∀x P(x) x P(x) ∃x ∃x P(x)P(x)∃∃x P(x)x P(x) ∀x ∀x P(x)P(x)

Page 71: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

71

Negating quantified expressionNegating quantified expression

De Morgan’s laws for quantifiersDe Morgan’s laws for quantifiers∃∃x P(x) x P(x) ∀x ∀x P(x)P(x)The The negationnegation is is truetrue when for every x, P(x) when for every x, P(x) is falseis falseThe The negationnegation is is falsefalse when there is an x for when there is an x for which P(x) is truewhich P(x) is true

∀∀x P(x) x P(x) ∃x ∃x P(x)P(x)The The negationnegation is is truetrue when there is an x for when there is an x for which P(x) is falsewhich P(x) is falseThe The negationnegation is is false false when for every x, P(x) when for every x, P(x) is trueis true

Page 72: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

72

Negating quantified expressionNegating quantified expression

De Morgan’s laws for quantifiersDe Morgan’s laws for quantifiersWhen the domain of a predicate Q(x) When the domain of a predicate Q(x) consists of n elements xconsists of n elements x11, x, x22 ,x ,x33, x, x44, ……., x, ……., xnn

∀∀x Q(x) is the same as the conjunction x Q(x) is the same as the conjunction Q(xQ(x11) ) Q(xQ(x22) ) …. …. Q(xQ(xnn) ) ∀∀x Q(x) is the same as the disjunction x Q(x) is the same as the disjunction Q(xQ(x11) ) Q(xQ(x22) ) …. …. Q(xQ(xnn) )

∃∃x Q(x) is the same as the disjunctionx Q(x) is the same as the disjunction

Q(xQ(x11) ) Q(xQ(x22) ) …. …. Q(xQ(xnn)) ∃ ∃x Q(x) is the same as the conjunctionx Q(x) is the same as the conjunction

Q(xQ(x11) ) Q(xQ(x22) ) …. …. Q(xQ(xnn))

Page 73: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

73

Negating quantified expressionNegating quantified expression

Examples: what are the negation ofExamples: what are the negation of

∀∀x (xx (x22>x)>x)∃∃x (xx (x22=x)=x)

∀∀x (xx (x22>x)>x)∀∀x (xx (x22>x) >x) ∃∃x x (x(x22>x) >x) ∃∃x (xx (x22x) x)

∃∃x (xx (x22=x)=x)∃∃x (xx (x22=x) =x) ∀x ∀x (x(x22=x) =x) ∀x (x ∀x (x22x) x)

Page 74: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

74

Negating quantified expressionNegating quantified expression

Show thatShow that∀∀x [P(x) x [P(x) Q(x)] Q(x)] ∃∃x [P(x) x [P(x) Q(x)] Q(x)]

∀∀x [P(x) x [P(x) Q(x)] Q(x)] ∃∃x x [P(x) [P(x) Q(x)] Q(x)] ∃∃x x [[P(x) P(x) Q(x)] Q(x)] ∃∃x x [[ P(x) P(x) Q(x)]Q(x)] ∃∃x x [[P(x) P(x) Q(x)]Q(x)]

Page 75: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

75

Translating from English into Logical Translating from English into Logical ExpressionsExpressions

Express the statement Express the statement “Every student in the class “Every student in the class has studied calculus”has studied calculus” using predicates and using predicates and quantifiersquantifiers..

Rewrite the statement to identify the appreciate Rewrite the statement to identify the appreciate quantifiers to usequantifiers to use““For every student in the class,that student has For every student in the class,that student has studied calculus”studied calculus”Introduce the variable x Introduce the variable x ““For every student x in the class,x has studied For every student x in the class,x has studied calculus”calculus” introduce C(x) “x has studied calculus”introduce C(x) “x has studied calculus”∀∀x C(x)x C(x)The domain for x consists of the students in the The domain for x consists of the students in the classclass

Page 76: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

76

Translating from English into Logical Translating from English into Logical ExpressionsExpressions

If we change the domain to consists of peopleIf we change the domain to consists of people

““For every person x, if person x is a student in the For every person x, if person x is a student in the class,then x has studied calculus”class,then x has studied calculus”

C(x) “x has studied calculus”C(x) “x has studied calculus”S(x) “person x is a student in the class”S(x) “person x is a student in the class”

∀∀x (S(x) x (S(x) C(x)) C(x))

Note Note ∀x (S(x) ∀x (S(x) C(x)) is C(x)) is wrongwrongAll people are students in this class and All people are students in this class and have studied calculushave studied calculus

Page 77: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

77

Translating from English into Logical Translating from English into Logical ExpressionsExpressions

Express the statements Express the statements “some students in the “some students in the class has visited Cairo” , “every student in the class has visited Cairo” , “every student in the class has visited either Aswan or Cairo ”class has visited either Aswan or Cairo ” using using predicates and quantifierspredicates and quantifiers..

“ “some students in the class has visited Cairo”some students in the class has visited Cairo”some students ~ there is a student some students ~ there is a student C(x) “x has visited Cairo”C(x) “x has visited Cairo” ∃ ∃x C(x)x C(x)

“ “every student in the class has visited either every student in the class has visited either Aswan or Cairo ”Aswan or Cairo ”A(x) “x has visited Aswan ”A(x) “x has visited Aswan ” ∀ ∀x (C(x) x (C(x) A(x)) A(x))

Page 78: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

78

Translating from English into Logical Translating from English into Logical ExpressionsExpressions

System specificationsSystem specificationsExpress the statement Express the statement “Every mail message “Every mail message larger than one megabyte will be compressed” larger than one megabyte will be compressed” using predicates and quantifiersusing predicates and quantifiers..

S(m,y) “Mail message m is larger than y S(m,y) “Mail message m is larger than y megabyte” megabyte” Where m has the domain of all mail message Where m has the domain of all mail message y is a positive real numbery is a positive real numberC(m) “Mail message m will be compressed”C(m) “Mail message m will be compressed” ∀∀m (S(m,1) m (S(m,1) C(m)) C(m))

Page 79: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

79

Translating from English into Logical Translating from English into Logical ExpressionsExpressions

System specificationsSystem specificationsExpress the statement Express the statement “If a user is active, at “If a user is active, at least one network link will be available”least one network link will be available” using using predicates and quantifierspredicates and quantifiers..

A(u) “user u is active” A(u) “user u is active” Where u has the domain of all users Where u has the domain of all users S(n,x) “network link n is in state x” S(n,x) “network link n is in state x” Where n has the domain of all network linksWhere n has the domain of all network links x has the domain of all possible states x has the domain of all possible states for a network linkfor a network link

∃ ∃u A(u) u A(u) ∃n S(n, available) ∃n S(n, available)

Page 80: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

80

Chapter 1 ExercisesChapter 1 Exercises

Pages (46-50)Pages (46-50)1-41-45(a,d)5(a,d)8(b,c)8(b,c)101012(b,d,g)12(b,d,g)171720(e)20(e)21-2221-2224, 29, 31 ,3624, 29, 31 ,3640-4240-4243, 4843, 48

Page 81: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

81

Nested QuantifiersNested Quantifiers

Two quantifiers are nested if one is within Two quantifiers are nested if one is within the scope of the other.the scope of the other.

∀∀x∃y (x+y=0)x∃y (x+y=0)

Every thing within the scope of a quantifier Every thing within the scope of a quantifier can be thought as a propositional function.can be thought as a propositional function.For exampleFor example∀∀x Q(x)x Q(x)Q(x) is ∃y P(x,y)Q(x) is ∃y P(x,y)P(x,y) is (x+y=0)P(x,y) is (x+y=0)

Page 82: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

82

Nested QuantifiersNested Quantifiers

Translate into EnglishTranslate into English∀∀x∀y( (x>0) x∀y( (x>0) (y<0) (y<0) (xy<0)) (xy<0))The domain of both x and y are real The domain of both x and y are real number.number.

Thinking of quantification as a loopsThinking of quantification as a loops ∀ ∀x∀y P(x,y) ∀x ∃y P(x,y) x∀y P(x,y) ∀x ∃y P(x,y) For all xFor all x For all yFor all y P(x,y) all are true at least one is trueP(x,y) all are true at least one is true End for all y for all x and y in y loop and all xEnd for all y for all x and y in y loop and all xEnd for all xEnd for all x

Page 83: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

83

Nested QuantifiersNested Quantifiers

Thinking of quantification as a loopsThinking of quantification as a loops ∃∃x ∀y P(x,y)x ∀y P(x,y)For all yFor all y For all xFor all x P(x,y) at least one is true in x loop and all P(x,y) at least one is true in x loop and all yy End for all xEnd for all xEnd for all yEnd for all y

∃∃x∃y P(x,y)x∃y P(x,y)For all xFor all x For all yFor all y P(x,y) at least one is trueP(x,y) at least one is true End for all yEnd for all yEnd for all xEnd for all x

Page 84: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

84

Nested QuantifiersNested Quantifiers

The order of quantifiersThe order of quantifiers Suppose that the universe for x and y is {1, 2, 3}. Also, assume that P(x, y) is a predicate that istrue in the following cases, and false otherwise: P(1, 3), P(2, 1), P(2, 2), P(3, 1), P(3, 2), P(3, 3). Determinewhether each of the following is true or false: (a) ∀y∃x (xy ∧ P(x, y)). (b) ∀x∃y (xy ∧ ¬P(x, y)). (c) ∀y∃x (xy ∧¬P(x, y)).

trueFalse.False.

Page 85: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

85

Nested QuantifiersNested Quantifiers

Translate the following statements into Translate the following statements into logical expressionlogical expression

““the sum of two positive integers is always the sum of two positive integers is always positive”positive” ∀ ∀x∀y( (x>0) x∀y( (x>0) (y>0) (y>0) (x+y>0)) (x+y>0)) Or Or ∀∀x∀y(x+y>0), x∀y(x+y>0), where the domain of both x and y consists of all where the domain of both x and y consists of all positive integers.positive integers.

““every real number except zero has a every real number except zero has a multiplicative inverse”multiplicative inverse” ∀ ∀x ( (x x ( (x 0) 0) ∃y(xy=1))(xy=1))

Page 86: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

86

Nested QuantifiersNested Quantifiers

Translate the statements into EnglishTranslate the statements into English

∀ ∀xx((C(x) C(x) ∃y((C(y) C(y) F(x,y F(x,y) ) )))) where C(x) is “x has a computer” where C(x) is “x has a computer” F(x,yF(x,y) is “x and y are friends”) is “x and y are friends” the domain for both x and y consists of the domain for both x and y consists of all student in your school.all student in your school.

““for every student x in your school, x has a for every student x in your school, x has a computer or there is a student y such that y has a computer or there is a student y such that y has a computer and x and y are friends ”computer and x and y are friends ”

““every student in your school has a computer or every student in your school has a computer or has a friend who has a computer”has a friend who has a computer”

Page 87: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

87

Nested QuantifiersNested Quantifiers

Express the statement as logical expressionExpress the statement as logical expression (quantifiers, predicates, logical connectives) (quantifiers, predicates, logical connectives) the the domain consists of all people.domain consists of all people. “ “ if a person is male and is a parent, then this if a person is male and is a parent, then this person is someone’s father”person is someone’s father”∀∀xx( ( (M(x) (M(x) P(x)) (x)) ∃y F(x,yF(x,y) ) )) where M(x) is “x is male ” where M(x) is “x is male ” P(x) is “x is a parent”(x) is “x is a parent” F(x,yF(x,y) is “x is the father of y”) is “x is the father of y” Or ∀x Or ∀x ∃y ( ( (M(x) (M(x) P(x)) (x)) F(x,yF(x,y) ) ))

Page 88: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

88

Negating Nested Negating Nested QuantifiersQuantifiersNegate this statement( no negation Negate this statement( no negation

precedes a quantifier)precedes a quantifier)∀∀x ∃y (xy=1)x ∃y (xy=1)((∀x ∃y (xy=1)∀x ∃y (xy=1)))∃∃x x ∃y (xy=1)∃y (xy=1)∃∃x ∀y x ∀y (xy=1)(xy=1)∃∃x ∀y (xyx ∀y (xy1)1)

Page 89: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

89

Chapter 1 ExercisesChapter 1 Exercises

Pages (58-62)Pages (58-62)1144661111242426262929313139394545

Page 90: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

90

Rules of InferenceRules of Inference

Page 91: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

91

Rules of InferenceRules of Inference

An An argumentargument in Propositional logic is a in Propositional logic is a sequence of propositionssequence of propositions. All but the . All but the final proposition in the argument are final proposition in the argument are called called premisespremises and the final proposition and the final proposition is called the is called the conclusionconclusion..

“ “if you have a current password, if you have a current password, then you can log onto the network” then you can log onto the network”

premisespremises “ “you have a current password”you have a current password”Therefore,Therefore, “ “you can log onto the network” you can log onto the network”

conclusionconclusion

Page 92: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

92

Rules of InferenceRules of Inference

An An argument formargument form in Propositional logic is in Propositional logic is a a sequence of compound propositionssequence of compound propositions involving involving propositionalpropositional variablesvariables..

pp “ “if you have a current password, if you have a current password, then you can log onto the network” then you can log onto the network” qq “ “you have a current password”you have a current password”ThereforeTherefore,, “ “you can log onto the network”you can log onto the network” p p q q pp qq

Page 93: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

93

Rules of InferenceRules of Inference

Valid arguments in Propositional logicValid arguments in Propositional logic An An argumentargument is is validvalid if the truth of all its if the truth of all its

premisespremises implies that the implies that the conclusion conclusion isis truetrue..

If we have an If we have an argumentargument with premises p with premises p11, , pp22, p, p33, …………,p, …………,pnn and conclusion q and conclusion q

This This argumentargument is is validvalid when when(p(p1 1 p p2 2 p p3 3 ………… ………… p pnn) ) q is a q is a tautologytautology

Page 94: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

94

Rules of InferenceRules of Inference

We can use a truth table to show that an We can use a truth table to show that an argument form is valid. By showing that argument form is valid. By showing that whenever the whenever the premisespremises are are truetrue, the , the conclusionconclusion must also be must also be truetrue. . p p q q

pp qq

pp qq ppqq (p(pq) q) p p (p(p(p(pq)) q)) q

FF FF TT FF TT

FF TT TT FF TT

TT FF FF FF TT

TT TT TT TT TT

Page 95: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

95

Rules of InferenceRules of Inference

We can use a We can use a truth tabletruth table to show that an to show that an argument form is validargument form is valid. By showing that . By showing that whenever the premises are true, the whenever the premises are true, the conclusion must also be true.conclusion must also be true.

If an argument form involves If an argument form involves 1010 different different propositional variables, to use truth propositional variables, to use truth table, table, 221010=1024=1024 rowsrows are needed.This is are needed.This is a tedious(long and boring) approach.a tedious(long and boring) approach.

Page 96: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

96

Rules of InferenceRules of Inference

instead of using a instead of using a truth tabletruth table to show that to show that an argument form is valid, we cant use an argument form is valid, we cant use Rules of inferenceRules of inference. .

The The tautology tautology ((pp (p(pq))q))q is the basis of the rule of inference called Modus Modus PonensPonens ( or law of detachment- mode that affirms)p p q qpp

qqThe hypotheses are written in a column,

followed by horizontal bar,followed by the and theand the conclusion.conclusion.

Page 97: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

97

Rules of InferenceRules of Inference

Modus PonensModus Ponens ppp p q q

qqModus PonensModus Ponens tell us that if a conditional

statement and its hypothesis are both true, then the conclusion must also be conclusion must also be true.true.

Page 98: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

98

Rules of InferenceRules of Inference

Modus PonensModus Ponens conditional statement ““if you have a current password, if you have a current password, then you can log onto the network”then you can log onto the network”hypothesis “ “you have a current password”you have a current password” if if conditional statement and hypothesis

are truetrue

Then the Then the conclusionconclusion is is truetrue “ “you can log onto the network”you can log onto the network”

Page 99: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

99

Rules of InferenceRules of InferenceModus PonensModus Ponens (Example)

““if ,then “if ,then “

Determine whether the argument is Determine whether the argument is valid, and determine whether its valid, and determine whether its conclusion must be true because of the conclusion must be true because of the validity of the argument.validity of the argument.

Let Let pp be the proposition be the proposition and and qq be the proposition be the proposition the the premisespremises of the argument are of the argument are p p q q

andand p pand and its its conclusionconclusion is is qq..

Page 100: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

100

Rules of InferenceRules of InferenceModus PonensModus Ponens (Example)

““if ,then “if ,then “

the the premisespremises of the argument are of the argument are p p q q andand p p

and and its its conclusionconclusion is is qq..this argument is valid (it is constructed by this argument is valid (it is constructed by

usingusingModus ponens), a valid argument form.Modus ponens), a valid argument form.

The premise is false, therefore we The premise is false, therefore we can not conclude that the conclusion is can not conclude that the conclusion is true. true.

Conclusion is false. Conclusion is false.

Page 101: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

101

Rules of InferenceRules of Inference

Inference Rule – general formPattern establishing that if we know that a set of hypotheses are all true, then a certain related conclusion statement is true.

Hypothesis 1 Hypothesis 2 … conclusion “” means “therefore”

Page 102: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

102

Rules of InferenceRules of Inference

Inference Rule – general form

Each logical inference rule Each logical inference rule corresponds to an implication that is corresponds to an implication that is a tautology.a tautology.

Hypothesis 1 Hypothesis 1 Inference ruleInference rule Hypothesis 2 … Hypothesis 2 … conclusionconclusion

Corresponding tautology: Corresponding tautology: ((((Hypoth. 1Hypoth. 1) ) ( (Hypoth. 2Hypoth. 2) ) …) …) conclusionconclusion

Page 103: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

103

Rules of InferenceRules of Inference

Some Inference RulesSome Inference Rules

pp Rule of AdditionRule of Addition p pqq

““It is below freezing now. Therefore, it is It is below freezing now. Therefore, it is either below freezing or raining now.”either below freezing or raining now.”

ppqq Rule of SimplificationRule of Simplification p p

““It is below freezing and raining now. It is below freezing and raining now. Therefore, it is below freezing now.”Therefore, it is below freezing now.”

Page 104: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

104

Rules of InferenceRules of Inference

pp

qq

ppqq Rule of ConjunctionRule of Conjunction

““It is below freezing. It is raining now. It is below freezing. It is raining now.

Therefore, it is below freezing and it is Therefore, it is below freezing and it is raining now.”raining now.”

Page 105: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

105

Rules of InferenceRules of Inference

pp Rule of modus ponensRule of modus ponens ppqq (law of detachment- (law of detachment- qq the mode of affirmingthe mode of affirming))

““If it is snows today, then we will go If it is snows today, then we will go skiing” .skiing” .

““It is snowing today”. Therefore (or imply It is snowing today”. Therefore (or imply that) “We will go skiing”that) “We will go skiing”

qq ppqq Rule of modus tollensRule of modus tollens p p ((mode of denying)

Page 106: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

106

Rules of InferenceRules of Inference

p p q q Rule of disjunctiveRule of disjunctive pp syllsylloogismgism q q

ppqq Rule of hypotheticalRule of hypothetical qqrr syllogismsyllogism p prr

Page 107: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

107

Rules of InferenceRules of Inference

p p q q Rule of ResolutionRule of Resolution pp r r q q r r

Page 108: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

108

Rules of InferenceRules of Inference

Page 109: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

109

Rules of InferenceRules of Inference

ExamplesExamplesState which rule of inference is the basis State which rule of inference is the basis of the following argument:of the following argument:

“ “it is below freezing nowit is below freezing now (p)(p). Therefore, . Therefore, it is either below freezing or it is either below freezing or raining nowraining now (q)(q).”.”

this argument is of the formthis argument is of the form

pp

p p q q

This argument uses the This argument uses the additionaddition rule rule

Page 110: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

110

Rules of InferenceRules of Inference

ExamplesExamplesState which rule of inference is the basis State which rule of inference is the basis of the following argument:of the following argument:

“ “it is below freezing nowit is below freezing now(p) (p) and and raining raining nownow(q)(q) . Therefore, it is below freezing . Therefore, it is below freezing now.”now.”

this argument is of the formthis argument is of the form

p p qq

pp

This argument uses the This argument uses the simplificationsimplification rule rule

Page 111: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

111

Rules of InferenceRules of InferenceExamplesExamplesState which rule of inference is the basis State which rule of inference is the basis of the following argument:of the following argument:

if if it rains todayit rains today(p)(p), then , then we will not have we will not have a barbecue todaya barbecue today(q)(q). if we do not have a . if we do not have a barbecue today, then barbecue today, then we will have a we will have a barbecue tomorrowbarbecue tomorrow(r)(r) . Therefore, it is . Therefore, it is rains today,then we will have a barbecue rains today,then we will have a barbecue tomorrow.tomorrow. this argument is of the form p this argument is of the form p q q q q r r p p r rThis argument uses the This argument uses the hypotheticalhypothetical syllogismsyllogism rule rule

Page 112: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

112

Using Rules of Inference to Build Using Rules of Inference to Build ArgumentsArguments A formal proof of a conclusion C, given premises p1, p2,…,pn consists of a sequence of steps, each of which applies some inference rule to premises or to previously-proven statements (as hypotheses) to yield a new true statement (the conclusion).

•A proof demonstrates that if the premises are true, then the conclusion is true (i.e., valid argument).

Page 113: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

113

Using Rules of Inference to Build Using Rules of Inference to Build ArgumentsArguments Example:

Show that the hypothesesShow that the hypotheses

““It is not sunny and It is not sunny and it is coldit is cold (q)(q).”.”““we will swimwe will swim (r)(r) only if only if it is sunnyit is sunny (p)(p), , “If we do not swim, then “If we do not swim, then we will canoewe will canoe(s)(s).”.”“If we canoe, then “If we canoe, then we will be home we will be home earlyearly(t)(t).”.”

Leads to the conclusionLeads to the conclusion “We will be home early” “We will be home early” tt

p p q , r q , r p, p, r r s, s s, s t t

Page 114: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

114

Using Rules of Inference to Build Using Rules of Inference to Build ArgumentsArguments Example: (we can use the truth table)PremisesPremises p p q , r q , r p, p, r r s, s s, s t tConclusionConclusion t t

Step ReasonStep Reason1.1. p p q Hypothesis q Hypothesis2.2. p p Simplification using (1)Simplification using (1)3.3. r r p Hypothesis p Hypothesis 4.4. r Modus r Modus Tollens using (2) (3)Tollens using (2) (3)5.5. r r s Hypothesis s Hypothesis 6.6. s Modus s Modus ponens using (4) (5)ponens using (4) (5) 7.7. s s t Hypothesis t Hypothesis 8.8. t Modus t Modus ponens using (6) (7)ponens using (6) (7)

Page 115: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

115

Common FallaciesCommon FallaciesIs this argument is valid?Is this argument is valid?If you do every problem in this book, then you will If you do every problem in this book, then you will learn discrete mathematicslearn discrete mathematics(q)(q). You learned . You learned discrete mathematics.” Therefore, discrete mathematics.” Therefore, you did every you did every problem in this bookproblem in this book(p)(p)..

this argument is of the formthis argument is of the formppq and q then p . This is an example of an q and q then p . This is an example of an incorrect argument using the incorrect argument using the Fallacy of affirming Fallacy of affirming the conclusion:the conclusion:ppq and q does not imply pq and q does not imply p

The proposition The proposition [[(p(pq)q)q)q)p] is not a tautology tautology (its false if p is F and q is T) (its false if p is F and q is T) You can learn discrete mathematics in some way You can learn discrete mathematics in some way other than doing every problem in this book (by other than doing every problem in this book (by reading- listening to lectures-doing some(but not reading- listening to lectures-doing some(but not all) the problems in this book )all) the problems in this book )

Page 116: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

116

Common FallaciesCommon Fallacies

Is this argument is valid?Is this argument is valid?If If you do every problem in this bookyou do every problem in this book(p)(p), then you , then you will will learn discrete mathematicslearn discrete mathematics(q)(q). you did not do . you did not do every problem in this book. Therefore, You did not every problem in this book. Therefore, You did not learn learn discrete mathematics.”discrete mathematics.”this argument is of the formthis argument is of the form

ppq and q and pp imply imply qq . This is an example of an . This is an example of an incorrect argument using the incorrect argument using the Fallacy of denying the Fallacy of denying the hypothesis :hypothesis : ppq and q and p does not imply p does not imply q qThe proposition The proposition [[(p(pq)q)p)p)qq] is not a tautology tautology (its false if p is F and q is T)(its false if p is F and q is T)It is possible that you learned discrete even you It is possible that you learned discrete even you did not did not do every problem in this bookdo every problem in this book

Page 117: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

117

Common FallaciesCommon Fallacies

• A A fallacyfallacy is an inference rule or other is an inference rule or other proof method that is proof method that is not logically validnot logically valid..– May yield a false conclusionMay yield a false conclusion!!

• Fallacy of affirming the conclusionFallacy of affirming the conclusion::– ““ppq is true, and q is true, so p must q is true, and q is true, so p must

be true.” (No, because Fbe true.” (No, because FT is true.)T is true.)• Fallacy of denying the hypothesisFallacy of denying the hypothesis::

– ““ppq is true, and p is false, so q must q is true, and p is false, so q must be false.” (No, again because Fbe false.” (No, again because FT is T is true.)true.)

Page 118: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

118

Inference Rules for QuantifiersInference Rules for Quantifiers

Universal instantiationUniversal instantiation

x P(x)x P(x)P(c)P(c) (substitute any object (substitute any object c)c)

We can conclude that P(c) is true, We can conclude that P(c) is true, where c is a particular member of where c is a particular member of the domain, if we know that the domain, if we know that x P(x) x P(x) is true.is true.

ExampleExample

““all students have internet account”all students have internet account”

““Ahmed has internet account”Ahmed has internet account”Where, Ahmed is a member of the Where, Ahmed is a member of the

domaindomainOf all students Of all students

Page 119: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

119

Inference Rules for QuantifiersInference Rules for Quantifiers

• Existential instantiationExistential instantiation

x P(x)x P(x)

P(c)P(c) (for some element c)(for some element c)

We can conclude that there is an We can conclude that there is an element c in the domain for which element c in the domain for which P(c) is true, if we know that P(c) is true, if we know that x P(x)x P(x) is true.is true.

Page 120: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

120

Inference Rules for QuantifiersInference Rules for Quantifiers

• Universal generalizationUniversal generalization

• P(c)P(c) (for an arbitrary c) (for an arbitrary c)x P(x)x P(x)

• Existential generalizationExistential generalization

• P(c)P(c) (for some element c ) (for some element c )

x P(x)x P(x)

Page 121: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

121

Inference Rules for QuantifiersInference Rules for Quantifiers

Show that the premisesShow that the premises “ “Everyone in this Everyone in this discrete math class has taken a course in discrete math class has taken a course in computer science” computer science” andand “Ali is a student in this “Ali is a student in this class” class” imply the conclusionimply the conclusion “Ali has taken a “Ali has taken a course in computer science”course in computer science”

D(x): “x is in discrete math class”D(x): “x is in discrete math class”C(x): “x has taken a course in computer science”C(x): “x has taken a course in computer science” x (D(x) x (D(x) C(x)) C(x)) Premise #1 Premise #1 D(Ali)D(Ali) Premise #2 Premise #2 C(Ali)C(Ali)Step ReasonStep Reason1. 1. x (D(x) x (D(x) C(x)) Premise #1 C(x)) Premise #12. D(2. D(AliAli) ) C( C(AliAli)) Univ. instantiation. Univ. instantiation.3. D(3. D(AliAli)) Premise #2. Premise #2.4. C(4. C(AliAli)) Modus ponens on 2,3. Modus ponens on 2,3.

Page 122: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

122

Inference Rules for QuantifiersInference Rules for Quantifiers

Show that the premises Show that the premises “A student in this class “A student in this class has not read the book” has not read the book” andand “Everyone in this “Everyone in this class passed the first exam” class passed the first exam” imply the conclusionimply the conclusion “Someone who passed the first exam has not read “Someone who passed the first exam has not read the book”the book”

C(x): “x is in this class” C(x): “x is in this class” x(C(x) x(C(x) B(x))B(x)) B(x): “x has read the book” B(x): “x has read the book” x (C(x) x (C(x) P(x)) P(x)) P(x): “x passed the first exam” P(x): “x passed the first exam” x(P(x) x(P(x) B(x))B(x))Step ReasonStep Reason 1. 1. xx(C(x)(C(x) B(x))B(x)) Premise #1.Premise #1.2. C(a) 2. C(a) B(a) B(a) Exist. instantiation.Exist. instantiation.3. C(a)3. C(a) Simplification on 2.Simplification on 2.4. 4. xx (C(x) (C(x) P(x)) P(x)) Premise #2.Premise #2.5. C(a) 5. C(a) P(a) P(a) Univ. instantiation. Univ. instantiation.6. P(a)6. P(a) Modus ponens on 3,5 Modus ponens on 3,57. 7. B(a) B(a) Simplification on 28. P(a) B(a) B(a) Conjunction on 6,7 Conjunction on 6,79. 9. x(x(P(x)P(x) B(x))B(x)) Exist. generalizationExist. generalization

Page 123: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

123

Combining Rules of Inference for Combining Rules of Inference for Propositions and Quantified Propositions and Quantified StatementsStatements

Universal Modus Ponens Inference RuleUniversal Modus Ponens Inference Rule x (P(x) x (P(x) Q(x)) Q(x)) P(a)P(a) Q(a) Q(a)

Universal Modus Tollens Inference RuleUniversal Modus Tollens Inference Rule

x (P(x) x (P(x) Q(x)) Q(x)) Q(a) Q(a) P(a)P(a)

WhereWhere a a is a particular element in the domainis a particular element in the domain

Page 124: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

124

Combining Rules of Inference for Combining Rules of Inference for Propositions and Quantified Propositions and Quantified StatementsStatements

Assume thatAssume that “For all positive integers “For all positive integers nn, if , if n is greater than 4, then nn is greater than 4, then n22 is less than 2 is less than 2nn” ” is true.is true.Use universal modus ponens to show thatUse universal modus ponens to show that 10010022 < 2 < 2100100 P(n) denote “n>4”P(n) denote “n>4”Q(n) denote “nQ(n) denote “n2 2 < 2< 2nn” ” n (P(n) n (P(n) Q(n)) Q(n)) P(100) is true, because 100>4P(100) is true, because 100>4It follows by universal modus ponens thatIt follows by universal modus ponens that Q(n) is true, this means that nQ(n) is true, this means that n2 2 < 2< 2n n is trueis true10010022 < 2 < 2100 100 is trueis true

Page 125: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

125

ExercisesExercises

pp(72-74)pp(72-74)1-31-36-96-912-1312-13151517-1917-1924-2524-25272729293333

Page 126: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

126

Introduction to ProofsIntroduction to Proofs

Some terminologySome terminology

TheoremTheorem Is a statement that can be shown to be Is a statement that can be shown to be true.true.

AxiomsAxioms (postulates) (postulates) Statements that used in a proof and are Statements that used in a proof and are assumed to be true.assumed to be true.

Page 127: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

127

Proof MethodsProof Methods

Proving pProving pqqDirect proofDirect proof: Assume p is true, and prove : Assume p is true, and prove q.q.Indirect proofIndirect proof: Assume : Assume q, and prove q, and prove p.p.Trivial proofTrivial proof: Prove q true.: Prove q true.Vacuous proofVacuous proof: Prove : Prove p is true.p is true.

Page 128: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

128

Proof Methods (Proof Methods (Direct proofDirect proof))

Proving pProving pq q Direct proofDirect proof: Assume p is true, and : Assume p is true, and prove qprove q

DefinitionDefinition: : The integer n is The integer n is eveneven if there exists if there exists an integer k such that an integer k such that n=2kn=2k, and n is , and n is oddodd if there if there exists an integer k such that exists an integer k such that n=2k+1n=2k+1.. AxiomAxiom: : Every integer is either odd or even.Every integer is either odd or even.

TheoremTheorem: : (For all numbers n) If n is an odd (For all numbers n) If n is an odd integer, then ninteger, then n22 is an odd integer. is an odd integer.

ProofProof: : If n is odd, then n = 2k+1 for some integer k. If n is odd, then n = 2k+1 for some integer k. Thus, nThus, n22 = (2k+1) = (2k+1)22 = 4k = 4k22 + 4k + 1 = 2(2k + 4k + 1 = 2(2k22 + 2k) + + 2k) + 1. 1. Therefore nTherefore n22 is of the form 2j + 1 (with j the is of the form 2j + 1 (with j the integer 2kinteger 2k22 + 2k), thus n + 2k), thus n22 is odd. is odd.

Page 129: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

129

Proof Methods (Proof Methods (Direct proofDirect proof))

Proving pProving pq q Direct proofDirect proof: Assume p is true, and : Assume p is true, and prove qprove qDirect proofs lead from the hypothesis of a Direct proofs lead from the hypothesis of a theorem to the conclusion.theorem to the conclusion.They begin with the premises, continue with a They begin with the premises, continue with a sequence of deductions, and ends with the sequence of deductions, and ends with the conclusion. conclusion. A direct proof often reach dead ends.A direct proof often reach dead ends.

ExampleExampleProve thatProve that if n is an integer and 3n+2 is odd, if n is an integer and 3n+2 is odd, then n is odd.then n is odd.

We assume that 3n+2 is an odd integerWe assume that 3n+2 is an odd integerThis mean that 3n+2=2k+1This mean that 3n+2=2k+1There is no direct way to proof that n is odd There is no direct way to proof that n is odd integerinteger

Page 130: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

130

Proof Methods (Proof Methods (Indirect proofIndirect proof))

Proving pProving pq q Indirect proof(Indirect proof(proof by contrapositionproof by contraposition)): Assume : Assume q, and prove q, and prove p. p. Contraposition (Contraposition (ppq q q q pp))ExampleExampleProve thatProve that if n is an integer and 3n+2 is odd, if n is an integer and 3n+2 is odd, then n is odd.then n is odd.ProofProof:: Suppose that the conclusion is false,Suppose that the conclusion is false,i.e.i.e., that , that nn is is eveneven. . Then Then nn=2=2kk for some integer for some integer kk. . Then 3Then 3nn+2 = 3(2+2 = 3(2kk)+2 = 6)+2 = 6kk+2 = 2(3+2 = 2(3kk+1). Thus +1). Thus 33nn+2+2 is is eveneven, because it equals 2, because it equals 2jj for integer for integer jj = = 33kk+1. +1. So So 33nn+2+2 is is not oddnot odd. . We have shown that ¬(We have shown that ¬(nn is odd)→¬(3 is odd)→¬(3nn+2 is odd), +2 is odd), thus its contraposition (3thus its contraposition (3nn+2 is odd) → (+2 is odd) → (nn is odd) is odd) is also true.is also true.

Page 131: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

131

Proof Methods (Proof Methods (Indirect proofIndirect proof))

Proving pProving pq q Indirect proof(Indirect proof(proof by contrapositionproof by contraposition)): Assume : Assume q, and prove q, and prove p is true. p is true. Contraposition (Contraposition (ppq q q q pp))

ExampleExample Prove that if n=ab, where a and b Prove that if n=ab, where a and b are positive integers, then a are positive integers, then a (n) (n)1/21/2 or b or b (n)(n)1/21/2

We assume that We assume that a a (n) (n)1/21/2 b b (n) (n)1/21/2 is false is falseThis implies that both a This implies that both a (n) (n)1/21/2 and b and b (n) (n)1/2 1/2 are are falsefalseThis implies that a > (n)This implies that a > (n)1/21/2 and b > (n) and b > (n)1/2 1/2

This implies that ab> (n)This implies that ab> (n)1/21/2 (n) (n)1/2 1/2

Then Then ab>nab>nThis show that abThis show that abn the theorem is provedn the theorem is proved

Page 132: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

132

Proof Methods (Proof Methods (Vacuous proofVacuous proof))

Proving pProving pq q Vacuous proofVacuous proof: Prove : Prove p is true.p is true.

ExamplesExamples

TheoremTheorem: (For all : (For all nn) If ) If nn is both odd and is both odd and even, then even, then nn22 = = nn + + nn..

ProofProof: The statement “: The statement “nn is both odd and is both odd and even” is necessarily false, since no number even” is necessarily false, since no number can be both odd and even. So, the can be both odd and even. So, the theorem is vacuously true. theorem is vacuously true.

Page 133: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

133

Proof Methods (Proof Methods (Trivial proofTrivial proof))

Proving pProving pq q Trivial proofTrivial proof: Prove q true.: Prove q true.

ExamplesExamples

TheoremTheorem: (For integers n) If n is the sum : (For integers n) If n is the sum of two prime numbers, then either n is odd of two prime numbers, then either n is odd or n is even.or n is even.

ProofProof: Any integer n is either odd or even. : Any integer n is either odd or even. So the conclusion of the implication is true So the conclusion of the implication is true regardless of the truth of the hypothesis. regardless of the truth of the hypothesis.

Thus the implication is true trivially. Thus the implication is true trivially.

Page 134: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

134

Proof Methods (Proof Methods (ExampleExample))

DefinitionDefinition: The real number r is rational if there : The real number r is rational if there exist integers p and q with q≠0 such that r=p/q. A exist integers p and q with q≠0 such that r=p/q. A real number that is not rational is called real number that is not rational is called irrational.irrational.

TheoremTheorem: Prove that the sum of two rational : Prove that the sum of two rational numbers is rational.numbers is rational.

ProofProof: assume that r and s are rational numbers : assume that r and s are rational numbers

r=p/q and s=t/u where p,q,t,u are integers and r=p/q and s=t/u where p,q,t,u are integers and p≠0, u≠0 p≠0, u≠0

r+s=(p/q)+(t/u) = (pu+qt)/(qu)r+s=(p/q)+(t/u) = (pu+qt)/(qu)Because p≠0 and u≠0 , then qu≠0 Because p≠0 and u≠0 , then qu≠0 Both (pu+qt) and (qu) are integersBoth (pu+qt) and (qu) are integersThen the theorem is proved Then the theorem is proved

Note that :Our attempt to find direct proof Note that :Our attempt to find direct proof succeeded.succeeded.

Page 135: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

135

Proof Methods (Proof Methods (Proof by Contradiction))

•Proving p Proving p is trueis trueAssume we can find a Assume we can find a contradictioncontradiction qq such that such that

((ppq) is true. q) is true.

Because q is false and (Because q is false and (ppq) is true, we can q) is true, we can conclude that conclude that p is false, which means that p is p is false, which means that p is true.true.

p, and prove that p, and prove that pp (r (r r)r)

(r (r r) is a trivial contradiction, equal to Fr) is a trivial contradiction, equal to F

Thus Thus ppF is true only if F is true only if p=Fp=F

P is trueP is true

Page 136: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

136

Proof Methods (Proof Methods (Proof by Contradiction))

ExampleExample

Give a proof by contradiction of the theorem “if Give a proof by contradiction of the theorem “if 3n+2 is odd, then n is odd”3n+2 is odd, then n is odd”

ProofProofLet p be “3n+2 is odd“ and q be “n is odd“Let p be “3n+2 is odd“ and q be “n is odd“We assume that both p and We assume that both p and q are trueq are trueq “n is even“q “n is even“3n+2=3(2k)+2=6k+2=2(3k+2)=2t even 3n+2=3(2k)+2=6k+2=2(3k+2)=2t even this means p is false (this means p is false (p is true)p is true)But we assume that both p and But we assume that both p and q are trueq are trueThen we have a contradictionThen we have a contradiction

3n+2 is odd (p) and n is even 3n+2 is odd (p) and n is even assumptionassumption3n+2 is even (3n+2 is even (p) p) conclusionconclusion The “if 3n+2 is odd, then n is odd” is trueThe “if 3n+2 is odd, then n is odd” is true

Page 137: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

137

ExercisesExercises

pp(85)pp(85)

1-31-3

5-65-6

16-1816-18

Page 138: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

138

Proof Methods and StrategyProof Methods and Strategy

•Exhaustive proof and proof by casesExhaustive proof and proof by cases

Sometimes we cannot prove a theorem using a Sometimes we cannot prove a theorem using a single argument that holds for all possible cases. single argument that holds for all possible cases. In this situation we consider each case separately.In this situation we consider each case separately.To proveTo prove (p(p11 p p22 pp33 ……… ……… ppnn) ) q qThe following The following tautologytautology can be used as a rule of can be used as a rule of inference:inference:[(p[(p11pp22pp33……ppnn))q] q] [(p [(p11qq))((pp22qq))((pp33qq))…… ((ppnnqq))]]So we need to proveSo we need to prove(p(p1 1 q q)) ((pp2 2 q q) ) ((pp3 3 q q) ) ……… ……… ( (ppn n q q))This argument is called a This argument is called a proof by casesproof by cases

Some theorem can be proved by examining a Some theorem can be proved by examining a relatively small number of examples, such proof is relatively small number of examples, such proof is called called exhaustive proofexhaustive proof(special type of proof by (special type of proof by cases)cases)

Page 139: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

139

Proof Methods and StrategyProof Methods and Strategy

Exhaustive proof Exhaustive proof (example)(example)• Disproof that Disproof that (n+1)(n+1)22 3 3n n if n is a positive integerif n is a positive integer

with nwith n4 4

For For n=1n=1 : (n+1) : (n+1)22 = (1+1) = (1+1)22 = 2 = 222 = =44 and 3 and 3n n = 3= 311 = =3 3 (T)(T)

For For n=2n=2 : (n+1) : (n+1)22 = (2+1) = (2+1)22 = 3 = 322 = =99 and 3 and 3n n = 3= 322 = =9 9 (T)(T)

For For n=3n=3 : (n+1) : (n+1)22 = (3+1) = (3+1)22 = 4 = 422 = =1616 and 3 and 3n n = 3= 333 = =27 27 (F)(F)

For For n=4n=4 : (n+1) : (n+1)22 = (4+1) = (4+1)22 = 5 = 522 = =2525 and 3 and 3n n = 3= 344 = =81 81 (F)(F)

(n+1)(n+1)22 3 3n n if n is a positive integer with nif n is a positive integer with n4 is 4 is falsefalse

Page 140: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

140

Proof Methods and StrategyProof Methods and StrategyProof by cases Proof by cases (example)(example)• Proof that Proof that if n is an integer, then nif n is an integer, then n22 n n

To proof that nTo proof that n22 n for every integer, we will n for every integer, we will consider three cases:consider three cases:

Case 1: n=0 Case 1: n=0 0 022=0, we see that 0=0, we see that 022 0. 0.

It follows that nIt follows that n22 n is true in this n is true in this case. case.

Case 2: n Case 2: n 1 1 multiply both sides of the multiply both sides of the inequality n inequality n 1 1

by n we have n.n by n we have n.n 1.n = n 1.n = n22 n n

It follows that nIt follows that n22 n is true in this n is true in this case. case.

Case 3: n Case 3: n -1 -1 However n However n22 0, it implies n 0, it implies n22 n n

Because the inequality nBecause the inequality n22 n holds for all cases, n holds for all cases, we can conclude that if n is an integer, then nwe can conclude that if n is an integer, then n22 n n

Page 141: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

141

Proof Methods and StrategyProof Methods and Strategy

Proof by cases Proof by cases (example)(example)• Prove that the following is true for all real numbers x and y: |xy|= |x| |y|

The The absolute value functionabsolute value function |a| |a| |a| = |a| = aa if if a ≥ 0a ≥ 0 ==-a-a if if a a << 0 0

Case 1: (Case 1: (bothboth x and y are x and y are ≥ 0≥ 0 )) Case 2: (Case 2: (x ≥ 0x ≥ 0 and and y y << 0 0 ))Case 3: (Case 3: (x x << 0 0 and and y ≥ 0y ≥ 0 ))Case 4: (Case 4: (bothboth x and y are x and y are << 0 0 ))

Page 142: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

142

Proof Methods and StrategyProof Methods and Strategy

Proof by cases Proof by cases (example)(example)• Prove that the following is true for all real numbers x and y: max(x, y) = 0.5 (x + y + |x − y|)The absolute value function is used in this The absolute value function is used in this equation, its value depends on whether the equation, its value depends on whether the number is negative or nonnegative. two cases are number is negative or nonnegative. two cases are considered:considered:Case 1: (Case 1: (x −y x −y << 0 0)) this means this means (x (x << y) y) 0.5(x + y + |x − y|) = 0.5(x + y − (x − y)) 0.5(x + y + |x − y|) = 0.5(x + y − (x − y)) = 0.5(x + y + y − x) = 0.5(2y) = y.= 0.5(x + y + y − x) = 0.5(2y) = y.But if x But if x < < y, then we also have max(x, y) = y.y, then we also have max(x, y) = y.Case 2: (Case 2: (x − y ≥ 0 x − y ≥ 0 )) this means this means (x ≥ y)(x ≥ y)0.5(x + y + |x − y|) =0.5(x + y + (x − y)) 0.5(x + y + |x − y|) =0.5(x + y + (x − y)) =0.5(x + y + x − y) = 0.5(2x) = x.=0.5(x + y + x − y) = 0.5(2x) = x.But if But if x ≥ yx ≥ y, then we also have max(, then we also have max(x, yx, y) = ) = xx..Thus, in both cases we have Thus, in both cases we have max(x, y) = 0.5 (x + y + |x − y|)

Page 143: Dr. Eng. Farag Elnagahy farahelnagahy@hotmail Office Phone: 67967

143

ExercisesExercisespp(102-103)pp(102-103)

11

3-53-5


Recommended