Chapter , Part I: Propositional...

52
Chapter 1, Part I: Propositional Logic With Question/Answer Animations

Transcript of Chapter , Part I: Propositional...

Page 1: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Chapter1,PartI:PropositionalLogic

WithQuestion/AnswerAnimations

Page 2: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

ChapterSummary PropositionalLogic

 TheLanguageofPropositions Applications  LogicalEquivalences

 PredicateLogic TheLanguageofQuantifiers  LogicalEquivalences NestedQuantifiers

 Proofs RulesofInference  ProofMethods  ProofStrategy

Page 3: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Proposi1onalLogicSummary  TheLanguageofPropositions

  Connectives  TruthValues  TruthTables

 Applications  TranslatingEnglishSentences  SystemSpecifications  LogicPuzzles  LogicCircuits

  LogicalEquivalences  ImportantEquivalences  ShowingEquivalence  Satisfiability

Page 4: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Section1.1

Page 5: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Sec1onSummary Propositions Connectives

 Negation Conjunction Disjunction Implication;contrapositive,inverse,converse Biconditional

 TruthTables

Page 6: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Proposi1ons Apropositionisadeclarativesentencethatiseithertrueor

false.  Examplesofpropositions:

a)  TheMoonismadeofgreencheese.b)  TrentonisthecapitalofNewJersey.c)  TorontoisthecapitalofCanada.d)  1+0=1 e)  0+0=2

  Examplesthatarenotpropositions.a)  Sitdown!b)  Whattimeisit?c)  x+1=2d)  x+y=z

Page 7: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Proposi1onalLogic ConstructingPropositions

 PropositionalVariables:p,q,r,s,… ThepropositionthatisalwaystrueisdenotedbyTandthepropositionthatisalwaysfalseisdenotedbyF.

 CompoundPropositions;constructedfromlogicalconnectivesandotherpropositions  Negation¬  Conjunction∧  Disjunction∨  Implication→  Biconditional↔

Page 8: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

CompoundProposi1ons:Nega1on Thenegationofapropositionpisdenotedby¬pandhasthistruthtable:

 Example:Ifpdenotes“Theearthisround.”,then¬pdenotes“Itisnotthecasethattheearthisround,”ormoresimply“Theearthisnotround.”

p ¬pT F

F T

Page 9: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Conjunc1on Theconjunctionofpropositionspandqisdenotedbyp ∧ q andhasthistruthtable:

 Example:Ifpdenotes“Iamathome.”andqdenotes“Itisraining.”thenp ∧ qdenotes“Iamathomeanditisraining.”

p q p ∧ q T T T

T F F

F T F

F F F

Page 10: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Disjunc1on Thedisjunctionofpropositionspandqisdenotedbyp ∨qandhasthistruthtable:

 Example:Ifpdenotes“Iamathome.”andqdenotes“Itisraining.”thenp ∨ qdenotes“Iamathomeoritisraining.”

p q p ∨qT T T

T F T

F T T

F F F

Page 11: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

TheConnec1veOrinEnglish InEnglish“or”hastwodistinctmeanings.

  “InclusiveOr”‐Inthesentence“StudentswhohavetakenCS202 orMath120maytakethisclass,”weassumethatstudentsneedtohavetakenoneoftheprerequisites,butmayhavetakenboth.Thisisthemeaningofdisjunction. For p ∨q to be true, either one or both of p and q must be true.

  “ExclusiveOr”‐Whenreadingthesentence“Souporsaladcomeswiththisentrée,”wedonotexpecttobeabletogetbothsoupandsalad.ThisisthemeaningofExclusiveOr(Xor).Inp ⊕ q , oneofpandqmustbetrue, but not both. The truth table for ⊕ is:

p q p ⊕ qT T F

T F T

F T T

F F F

Page 12: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Implica1on  Ifpandqarepropositions,thenp →qisaconditionalstatementor

implicationwhichisreadas“ifp,thenq”andhasthistruthtable:

  Example:Ifpdenotes“Iamathome.”andqdenotes“Itisraining.”thenp →qdenotes“IfIamathomethenitisraining.”

  Inp →q,pisthehypothesis(antecedentorpremise)andqistheconclusion(orconsequence).

p q p →qT T T

T F F

F T T

F F T

Page 13: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

UnderstandingImplica1on Inp →q theredoesnotneedtobeanyconnectionbetweentheantecedentortheconsequent. The “meaning” of p →q dependsonlyonthetruthvaluesofpandq.

 Theseimplicationsareperfectlyfine,butwouldnotbeusedinordinaryEnglish.

  “Ifthemoonismadeofgreencheese,thenIhavemoremoneythanBillGates.”

  “IfthemoonismadeofgreencheesethenI’monwelfare.”  “If1+1=3,thenyourgrandmawearscombatboots.”

