chapter , part i: propositional...
TRANSCRIPT
Chapter1,PartI:PropositionalLogic
WithQuestion/AnswerAnimations
ChapterSummary PropositionalLogic
TheLanguageofPropositions Applications LogicalEquivalences
PredicateLogic TheLanguageofQuantifiers LogicalEquivalences NestedQuantifiers
Proofs RulesofInference ProofMethods ProofStrategy
Proposi1onalLogicSummary TheLanguageofPropositions
Connectives TruthValues TruthTables
Applications TranslatingEnglishSentences SystemSpecifications LogicPuzzles LogicCircuits
LogicalEquivalences ImportantEquivalences ShowingEquivalence Satisfiability
Section1.1
Sec1onSummary Propositions Connectives
Negation Conjunction Disjunction Implication;contrapositive,inverse,converse Biconditional
TruthTables
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
Proposi1onalLogic ConstructingPropositions
PropositionalVariables:p,q,r,s,… ThepropositionthatisalwaystrueisdenotedbyTandthepropositionthatisalwaysfalseisdenotedbyF.
CompoundPropositions;constructedfromlogicalconnectivesandotherpropositions Negation¬ Conjunction∧ Disjunction∨ Implication→ Biconditional↔
CompoundProposi1ons:Nega1on Thenegationofapropositionpisdenotedby¬pandhasthistruthtable:
Example:Ifpdenotes“Theearthisround.”,then¬pdenotes“Itisnotthecasethattheearthisround,”ormoresimply“Theearthisnotround.”
p ¬pT F
F T
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
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
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
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
UnderstandingImplica1on Inp →q theredoesnotneedtobeanyconnectionbetweentheantecedentortheconsequent. The “meaning” of p →q dependsonlyonthetruthvaluesofpandq.
Theseimplicationsareperfectlyfine,butwouldnotbeusedinordinaryEnglish.
“Ifthemoonismadeofgreencheese,thenIhavemoremoneythanBillGates.”
“IfthemoonismadeofgreencheesethenI’monwelfare.” “If1+1=3,thenyourgrandmawearscombatboots.”
UnderstandingImplica1on(cont) Onewaytoviewthelogicalconditionalistothinkofanobligationorcontract. “IfIamelected,thenIwilllowertaxes.” “Ifyouget100%onthefinal,thenyouwillgetanA.”
Ifthepoliticianiselectedanddoesnotlowertaxes,thenthevoterscansaythatheorshehasbrokenthecampaignpledge.Somethingsimilarholdsfortheprofessor.Thiscorrespondstothecasewherepistrueandqisfalse.
DifferentWaysofExpressingp →qifp,thenqpimpliesqifp,qponlyifq qunless¬pqwhenpqifp qwhenp qwheneverp pissufficientforqqfollowsfrompqisnecessaryforp
anecessaryconditionforpisqasufficientconditionforqisp
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.
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
ExpressingtheBicondi1onal Somealternativeways“pifandonlyifq”isexpressedinEnglish:
pisnecessaryandsufficientforq ifpthenq,andconversely piffq
TruthTablesForCompoundProposi1ons Constructionofatruthtable: Rows
Needarowforeverypossiblecombinationofvaluesfortheatomicpropositions.
Columns Needacolumnforthecompoundproposition(usuallyatfarright)
Needacolumnforthetruthvalueofeachexpressionthatoccursinthecompoundpropositionasitisbuiltup. Thisincludestheatomicpropositions
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
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
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
Problem Howmanyrowsarethereinatruthtablewithnpropositionalvariables?
Solution:2n We will see how to do this in Chapter 6.
Notethatthismeansthatwithnpropositionalvariables,wecanconstruct2n distinct (i.e., not equivalent) propositions.
PrecedenceofLogicalOperatorsOperator Precedence
¬ 1
∧∨
23
→↔
45
p ∨ q → ¬r isequivalentto(p ∨ q) → ¬r Iftheintendedmeaningisp ∨(q → ¬r ) thenparenthesesmustbeused.
Section1.2
Applica1onsofProposi1onalLogic:Summary TranslatingEnglishtoPropositionalLogic SystemSpecifications BooleanSearching LogicPuzzles LogicCircuits
Transla1ngEnglishSentences StepstoconvertanEnglishsentencetoastatementinpropositionallogic Identifyatomicpropositionsandrepresentusingpropositionalvariables.
Determineappropriatelogicalconnectives “IfIgotoHarry’sortothecountry,Iwillnotgoshopping.” p:IgotoHarry’s q:Igotothecountry. r:Iwillgoshopping.
Ifporqthennotr.
ExampleProblem:Translatethefollowingsentenceintopropositionallogic:
“YoucanaccesstheInternetfromcampusonlyifyouareacomputersciencemajororyouarenotafreshman.”
OneSolution:Leta,c,andfrepresentrespectively“Youcanaccesstheinternetfromcampus,”“Youareacomputersciencemajor,”and“Youareafreshman.”
a→ (c ∨ ¬ f)
SystemSpecifica1ons SystemandSoftwareengineerstakerequirementsinEnglishandexpresstheminaprecisespecificationlanguagebasedonlogic.
Example:Expressinpropositionallogic:“Theautomatedreplycannotbesentwhenthefilesystemisfull”
Solution:Onepossiblesolution:Letpdenote“Theautomatedreplycanbesent”andqdenote“Thefilesystemisfull.”
q→ ¬ p
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.
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)
LogicCircuits(StudiedindepthinChapter12) Electroniccircuits;eachinput/outputsignalcanbeviewedasa0or1.
0representsFalse 1representsTrue
Complicatedcircuitsareconstructedfromthreebasiccircuitscalledgates.
Theinverter(NOTgate)takesaninputbitandproducesthenegationofthatbit. TheORgatetakestwoinputbitsandproducesthevalueequivalenttothedisjunctionofthetwo
bits. TheANDgatetakestwoinputbitsandproducesthevalueequivalenttotheconjunctionofthe
twobits. Morecomplicateddigitalcircuitscanbeconstructedbycombiningthesebasiccircuits
toproducethedesiredoutputgiventheinputsignalsbybuildingacircuitforeachpieceoftheoutputexpressionandthencombiningthem.Forexample:
Section1.3
Sec1onSummary Tautologies,Contradictions,andContingencies. LogicalEquivalence
ImportantLogicalEquivalences ShowingLogicalEquivalence
NormalForms(optional,coveredinexercisesintext) ConjunctiveNormalForm
PropositionalSatisfiability SudokuExample
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
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
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
KeyLogicalEquivalences IdentityLaws:,
DominationLaws:,
Idempotentlaws:,
DoubleNegationLaw:
NegationLaws:,
KeyLogicalEquivalences(cont) CommutativeLaws:,
AssociativeLaws:
DistributiveLaws:
AbsorptionLaws:
MoreLogicalEquivalences
Construc1ngNewLogicalEquivalences Wecanshowthattwoexpressionsarelogicallyequivalentbydevelopingaseriesoflogicallyequivalentstatements.
ToprovethatweproduceaseriesofequivalencesbeginningwithAandendingwithB.
Keepinmindthatwheneveraproposition(representedbyapropositionalvariable)occursintheequivalenceslistedearlier,itmaybereplacedbyanarbitrarilycomplexcompoundproposition.
EquivalenceProofsExample:ShowthatislogicallyequivalenttoSolution:
EquivalenceProofsExample:Showthatisatautology.Solution:
Conjunc1veNormalForm(op1onal)Example:PutthefollowingintoCNF:
Solution:1. Eliminateimplicationsigns:
3. Movenegationinwards;eliminatedoublenegation:
5. ConverttoCNFusingassociative/distributivelaws
Proposi1onalSa1sfiability Acompoundpropositionissatisfiableifthereisanassignmentoftruthvaluestoitsvariablesthatmakeittrue.Whennosuchassignmentsexist,thecompoundpropositionisunsatisfiable.
Acompoundpropositionisunsatisfiableifandonlyifitsnegationisatautology.
Ques1onsonProposi1onalSa1sfiabilityExample:Determinethesatisfiabilityofthefollowingcompoundpropositions:
Solution:Satisfiable.AssignTtop, q, andr.
Solution:Satisfiable.AssignTtop and F to q.
Solution:Notsatisfiable.Checkeachpossibleassignmentoftruthvaluestothepropositionalvariablesandnonewillmakethepropositiontrue.
Nota1on
Neededforthenextexample.
Sudoku ASudokupuzzleisrepresentedbya9×9gridmadeupofnine3×3subgrids,knownasblocks.Someofthe81cellsofthepuzzleareassignedoneofthenumbers1,2,…,9.
Thepuzzleissolvedbyassigningnumberstoeachblankcellsothateveryrow,columnandblockcontainseachoftheninepossiblenumbers.
Example
EncodingasaSa1sfiabilityProblem Letp(i,j,n)denotethepropositionthatistruewhenthenumbernisinthecellintheithrowandthejthcolumn.
Thereare9×9×9=729suchpropositions. Inthesamplepuzzlep(5,1,6)istrue,butp(5,j,6)isfalseforj=2,3,…9
Encoding(cont) Foreachcellwithagivenvalue,assertp(d,j,n),whenthecellinrowiandcolumnjhasthegivenvalue.
Assertthateveryrowcontainseverynumber.
Assertthateverycolumncontainseverynumber.
Encoding(cont) Assertthateachofthe3x3blockscontaineverynumber.
(thisistricky‐ideasfromchapter4help) Assertthatnocellcontainsmorethanonenumber.Taketheconjunctionoverallvaluesofn,n’,i,andj,whereeachvariablerangesfrom1to9and,
of
SolvingSa1sfiabilityProblems TosolveaSudokupuzzle,weneedtofindanassignmentoftruthvaluestothe729variablesoftheformp(i,j,n)thatmakestheconjunctionoftheassertionstrue.ThosevariablesthatareassignedTyieldasolutiontothepuzzle.
Atruthtablecanalwaysbeusedtodeterminethesatisfiabilityofacompoundproposition.Butthisistoocomplexevenformoderncomputersforlargeproblems.
Therehasbeenmuchworkondevelopingefficientmethodsforsolvingsatisfiabilityproblemsasmanypracticalproblemscanbetranslatedintosatisfiabilityproblems.