discrete mathematics for computer science prof. raissa d’souza

47
B P M /92 Module #1 - Logic B P M /92 Module #1 - Logic UC Davis ECS20, Winter 2017 Discrete Mathematics for Computer Science Prof. Raissa D’Souza (slides adopted from Michael Frank and Haluk Bingöl)

Upload: others

Post on 10-Dec-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

UCDavisECS20,Winter2017DiscreteMathematicsforComputerScience

Prof.RaissaD’Souza(slidesadoptedfromMichaelFrankandHalukBingöl)

Page 2: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

FoundationsofLogic:Overview

• Proposi'onallogic(§1.1-1.2):– Basicdefini'ons.(§1.1)– Equivalencerules&deriva'ons.(§1.2)

• Predicatelogic(§1.3-1.4)– Predicates.– Quan'fiedpredicateexpressions.– Equivalences&deriva'ons.

Page 3: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

DePinitionofaProposition• Defini&on:Aproposi&on(denotedp,q,r,…)issimply:• Adeclara&vestatementwithsomedefinitemeaning,(notvagueorambiguous)

• havingatruthvaluethatiseithertrue(T)orfalse(F)•  itisneverboth,neither,orsomewhere“inbetween”

•  However,youmightnotknowtheactualtruthvalue,•  and,thetruthvaluemightdependonthesitua'onorcontext.

•  Algebra,mathema'csexpressedintermsofunknownvariableslikexandnareNOTproposi'ons:(predicatelogicnexttopic)

•  X+10=30•  1024>2n

Topic #1 – Propositional Logic

Page 4: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Example–Arethesestatementspropositions?• p=“Thisstatementistrue”(assertp=T)

•  Yesaproposi'on;consistentT/Fassignment•  Ifp=Tthenstatementistrue•  Ifp=Fthen¬pandthestatementisnottrue

• p=“Thisstatementisfalse”(assertp=F)

• No,notaproposi&on;cannotassignTorF•  Ifp=Fthen,infact,p=T•  Ifp=Tthen,infact,p=F

(Recall,aproposi&oncannotbebothTandF,orpartway)Thecompoundproposi&onp∧¬pisF

Page 5: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

SomePopularBooleanOperators

Formal Name Nickname Arity Symbol

Negation operator NOT Unary ¬

Conjunction operator AND Binary ∧

Disjunction operator OR Binary ∨

Exclusive-OR operator XOR Binary ⊕

Implication operator IMPLIES Binary →

Biconditional operator IFF Binary ↔

Topic #1.0 – Propositional Logic: Operators

Page 6: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Truthtables

•  To evaluate the T or F status of a compound proposition

•  Enumerate over all T and F combinations of all the propositions

Page 7: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

p ¬p T F F T

p q p∧q F F F F T F T F F T T T

p q p∨qF F FF T TT F TT T T

Page 8: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

NestedPropositionalExpressions•  Useparenthesestogroupsub-expressions:“Ijustsawmyoldfriend,andeitherhe’sgrownorI’veshrunk.”

•  First break it down into propositions: •  f = “Ijustsawmyoldfriend”•  g = “he’s grown” •  s = “I’ve shrunk”

•  =f∧(g∨s)•  (f∧g)∨swouldmeansomethingdifferent•  f∧g∨swouldbeambiguous

•  Byconven'on,“¬”takesprecedenceoverboth“∧”and“∨”.•  ¬s∧fmeans(¬s)∧f,not¬(s∧f)

Topic #1.0 – Propositional Logic: Operators

Page 9: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

ASimpleExercise•  Letp=“Itrainedlastnight”,q=“Thesprinklerscameonlastnight,”r=“Thelawnwaswetthismorning.”

•  TranslateeachofthefollowingintoEnglish:•  ¬p=•  r∧¬p=•  ¬r∨p∨q=

Topic #1.0 – Propositional Logic: Operators

Page 10: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

TheExclusiveOrOperator•  Thebinaryexclusive-oroperator“⊕”(XOR)combinestwoproposi'onstoformtheirlogical“exclusiveor”(exclusivedisjunc'on)

•  p=“IwillearnanAinthiscourse,”•  q=“Iwilldropthiscourse,”•  p⊕q=“IwilleitherearnanAinthiscourse,orIwilldropit(butnotboth!)”

•  A more common phrase: “Your entrée comes with either soup of salad”

Topic #1.0 – Propositional Logic: Operators