Page 14: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

UnderstandingImplica1on(cont) Onewaytoviewthelogicalconditionalistothinkofanobligationorcontract.  “IfIamelected,thenIwilllowertaxes.”  “Ifyouget100%onthefinal,thenyouwillgetanA.”

  Ifthepoliticianiselectedanddoesnotlowertaxes,thenthevoterscansaythatheorshehasbrokenthecampaignpledge.Somethingsimilarholdsfortheprofessor.Thiscorrespondstothecasewherepistrueandqisfalse.

Page 15: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

DifferentWaysofExpressingp →qifp,thenqpimpliesqifp,qponlyifq qunless¬pqwhenpqifp qwhenp qwheneverp pissufficientforqqfollowsfrompqisnecessaryforp

anecessaryconditionforpisqasufficientconditionforqisp

Page 16: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Converse,Contraposi1ve,andInverse Fromp →qwecanformnewconditionalstatements.

  q →pistheconverseofp →q  ¬q → ¬ pisthecontrapositiveofp →q ¬ p → ¬ qistheinverseofp →q

Example:Findtheconverse,inverse,andcontrapositiveof“Itrainingisasufficientconditionformynotgoingtotown.”

Solution:converse:IfIdonotgototown,thenitisraining.inverse:Ifitisnotraining,thenIwillgototown.contrapositive:IfIgototown,thenitisnotraining.

Page 17: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Bicondi1onal  Ifpandqarepropositions,thenwecanformthebiconditional

propositionp ↔ q,readas“pifandonlyifq.”Thebiconditionalp ↔ qdenotesthepropositionwiththistruthtable:

  Ifpdenotes“Iamathome.”andqdenotes“Itisraining.”thenp ↔ qdenotes“Iamathomeifandonlyifitisraining.”

p q p ↔ qT T T

T F F

F T F

F F T

Page 18: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

ExpressingtheBicondi1onal Somealternativeways“pifandonlyifq”isexpressedinEnglish:

  pisnecessaryandsufficientforq  ifpthenq,andconversely  piffq

Page 19: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

TruthTablesForCompoundProposi1ons Constructionofatruthtable: Rows

  Needarowforeverypossiblecombinationofvaluesfortheatomicpropositions.

 Columns Needacolumnforthecompoundproposition(usuallyatfarright)

 Needacolumnforthetruthvalueofeachexpressionthatoccursinthecompoundpropositionasitisbuiltup.  Thisincludestheatomicpropositions

Page 20: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

ExampleTruthTable Constructatruthtablefor

p q r ¬r p∨ q p∨ q → ¬r

T T T F T F

T T F T T T

T F T F T F

T F F T T T

F T T F T F

F T F T T T

F F T F F T

F F F T F T

Page 21: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

EquivalentProposi1ons Twopropositionsareequivalentiftheyalwayshavethesametruthvalue.

 Example:Showusingatruthtablethatthebiconditionalisequivalenttothecontrapositive.

Solution:

p q ¬ p ¬ q p →q ¬q → ¬ pT T F F T T

T F F T F F

F T T F T T

F F T T F T

Page 22: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

UsingaTruthTabletoShowNon‐EquivalenceExample:Showusingtruthtablesthatneithertheconversenorinverseofanimplicationarenotequivalenttotheimplication.

Solution:p q ¬ p ¬ q p → q ¬ p → ¬ q q → p

T T F F T T T

T F F T F T T

F T T F T F F

F F T T F T T

Page 23: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Problem Howmanyrowsarethereinatruthtablewithnpropositionalvariables?

Solution:2n We will see how to do this in Chapter 6.

 Notethatthismeansthatwithnpropositionalvariables,wecanconstruct2n distinct (i.e., not equivalent) propositions.

Page 24: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

PrecedenceofLogicalOperatorsOperator Precedence

¬ 1

∧∨

23

→↔

45

p ∨ q → ¬r isequivalentto(p ∨ q) → ¬r Iftheintendedmeaningisp ∨(q → ¬r ) thenparenthesesmustbeused.

Page 25: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Section1.2

Page 26: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Applica1onsofProposi1onalLogic:Summary TranslatingEnglishtoPropositionalLogic SystemSpecifications BooleanSearching LogicPuzzles LogicCircuits

Page 27: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Transla1ngEnglishSentences StepstoconvertanEnglishsentencetoastatementinpropositionallogic Identifyatomicpropositionsandrepresentusingpropositionalvariables.

 Determineappropriatelogicalconnectives “IfIgotoHarry’sortothecountry,Iwillnotgoshopping.” p:IgotoHarry’s q:Igotothecountry. r:Iwillgoshopping.

Ifporqthennotr.

Page 28: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

ExampleProblem:Translatethefollowingsentenceintopropositionallogic:

