First-Order Logic Part Two
Total Page:16
File Type:pdf, Size:1020Kb
First-Order Logic Part Two Recap from Last Time What is First-Order Logic? ● First-order logic is a logical system for reasoning about properties of objects. ● Augments the logical connectives from propositional logic with ● predicates that describe properties of objects, ● functions that map objects to one another, and ● quantifiers that allow us to reason about many objects at once. Some muggle is intelligent. ∃m. (Muggle(m) ∧ Intelligent(m)) ∃ existential quantifier ∃ isis thethe existential quantifier andand sayssays “for“for somesome choicechoice ofof m,m, thethe followingfollowing isis true.”true.” “For any natural number n, n is even if and only if n2 is even” ∀n. (n ∈ ℕ → (Even(n) ↔ Even(n2))) ∀ universal quantifier ∀ isis thethe universal quantifier andand sayssays “for“for anyany choicechoice ofof nn,, thethe followingfollowing isis true.”true.” “All A's are B's” translates as ∀x. (A(x) → B(x)) Useful Intuition: Universally-quantified statements are true unless there's a counterexample. ∀x. (A(x) → B(x)) IfIf xx isis aa counterexample,counterexample, itit mustmust havehave propertyproperty AA butbut notnot havehave propertyproperty BB.. “Some A is a B” translates as ∃x. (A(x) ∧ B(x)) Useful Intuition: Existentially-quantified statements are false unless there's a positive example. ∃x. (A(x) ∧ B(x)) IfIf xx isis anan example,example, itit mustmust havehave propertyproperty AA onon toptop ofof propertyproperty BB.. The Aristotelian Forms “All As are Bs” “Some As are Bs” ∀x. (A(x) → B(x)) ∃x. (A(x) ∧ B(x)) “No As are Bs” “Some As aren’t Bs” ∀x. (A(x) → ¬B(x)) ∃x. (A(x) ∧ ¬B(x)) ItIt isis worthworth committingcommitting thesethese patternspatterns toto memory.memory. We’llWe’ll bebe usingusing themthem throughoutthroughout thethe dayday andand theythey formform thethe backbonebackbone ofof manymany first-orderfirst-order logic logic translations.translations. The Art of Translation Using the predicates - Person(p), which states that p is a person, and - Loves(x, y), which states that x loves y, write a sentence in first-order logic that means “every person loves someone else.” ∀p. (Person(p) → ∃q. (Person(q) ∧ p ≠ q ∧ Loves(p, q) ) ) Using the predicates - Person(p), which states that p is a person, and - Loves(x, y), which states that x loves y, write a sentence in first-order logic that means “there is a person that everyone else loves.” ∃p. (Person(p) ∧ ∀q. (Person(q) ∧ p ≠ q → Loves(q, p) ) ) Combining Quantifiers ● Most interesting statements in first-order logic require a combination of quantifiers. ● Example: “Every person loves someone else” For every person… ∀p. (Person(p) → … there is another person … ∃q. (Person(q) ∧ p ≠ q ∧ … they love Loves(p, q) ) ) Combining Quantifiers ● Most interesting statements in first-order logic require a combination of quantifiers. ● Example: “There is someone everyone else loves.” There is a person… ∃p. (Person(p) ∧ … that everyone else … ∀q. (Person(q) ∧ p ≠ q → … loves. Loves(q, p) ) ) For Comparison For every person… ∀p. (Person(p) → … there is another person … ∃q. (Person(q) ∧ p ≠ q ∧ … they love Loves(p, q) ) ) There is a person… ∃p. (Person(p) ∧ … that everyone else … ∀q. (Person(q) ∧ p ≠ q → … loves. Loves(q, p) ) ) Every Person Loves Someone Else NoNo oneone herehere isis universallyuniversally loved.loved. There is Someone Everyone Else Loves ThisThis personperson doesdoes notnot lovelove anyoneanyone else.else. Every Person Loves Someone Else and There is Someone Everyone Else Loves For every person… ∀p. (Person(p) → … there is another person … ∃q. (Person(q) ∧ p ≠ q ∧ … they love Loves(p, q) ) ) and ∧ There is a person… ∃p. (Person(p) ∧ … that everyone else … ∀q. (Person(q) ∧ p ≠ q → … loves. Loves(q, p) ) ) Quantifier Ordering ● The statement ∀x. ∃y. P(x, y) means “for any choice of x, there's some choice of y where P(x, y) is true.” ● The choice of y can be different every time and can depend on x. Quantifier Ordering ● The statement ∃x. ∀y. P(x, y) means “there is some x where for any choice of y, we get that P(x, y) is true.” ● Since the inner part has to work for any choice of y, this places a lot of constraints on what x can be. Order matters when mixing existential and universal quantifiers! Time-Out for Announcements! Problem Set Two ● Problem Set One was due today at 2:30PM. ● Want to use late days? Turn it in by Sunday at 2:30PM. ● Problem Set Two goes out today. ● The checkpoint is due on Monday at 2:30PM. It’s completed online. ● The remaining problems are due next Friday. ● We have some reading recommendations for this problem set. ● Check out the Guide to Logic Translations for more on how to convert from English to FOL. ● Check out the Guide to Negations for information about how to negate formulas. ● Check out the First-Order Translation Checklist for details on how to check your work. Your Questions “Reading recommendations?” Shorter,Shorter, thought-provokingthought-provoking reads:reads: “De“De BrevitateBrevitate Vitae”Vitae” byby SenecaSeneca (on(on howhow toto spendspend timetime meaningfully),meaningfully), “Scott“Scott andand Scurvy”Scurvy” byby IdleIdle WordsWords (how(how wewe found,found, thenthen lost,lost, thethe curecure toto scurvy),scurvy), “The“The ReallyReally BigBig One”One” byby KathrynKathryn SchulzSchulz (Pulitzer-winning(Pulitzer-winning explorationexploration ofof aa hugehuge impendingimpending earthquake),earthquake), “Before“Before thethe Law”Law” byby KafkaKafka (great(great parableparable toto discuss),discuss), “Omphalos”“Omphalos” andand “Exhalation”“Exhalation” byby TedTed ChiangChiang (on(on divinedivine revelationrevelation andand entropy,entropy, respectively),respectively), “The“The EndEnd andand thethe Beginning”Beginning” byby WislawaWislawa SzymborskaSzymborska (powerful(powerful poempoem –– nono spoilers!),spoilers!), andand “The“The LibraryLibrary ofof Babel”Babel” byby JorgeJorge LuisLuis BorgesBorges (exploration(exploration ofof thethe finitefinite andand infinite). infinite). LongerLonger reads:reads: “The“The AutobiographyAutobiography ofof MalcolmMalcolm X”X” (race,(race, identity,identity, power,power, andand conviction),conviction), “Voices“Voices fromfrom Chernobyl”Chernobyl” (self-explanatory),(self-explanatory), “Guns,“Guns, Germs,Germs, andand Steel”Steel” (about(about whywhy societiessocieties evolvedevolved thethe wayway theythey did),did), “The“The SpiritSpirit CatchesCatches YouYou AndAnd YouYou FallFall Down”Down” (on(on cross-culturalcross-cultural medicine),medicine), “Cadillac“Cadillac Desert”Desert” (about(about waterwater policypolicy andand dam-buildingdam-building inin thethe US),US), andand “Whistling“Whistling Vivaldi”Vivaldi” (about(about stereotypestereotype threat)threat) “Can you give a real-world application of when the behavior of the vacuous truth is advantageous over assuming a "vacuous false"?” Sure!Sure! SupposeSuppose youyou wantwant toto checkcheck whetherwhether you’veyou’ve takentaken allall thethe prerequisitesprerequisites forfor aa course.course. InIn otherother words,words, youyou wantwant toto evaluateevaluate ∀ → YouHaveTaken(c)). ∀c.c. (CourseIsAPrereq(c)(CourseIsAPrereq(c) → YouHaveTaken(c)). YouHaveTaken(c)).YouHaveTaken(c)). WhatWhat shouldshould happenhappen ifif youyou wantwant toto taketake aa classclass thatthat hashas nono prerequisites?prerequisites? “How has learning formal logic benefited your personal/professional life? When have you used formal logic to prove/disprove something important?” AA relativerelative ofof minemine gotgot veryvery sicksick manymany yearsyears backback andand waswas givengiven aa medicinemedicine wherewhere thethe differencedifference betweenbetween aa therapeutictherapeutic andand toxictoxic dosedose waswas veryvery small.small. II waswas extremelyextremely concernedconcerned thatthat thethe regimenregimen theythey werewere onon wouldwould bebe toxic.toxic. II lookedlooked upup howhow rapidlyrapidly thethe medicinemedicine waswas eliminatedeliminated (about(about 50%50% everyevery couplecouple hours),hours), thenthen usedused aa proofproof byby inductioninduction toto convinceconvince myselfmyself thatthat thethe totaltotal dosagedosage waswas safe.safe. II sleptslept aa lotlot betterbetter atat nightnight afterafter that.that. Back to CS103! Set Translations Using the predicates - Set(S), which states that S is a set, and - x ∈ y, which states that x is an element of y, write a sentence in first-order logic that means “the empty set exists.” First-orderFirst-order logiclogic doesn'tdoesn't havehave setset operatorsoperators oror symbolssymbols “built“built in.”in.” IfIf wewe onlyonly havehave thethe predicatespredicates givengiven above,above, howhow mightmight wewe describedescribe this?this? ∃S. (Set(S) ∧ there are no elements in S∧ ) ∃S. (Set(S) ∧ ¬∃x. x ∈ S) ∃S. (Set(S) ∧ ¬∃x. x ∈ S) ∃S. (Set(S) ∧ there are no elements in S( ) ∃S. (Set(S) ∧ ¬∃x. x ∈ S) ∃S. (Set(S) ∧ ∀x. x ∉ S) BothBoth ofof thesethese translationstranslations areare correct.correct. JustJust likelike inin propositionalpropositional logic,logic, therethere areare manymany differentdifferent equivalentequivalent waysways ofof expressingexpressing thethe samesame statementstatement inin first-first- orderorder logic.logic. ∃S. (Set(S) ∧ ¬∃x. x ∈ S) ∃S. (Set(S) ∧ ∀x. x ∉ S) WhyWhy cancan wewe switchswitch whichwhich quantifierquantifier we’rewe’re usingusing here?here? Mechanics: Negating Statements An Extremely Important Table When is this true? When is this false? For any choice of x, ∀x. P(x) P(x) ∃x. ¬P(x) For some choice of x, ∃x. P(x) P(x) ∀x. ¬P(x)