Page 11: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Exclusive-OrTruthTable

• Notethatp⊕qmeansthatpistrue,orqistrue,butnotboth!

•  Thisopera'oniscalledexclusiveor,becauseitexcludesthepossibilitythatbothpandqaretrue.

• Remark.“¬”and“⊕”togetherarenotuniversal.

p q p⊕qF F FF T TT F TT T F Note

difference from OR.

Topic #1.0 – Propositional Logic: Operators

Page 12: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

NaturalLanguageisAmbiguous

• NotethatEnglish“or”canbeambiguousregardingthe“both”case!

• “PatisasingerorPatisawriter.”-

• “PatisaliveorPatisdeceased.”-

• Needcontexttodisambiguatethemeaning!•  Forthisclass,assume“or”meansinclusive.

p q p "or" qF F FF T TT F TT T ?

Topic #1.0 – Propositional Logic: Operators

Page 13: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

TheImplicationOperator

•  Theimplica&onp→qstatesthatpimpliesq.

•  i.e.,Ifpistrue,thenqistrue;butifpisnottrue,thenqcouldbeeithertrueorfalse.

•  E.g.,letp=“YoumasterECS20.”q=“Youwillgetagoodjob.”

•  p→q=“IfyoumasterECS20,thenyouwillgetagoodjob.”

(else,itcouldgoeitherway;somegreatjobsdonotrequirediscretemath)

Let’sbuildthetruthtableforp→q

Topic #1.0 – Propositional Logic: Operators

antecedent consequent

Page 14: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

ImplicationTruthTable• p→qisfalseonlywhenpistruebutqisnottrue.

• p→qdoesnotsaythatpcausesq!

• p→qdoesnotrequirethatporqareevertrue!

•  E.g.“(1=0)→pigscanfly”isTRUE!

p q p→q F F T F T T T F F T T T

The only False case!

Topic #1.0 – Propositional Logic: Operators

Page 15: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

ExamplesofImplications• “Ifthislectureeverends,thenthesunwillrisetomorrow.” TrueorFalse?

• “IfTuesdayisadayoftheweek,thenIamapenguin.” TrueorFalse?

• “If1+1=6,thenBushispresident.”TrueorFalse?

• “Ifthemoonismadeofgreencheese,thenIamricherthanBillGates.” TrueorFalse?

Topic #1.0 – Propositional Logic: Operators

Page 16: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

ExamplesofImplications• “Ifthislectureeverends,thenthesunwillrisetomorrow.” TrueorFalse?

• “IfTuesdayisadayoftheweek,thenIamapenguin.” TrueorFalse?

• “If1+1=6,thenBushispresident.”TrueorFalse?

• “Ifthemoonismadeofgreencheese,thenIamricherthanBillGates.” TrueorFalse?

Topic #1.0 – Propositional Logic: Operators

Page 17: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Whydoesthisseemwrong?• Considerasentencelike,

• “IfIweararedshirttomorrow,thenglobalpeacewillprevail”

•  Inlogic,weconsiderthesentenceTruesolongaseitherIdon’tweararedshirt,orglobalpeaceisnotachieved.

• But,innormalEnglishconversa'on,ifIweretomakethisclaim,youwouldthinkthatIwascrazy.• Whythisdiscrepancybetweenlogic&language?

•  Logicisaboutconsistency.

Page 18: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

EnglishPhrasesMeaningp→q• “pimpliesq”• “ifp,thenq”• “ifp,q”• “whenp,q”• “wheneverp,q”• “qifp”• “qwhenp”• “qwheneverp”

• “ponlyifq”• “pissufficientforq”• “qisnecessaryforp”• “qfollowsfromp”• “qisimpliedbyp”

• Wewillseesomeequivalentlogicexpressionslater.

Topic #1.0 – Propositional Logic: Operators

Page 19: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Converse,Inverse,Contrapositive

•  Someterminology,foranimplica'onp→q:•  Itsconverseis: q→p.•  Itsinverseis: ¬p→¬q.•  Itscontraposi&ve: ¬q→¬p.• Oneofthesethreehasthesamemeaning(sametruthtable)asp→q.Canyoufigureoutwhich?

(Let’sworkitoutontheboard).

Topic #1.0 – Propositional Logic: Operators

Page 20: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

• Provingtheequivalenceofp→qanditscontraposi'veusingtruthtables:

p q ¬q ¬p p→q ¬q →¬pF F T T T TF T F T T TT F T F F FT T F F T T

Topic #1.0 – Propositional Logic: Operators

Page 21: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Thebiconditionaloperator

• Thebicondi&onalp↔qstatesthatp→qandq→p• Inotherwords,pistrueifandonlyif(IFF)qistrue.• p=“Clintonwinsthe2016elec'on.”• q=“Clintonwillbepresidentforallof2017.”• p↔q=“If,andonlyif,Clintonwinsthe2016elec'on,Clintonwillbepresidentforallof2017.”

Topic #1.0 – Propositional Logic: Operators

Page 22: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

BiconditionalTruthTable

• p↔qmeansthatpandqhavethesametruthvalue.

• Remark.Thistruthtableistheexactoppositeof⊕’s!•  Thus,p↔qmeans¬(p⊕q)

• p↔qdoesnotimplythatpandqaretrue,orthateitherofthemcausestheother,orthattheyhaveacommoncause.

p q p ↔ qF F TF T FT F FT T T

Topic #1.0 – Propositional Logic: Operators

Page 23: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

BooleanOperationsSummary

Orderofopera'on:¬,^,∨,⊕,→,↔i.e.,pV¬q→p^qmeans(pV(¬q))→(p^q)(Note,precedenceof∨,⊕isambiguousandoRendependsontheprogramminglanguage)

p q ¬p p∧q p∨q p⊕q p→q p↔qF F T F F F T TF T T F T T T FT F F F T T F FT T F T T F T T

Topic #1.0 – Propositional Logic: Operators

Page 24: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

SomeAlternativeNotations

Name: not and or xor implies iffPropositional logic: ¬ ∧ ∨ ⊕ → ↔Boolean algebra: p pq + ⊕C/C++/Java (wordwise): ! && || != ==C/C++/Java (bitwise): ~ & | ^Logic gates:

Topic #1.0 – Propositional Logic: Operators

Page 25: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

BitsandBitOperations•  Abitisabinary(base2)digit:0or1.•  Bitsmaybeusedtorepresenttruthvalues.•  Byconven'on:0represents“false”;1represents“true”.

•  Booleanalgebraislikeordinaryalgebraexceptthatvariablesstandforbits,+means“or”,andmul'plica'onmeans“and”.•  Seemodule23(chapter10)formoredetails.

Topic #2 – Bits

John Tukey (1915-2000)

Page 26: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

PropositionalEquivalence

Page 27: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

PropositionalEquivalence(§1.2)•  Twosyntac&cally(i.e.,textually)differentcompoundproposi'onsmaybetheseman&callyiden'cal(i.e.,havethesamemeaning).Wecallthemequivalent.Learn:

• Variousequivalencerulesorlaws.• Howtoproveequivalencesusingsymbolicderiva&ons.

Topic #1.1 – Propositional Logic: Equivalences

Page 28: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

TautologiesandContradictions• Atautologyisacompoundproposi'onthatistruenomaTerwhatthetruthvaluesofitsatomicproposi'onsare!

•  Ex.p∨¬p[Whatisitstruthtable?]• Acontradic&onisacompoundproposi'onthatisfalsenomaserwhat!Ex.p∧¬p[Truthtable?]

• Othercompoundprops.arecon&ngencies.(i.e.mostproposi'onsarecon'ngencies)

Topic #1.1 – Propositional Logic: Equivalences

Page 29: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

LogicalEquivalence• Compoundproposi'onpislogicallyequivalenttocompoundproposi'onq,wrisenp⇔q,IFFthecompoundproposi'onp↔qisatautology.