“YoucanaccesstheInternetfromcampusonlyifyouareacomputersciencemajororyouarenotafreshman.”

OneSolution:Leta,c,andfrepresentrespectively“Youcanaccesstheinternetfromcampus,”“Youareacomputersciencemajor,”and“Youareafreshman.”

a→ (c ∨ ¬ f)

Page 29: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

SystemSpecifica1ons SystemandSoftwareengineerstakerequirementsinEnglishandexpresstheminaprecisespecificationlanguagebasedonlogic.

Example:Expressinpropositionallogic:“Theautomatedreplycannotbesentwhenthefilesystemisfull”

Solution:Onepossiblesolution:Letpdenote“Theautomatedreplycanbesent”andqdenote“Thefilesystemisfull.”

q→ ¬ p

Page 30: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

ConsistentSystemSpecifica1onsDefinition:Alistofpropositionsisconsistentifitispossibletoassigntruthvaluestothepropositionvariablessothateachpropositionistrue.

Exercise:Arethesespecificationsconsistent?  “Thediagnosticmessageisstoredinthebufferoritisretransmitted.”  “Thediagnosticmessageisnotstoredinthebuffer.”  “Ifthediagnosticmessageisstoredinthebuffer,thenitisretransmitted.”

Solution:Letpdenote“Thediagnosticmessageisnotstoredinthebuffer.”Letqdenote“Thediagnosticmessageisretransmitted”Thespecificationcanbewrittenas: p ∨ q,p → q, ¬p.Whenpisfalseandqistrueallthreestatementsaretrue.Sothespecificationisconsistent.  Whatif“Thediagnosticmessageisnotretransmittedisadded.”Solution:Nowweareadding¬qandthereisnosatisfyingassignment.So

thespecificationisnotconsistent.

Page 31: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

LogicPuzzles  Anislandhastwokindsofinhabitants,knights,whoalwaystellthe

truth,andknaves,whoalwayslie.  YougototheislandandmeetAandB.

  Asays“Bisaknight.”  Bsays“Thetwoofusareofoppositetypes.”

Example:WhatarethetypesofAandB?Solution:LetpandqbethestatementsthatAisaknightandBisa

knight,respectively.So,then¬prepresentsthepropositionthatAisaknaveand¬qthatBisaknave.  IfAisaknight,thenpistrue.Sinceknightstellthetruth,qmustalsobe

true.Then(p ∧¬q)∨ (¬ p ∧q) wouldhavetobetrue,butitisnot.So,Aisnotaknightandtherefore¬pmustbetrue.

  IfAisaknave,thenBmustnotbeaknightsinceknavesalwayslie.So,thenboth¬pand¬qholdsincebothareknaves.

RaymondSmullyan(Born1919)

Page 32: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

LogicCircuits(StudiedindepthinChapter12)  Electroniccircuits;eachinput/outputsignalcanbeviewedasa0or1.

  0representsFalse  1representsTrue

  Complicatedcircuitsareconstructedfromthreebasiccircuitscalledgates.

 Theinverter(NOTgate)takesaninputbitandproducesthenegationofthatbit. TheORgatetakestwoinputbitsandproducesthevalueequivalenttothedisjunctionofthetwo

bits. TheANDgatetakestwoinputbitsandproducesthevalueequivalenttotheconjunctionofthe

twobits.  Morecomplicateddigitalcircuitscanbeconstructedbycombiningthesebasiccircuits

toproducethedesiredoutputgiventheinputsignalsbybuildingacircuitforeachpieceoftheoutputexpressionandthencombiningthem.Forexample:

Page 33: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Section1.3

Page 34: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Sec1onSummary Tautologies,Contradictions,andContingencies. LogicalEquivalence

 ImportantLogicalEquivalences ShowingLogicalEquivalence

 NormalForms(optional,coveredinexercisesintext) ConjunctiveNormalForm

 PropositionalSatisfiability SudokuExample

Page 35: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Tautologies,Contradic1ons,andCon1ngencies Atautologyisapropositionwhichisalwaystrue.

 Example:p∨ ¬p Acontradictionisapropositionwhichisalwaysfalse.

 Example:p∧ ¬p Acontingencyisapropositionwhichisneitheratautologynoracontradiction,suchasp

P ¬p p∨ ¬p p∧ ¬pT F T F

F T T F

Page 36: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

LogicallyEquivalent  Twocompoundpropositionspandqarelogicallyequivalentif

p ↔ qisatautology.  Wewritethisasp⇔ qorasp ≡ qwherepandqarecompound

propositions.  Twocompoundpropositionspandqareequivalentifandonlyif

thecolumnsinatruthtablegivingtheirtruthvaluesagree.  Thistruthtableshow¬p ∨ q isequivalenttop → q.

p q ¬p ¬p ∨ q P → qT T F T T

