discrete mathematics for computer science prof. raissa d’souza
TRANSCRIPT
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)
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
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
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
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)
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
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
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
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
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
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
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
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
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)
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
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
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
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.)
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
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
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
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
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
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
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
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
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