• Note,⇔isotendenotedby≡(Wewillusebothnota'onsinthisclass)

• Compoundproposi'onspandqarelogicallyequivalenttoeachotherIFFpandqcontainthesametruthvaluesaseachotherinallrowsoftheirtruthtables.

Topic #1.1 – Propositional Logic: Equivalences

Page 30: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

• Provethatp∨q⇔¬(¬p∧¬q).

ProvingEquivalenceviaTruthTables

Page 31: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

ProvingEquivalenceviaTruthTables•  Ex.Provethatp∨q⇔¬(¬p∧¬q).

p q pp∨∨qq ¬¬pp ¬¬qq ¬¬pp ∧∧ ¬¬qq ¬¬((¬¬pp ∧∧ ¬¬qq))F FF TT FT T

F T

T T

T

T

T

T T

T

F F

F

F

F F

F F

T T

Topic #1.1 – Propositional Logic: Equivalences

Page 32: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

EquivalenceLaws•  Thesearesimilartothearithme'ciden''esyoumayhavelearnedinalgebra,butforproposi'onalequivalencesinstead.

•  Theyprovideapasernortemplatethatcanbeusedtomatchallorpartofamuchmorecomplicatedproposi'onandtofindanequivalenceforit.

Topic #1.1 – Propositional Logic: Equivalences

Page 33: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

EquivalenceLaws-Examples

•  Iden&ty:p∧T⇔pp∨F⇔p

• Domina&on:p∨T⇔Tp∧F⇔F

•  Idempotent:p∨p⇔pp∧p⇔p

• Doublenega&on:¬¬p⇔p

• Commuta&ve:p∨q⇔q∨pp∧q⇔q∧p

• Associa&ve:(p∨q)∨r⇔p∨(q∨r)(p∧q)∧r⇔p∧(q∧r)

Topic #1.1 – Propositional Logic: Equivalences

Page 34: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

MoreEquivalenceLaws• Distribu&ve:p∨(q∧r)⇔(p∨q)∧(p∨r)p∧(q∨r)⇔(p∧q)∨(p∧r)• DeMorgan’s:

¬(p∧q)⇔¬p∨¬q ¬(p∨q)⇔¬p∧¬q• Trivialtautology/contradic&on:p∨¬p⇔Tp∧¬p⇔F

Topic #1.1 – Propositional Logic: Equivalences

Augustus De Morgan (1806-1871)

Page 35: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

DePiningOperatorsviaEquivalences

• Usingequivalences,wecandefineoperatorsintermsofotheroperators.

•  Exclusiveor:p⊕q⇔(p∨q)∧¬(p∧q)p⊕q⇔(p∧¬q)∨(q∧¬p)

•  Implies:p→q⇔¬p∨q

• Bicondi'onal:p↔q⇔(p→q)∧(q→p)p↔q⇔¬(p⊕q)

Topic #1.1 – Propositional Logic: Equivalences

Page 36: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

AnExampleProblem• Checkusingasymbolicderiva'onwhether(p∧¬q)→(p⊕r)⇔¬p∨q∨¬r.

•  (p∧¬q)→(p⊕r) • ⇔¬(p∧¬q)∨(p⊕r)[Expanddefini'onof→]

• ⇔¬(p∧¬q)∨((p∨r)∧¬(p∧r))[Expanddefn.of⊕]• ⇔(¬p∨q)∨((p∨r)∧¬(p∧r))[DeMorgan’sLaw]

•  cont.

Topic #1.1 – Propositional Logic: Equivalences

Page 37: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

ExampleContinued...• ⇔(¬p∨q)∨((p∨r)∧¬(p∧r))• ⇔(q∨¬p)∨((p∨r)∧¬(p∧r))[∨commutes]

• ⇔q∨(¬p∨((p∨r)∧¬(p∧r)))[∨associa've]• ⇔q∨(((¬p∨(p∨r))∧(¬p∨¬(p∧r)))[distrib.∨over∧]⇔ q∨(((¬p∨p)∨r)∧(¬p∨¬(p∧r)))[assoc.]⇔ q∨((T∨r)∧(¬p∨¬(p∧r)))[trivailtaut.]⇔ q∨(T∧(¬p∨¬(p∧r)))[domina'on]

⇔ q∨(¬p∨¬(p∧r))[iden'ty]cont.

Topic #1.1 – Propositional Logic: Equivalences

Page 38: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

EndofLongExample

⇔ q∨(¬p∨¬(p∧r))⇔ q∨(¬p∨(¬p∨¬r))[DeMorgan’s]

⇔ q∨((¬p∨¬p)∨¬r)[Assoc.]• ⇔q∨(¬p∨¬r)[Idempotent]

• ⇔(q∨¬p)∨¬r[Assoc.]⇔ ¬p∨q∨¬r[Commut.]

Q.E.D.

Remark.Q.E.D.(quoderatdemonstrandum)

Topic #1.1 – Propositional Logic: Equivalences

(Which was to be shown.)

Page 39: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

Review:PropositionalLogic(§§1.1-1.2)• Atomicproposi'ons:p,q,r,…• Booleanoperators:¬∧∨⊕→↔ • Compoundproposi'ons:s:≡(p∧¬q)∨r•  Equivalences:p∧¬q⇔¬(p→q)• Provingequivalencesusing:

•  Truthtables.•  Symbolicderiva'ons.p⇔q⇔r…

Topic #1 – Propositional Logic

Page 40: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

PredicateLogic

Page 41: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

PredicateLogic(§1.3)• Predicatelogicisanextensionofproposi'onallogicthatpermitsconciselyreasoningaboutwholeclassesofen''es.

• Proposi'onallogic(recall)treatssimpleproposi&ons(sentences)asatomicen''es.

•  Incontrast,predicatelogicdis'nguishesthesubjectofasentencefromitspredicate.

• RemembertheseEnglishgrammarterms?

Topic #3 – Predicate Logic

Page 42: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

ApplicationsofPredicateLogic•  Itistheformalnota'onforwri'ngperfectlyclear,concise,andunambiguousmathema'caldefini&ons,axioms,andtheorems(moreontheselater)foranybranchofmathema'cs.

• Predicatelogicwithfunc'onsymbols,the“=”operator,andafewproof-buildingrulesissufficientfordefininganyconceivablemathema'calsystem,andforprovinganythingthatcanbeprovedwithinthatsystem!

Topic #3 – Predicate Logic

Page 43: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

OtherApplications• Predicatelogicisthefounda'onofthefieldofmathema&callogic,whichculminatedinGödel’sincompletenesstheorem,whichrevealedtheul'matelimitsofmathema'calthought:

• Givenanyfinitelydescribable,consistentproofprocedure,therewillalwaysremainsometruestatementsthatwillneverbeprovenbythatprocedure.

• i.e.,wecan’tdiscoverallmathema'caltruths,unlesswesome'mesresorttomakingguesses.

Topic #3 – Predicate Logic

Kurt Gödel 1906-1978

Page 44: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

PracticalApplicationsofPredicateLogic•  Itisthebasisforclearlyexpressedformalspecifica'onsforanycomplexsystem.

•  Itisbasisforautoma&ctheoremproversandmanyotherAr'ficialIntelligencesystems.•  E.g.automa'cprogramverifica'onsystems.

• Predicate-logiclikestatementsaresupportedbysomeofthemoresophis'cateddatabasequeryenginesandcontainerclasslibraries•  thesearetypesofprogrammingtools.

Topic #3 – Predicate Logic

Page 45: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

SubjectsandPredicates•  Inthesentence“Thedogissleeping”:

•  Thephrase“thedog”denotesthesubject;theobjectoren&tythatthesentenceisabout.

•  Thephrase“issleeping”denotesthepredicate;apropertythatistrueofthesubject.

•  Inpredicatelogic,apredicateismodeledasafunc&onP(·)fromobjectstoproposi'ons.• P(x)=“xissleeping”(wherexisanyobject).

Topic #3 – Predicate Logic

Page 46: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

MoreAboutPredicates• Conven'on.Lowercasevariablesx,y,z...denoteobjects/en''es;uppercasevariablesP,Q,R…denoteproposi'onalfunc'ons(predicates).

• Remark.KeepinmindthattheresultofapplyingapredicatePtoanobjectxistheproposi&onP(x).ButthepredicatePitself(e.g.P=“issleeping”)isnotaproposi'on(notacompletesentence).•  E.g.ifP(x)=“xisaprimenumber”,P(3)istheproposi&on“3isaprimenumber.”

Topic #3 – Predicate Logic

Page 47: Discrete Mathematics for Computer Science Prof. Raissa D’Souza

Base

d on

Ros

en, D

iscr

ete

Mat

hem

atic

s &

Its

App

licat

ions

, 5e

Pr

epar

ed b

y (c

)200

1-20

04 M

icha

el P

. Fr

ank

M

odifi

ed b

y (c

) 20

04-2

005

Hal

uk B

ingö

l

‹#›/92 M

odul

e #1

- Lo

gic

PropositionalFunctions• Predicatelogicgeneralizesthegramma'calno'onofapredicatetoalsoincludeproposi'onalfunc'onsofanynumberofarguments,eachofwhichmaytakeanygramma'calrolethatanouncantake.

•  E.g.letP(x,y,z)=“xgaveythegradez”,thenif

x=“Mike”,y=“Mary”,z=“A”,thenP(x,y,z)=“MikegaveMarythegradeA.”

Topic #3 – Predicate Logic