T F F F F

F T T T T

F F T T T

Page 37: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

DeMorgan’sLaws

p q ¬p ¬q (p ∨ q) ¬(p ∨ q) ¬p ∧ ¬q

T T F F T F F

T F F T T F F

F T T F T F F

F F T T F T T

ThistruthtableshowsthatDeMorgan’sSecondLawholds.

AugustusDeMorgan

1806‐1871

Page 38: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

KeyLogicalEquivalences IdentityLaws:,

 DominationLaws:,

 Idempotentlaws:,

 DoubleNegationLaw:

 NegationLaws:,

Page 39: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

KeyLogicalEquivalences(cont) CommutativeLaws:,

 AssociativeLaws:

 DistributiveLaws:

 AbsorptionLaws:

Page 40: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

MoreLogicalEquivalences

Page 41: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Construc1ngNewLogicalEquivalences Wecanshowthattwoexpressionsarelogicallyequivalentbydevelopingaseriesoflogicallyequivalentstatements.

 ToprovethatweproduceaseriesofequivalencesbeginningwithAandendingwithB.

 Keepinmindthatwheneveraproposition(representedbyapropositionalvariable)occursintheequivalenceslistedearlier,itmaybereplacedbyanarbitrarilycomplexcompoundproposition.

Page 42: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

EquivalenceProofsExample:ShowthatislogicallyequivalenttoSolution:

Page 43: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

EquivalenceProofsExample:Showthatisatautology.Solution:

Page 44: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Conjunc1veNormalForm(op1onal)Example:PutthefollowingintoCNF:

Solution:1.  Eliminateimplicationsigns:

3.  Movenegationinwards;eliminatedoublenegation:

5.  ConverttoCNFusingassociative/distributivelaws

Page 45: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Proposi1onalSa1sfiability Acompoundpropositionissatisfiableifthereisanassignmentoftruthvaluestoitsvariablesthatmakeittrue.Whennosuchassignmentsexist,thecompoundpropositionisunsatisfiable.

 Acompoundpropositionisunsatisfiableifandonlyifitsnegationisatautology.

Page 46: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Ques1onsonProposi1onalSa1sfiabilityExample:Determinethesatisfiabilityofthefollowingcompoundpropositions:

Solution:Satisfiable.AssignTtop, q, andr.

Solution:Satisfiable.AssignTtop and F to q.

Solution:Notsatisfiable.Checkeachpossibleassignmentoftruthvaluestothepropositionalvariablesandnonewillmakethepropositiontrue.

Page 47: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Nota1on

Neededforthenextexample.

Page 48: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Sudoku ASudokupuzzleisrepresentedbya9×9gridmadeupofnine3×3subgrids,knownasblocks.Someofthe81cellsofthepuzzleareassignedoneofthenumbers1,2,…,9.

 Thepuzzleissolvedbyassigningnumberstoeachblankcellsothateveryrow,columnandblockcontainseachoftheninepossiblenumbers.

 Example

Page 49: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

EncodingasaSa1sfiabilityProblem Letp(i,j,n)denotethepropositionthatistruewhenthenumbernisinthecellintheithrowandthejthcolumn.

 Thereare9×9×9=729suchpropositions. Inthesamplepuzzlep(5,1,6)istrue,butp(5,j,6)isfalseforj=2,3,…9

Page 50: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Encoding(cont) Foreachcellwithagivenvalue,assertp(d,j,n),whenthecellinrowiandcolumnjhasthegivenvalue.

 Assertthateveryrowcontainseverynumber.

 Assertthateverycolumncontainseverynumber.

Page 51: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

Encoding(cont) Assertthateachofthe3x3blockscontaineverynumber.

(thisistricky‐ideasfromchapter4help) Assertthatnocellcontainsmorethanonenumber.Taketheconjunctionoverallvaluesofn,n’,i,andj,whereeachvariablerangesfrom1to9and,

of

Page 52: Chapter , Part I: Propositional Logicuser.ceng.metu.edu.tr/~mutlu/teaching/kesikliMatematik/eski/Chapte… · Predicate Logic ... propositional logic Identify atomic propositions

SolvingSa1sfiabilityProblems TosolveaSudokupuzzle,weneedtofindanassignmentoftruthvaluestothe729variablesoftheformp(i,j,n)thatmakestheconjunctionoftheassertionstrue.ThosevariablesthatareassignedTyieldasolutiontothepuzzle.

 Atruthtablecanalwaysbeusedtodeterminethesatisfiabilityofacompoundproposition.Butthisistoocomplexevenformoderncomputersforlargeproblems.

 Therehasbeenmuchworkondevelopingefficientmethodsforsolvingsatisfiabilityproblemsasmanypracticalproblemscanbetranslatedintosatisfiabilityproblems.