1 / 39

Inference in FOL [AIMA Ch. 9]

Inference in FOL [AIMA Ch. 9]. R e du c i n g f i rs t - o r d e r i n fe re n ce to p r opo s i t i o n al i n fe re n ce U n i f i c at i o n Ge n e r a li z ed M odu s P on e n s F o r w ard a n d b ack w a r d c h a i n i n g L og i c p r o g r a mm i n g R es o l u t i o n.

Download Presentation

Inference in FOL [AIMA Ch. 9]

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Inference in FOL [AIMA Ch. 9] • Reducingfirst-orderinferencetopropositionalinference • Unification • GeneralizedModusPonens • Forwardandbackwardchaining • Logicprogramming • Resolution

  2. A brief history of reasoning Stoics Aristotle Cardano propositionallogic,inference(maybe) “syllogisms”(inferencerules),quantifiers probabilitytheory(propositional logic+ uncertainty) propositionallogic (again) first-order logic proofbytruth tables ∃completealgorithm for FOL completealgorithm for FOL(reduceto propositional) ¬∃completealgorithm for arithmetic “practical” algorithm for propositional logic “practical” algorithm for FOL—resolution 450b.c. 322b.c. 1565 Boole Frege Wittgenstein Gödel Herbrand 1847 1879 1922 1930 1930 Gödel Davis/Putnam 1931 1960 1965 Robinson

  3. Universal instantiation (UI) • Everyinstantiationofauniversallyquantifiedsentence isentailedby it: • ∀vα • SUBST({v/g},α) • forany variablevand groundtermg • E.g.,∀xKing(x)∧Greedy(x)⇒Evil(x)yieldsKing(John)∧Greedy(John)⇒Evil(John) King(Richard)∧Greedy(Richard)⇒Evil(Richard) • King(Father(John))∧Greedy(Father(John))⇒Evil(Father(John)) • …

  4. Existential instantiation (EI) • Foranysentenceα,variablev,andconstant symbol kthat does not appearelsewherein theknowledgebase: • ∃vα • SUBST({v/k},α) • E.g.,∃xCrown(x)∧OnHead(x,John) • Crown(C1)∧OnHead(C1,John) yields providedC1 isa newconstantsymbol,calledaSkolemconstant • Anotherexample:from∃xd(xy)/dy=xy • d(ey)/dy=ey • providedeis anewconstantsymbol weobtain

  5. Existential instantition contd. • UIcanbeappliedseveraltimes toaddnewsentences; thenewKB islogicallyequivalenttotheold • EIcanbe appliedoncetoreplacetheexistentialsentence; thenewKB isnotequivalenttotheold,butissatisfiableiff theold KB wassatisfiable

  6. Reduction to propositional inference SupposetheKB containsjustthefollowing: ∀xKing(x)∧Greedy(x)⇒Evil(x) King(John) Greedy(John) Brother(Richard,John) Instantiatingtheuniversalsentenceinallpossibleways,wehave King(John)∧Greedy(John)⇒Evil(John) King(Richard)∧Greedy(Richard)⇒Evil(Richard) King(John) Greedy(John) Brother(Richard,John) ThenewKB is propositionalized:propositionsymbols are King(John),Greedy(John),Evil(John),King(Richard)etc.

  7. Reduction contd. • Claim: agroundsentenceisentailedby newKBiff entailed by originalKB • Claim:everyFOLKBcan bepropositionalizedsoas to preserveentailment • Idea:propositionalizeKBandquery,applyresolution,returnresult • Problem:withfunctionsymbols,thereareinfinitelymanygroundterms, • e.g.,Father(Father(Father(John)))

  8. Reduction contd. • Theorem: Herbrand(1930).Ifasentence αisentailed by anFOLKB,itisentailedby afinitesubsetofthepropositionalKB • Idea:Forn= 0to ∞do • createapropositionalKBby instantiatingwith depth-ntermsandseeifαisentailed byKB • Problem:worksifαisentailed,loopsifαisnot entailed • Theorem:Turing(1936),Church(1936), entailmentinFOLis semidecidable

  9. Problems with propositionalization • Propositionalizationseemstogeneratelotsofirrelevant sentences. • E.g.,from • ∀x King(x)∧Greedy(x)⇒Evil(x) King(John) • ∀yGreedy(y) Brother(Richard,John) • itseemsobvious thatEvil(John),butpropositionalization produceslotsoffactssuchasGreedy(Richard)thatare irrelevant • Withpk-arypredicatesandnconstants,therearep·nk • instantiations • Withfunctionsymbols,itgetsmuchmuchworse!

  10. Unification • Wecangettheinferenceimmediately ifwecanfind asubstitutionθsuchthatKing(x)andGreedy(x) matchKing(John)andGreedy(y) • θ={x/John,y/John}works • UNIFY(α,β)=θif αθ=βθ p q θ Knows(John,x) Knows(John,x) Knows(John,x) Knows(John,x) Knows(John,Jane) Knows(y,OJ) Knows(y,Mother(y)) Knows(x,OJ) {x/Jane} {x/OJ,y/John} {y/John,x/Mother(John)} fail Standardizing aparteliminates overlapofvariables,e.g.,Knows(z17,OJ)

  11. The unification algorithm

  12. The unification algorithm

  13. Generalized Modus Ponens (GMP) p1’,p2’,…,pn’,(p1 ∧p2 ∧…∧pn ⇒q) qθ • wherepi’θ=piθforall i • p1’isKing(John) • p2’isGreedy(y) • θis {x/John,y/John} • q θis Evil(John) p1 isKing(x) p2is Greedy(x) qis Evil(x) GMPusedwithKBofdefiniteclauses(exactlyonepositive literal) Allvariables assumeduniversally quantified

  14. Soundness of GMP Needtoshowthat p1’,p2’,…,pn’,(p1 ∧p2 ∧…∧pn ⇒q)╞qθ providedthatpi’θ=piθforall i Lemma:Forany definiteclausep,wehavep╞pθby UI 1.(p1 ∧p2 ∧…∧pn ⇒q)╞(p1 ∧p2 ∧…∧pn ⇒q)θ= (p1θ∧p2θ ∧…∧pnθ⇒qθ) 2.p1’,p2’,…,pn’╞p1’∧p2’∧…∧pn’╞p1’θ∧p2’θ∧…∧pn’θ 3.From 1and2,qfollowsbyordinaryModusPonens

  15. Example knowledge base • Thelaw saysthatit isacrimeforanAmericantosellweaponstohostilenations. ThecountryNono,anenemy ofAmerica,hassomemissiles,andallofitsmissiles weresoldtoit byColonelWest, whoisAmerican. • ProvethatCol.Westisacriminal

  16. Example knowledge base contd. …it is a crimefor an Americanto sellweaponsto hostilenations: American(x)∧Weapon(y)∧Sells(x,y,z)∧Hostile(z)⇒Criminal(x) • Owns(Nono,M)andMissile(M) • …all of its missiles weresold to itbyColonolWest • ∀x Missile(x)∧Owns(Nono,x)⇒Sells(West,x,Nono) • Missilesareweapons: • Missile(x)⇒Weapon(x) • An enemyofAmericacounts as “hostile”: • Enemy(x,America)⇒Hostile(x) • West,whois American… • American(west) • Thecountry Non,an enemyofAmerica • Enemy(Nono,America) Nono…has somemissiles,i.e., ∃xOwns(Nono,x)∧Missile(x):

  17. Forward chaining algorithm

  18. Forward chaining proof

  19. Forward chaining proof

  20. Forward chaining proof

  21. Properties of forward chaining • Sound andcompleteforfirst-orderdefiniteclauses (proofsimilartopropositionalproof) • Datalog=first-orderdefiniteclauses+nofunctions(e.g.,crimeKB) • FC terminatesforDataloginpolyiterations:at mostp·nkliterals • May notterminateingeneralif αisnotentailed • Thisisunavoidable:entailmentwithdefiniteclausesissemidecidable

  22. Efficiency of forward chaining • Simple observation:noneedtomatcharuleoniterationkifa premisewasn'tadded oniterationk-1 • ⇒matcheachrulewhosepremisecontainsa newlyaddedliteral • Matchingitselfcanbeexpensive • DatabaseindexingallowsO(1)retrievalofknownfacts e.g.,queryMissile(x)retrievesMissile(M1) • Matchingconjunctivepremisesagainstknownfactsis NP-hard • Forwardchainingis widelyusedin deductivedatabases

  23. Hard matching example • Colorable()isinferrediffthe CSPhasa solution • CSPsinclude3SATasa specialcase, hence matchingisNP-hard

  24. Backward chaining algorithm

  25. Backward chaining example

  26. Backward chaining example

  27. Backward chaining example

  28. Backward chaining example

  29. Backward chaining example

  30. Backward chaining example

  31. Backward chaining example

  32. Properties of backward chaining Depth-firstrecursiveproofsearch:spaceis linear insizeof proof Incompletedueto infinite loops ⇒fix bycheckingcurrentgoalagainsteverygoalonstack Inefficientduetorepeatedsubgoals(bothsuccessandfailure) ⇒fixusingcachingof previousresults(extraspace!) Widelyused(withoutimprovements!)forlogicprogramming

  33. Logic programming • Soundbite:computation asinferenceonlogicalKBs OrdinaryprogrammingIdentifyproblem Assembleinformation Figureoutsolution Programsolution Encodeproblemasdata Apply program todata Debugproceduralerrors Logicprogramming Identifyproblem Assemble information Teabreak EncodeinformationinKB Encodeproblemasfacts Askqueries Findfalsefacts ShouldbeeasiertodebugCapital(NewYork,US)thanx:=x+ 2!

  34. Prolog systems • Basis:backwardchainingwithHornclauses+ bells&whistles WidelyusedinEurope,Japan(basisof 5thGenerationproject) Compilationtechniques⇒approachingabillionLIPS • Program=setofclauses=head :- literal1,… literaln. • criminal(X):- american(X), weapon(Y), sells(X,Y,Z), hostile(Z). • Efficientunificationby opencoding • Efficientretrievalof matchingclausesby directlinking • Depth-first,left-to-rightbackwardchaining • Built-in predicatesforarithmetic etc.,e.g.,X isY*Z+3 • Closed-worldassumption(“negationasfailure”) e.g.,givenalive(X) :- not dead(X). alive(joe)succeedsifdead(joe)fails

  35. Prolog examples Depth-firstsearchfromastartstate X: No need toloopoverS:successorsucceedsforeach Appendingtwoliststo produceathird: append([],Y,Y). append([X|L],Y,[X|Z]) :-append(L,Y,Z). query: append(A,B,[1,2]) ?

  36. Resolution: brief summary Fullfirst-orderversion: l1 ∨ …∨ lk,m1 ∨ …∨ mn (l1 ∨ …li-1 ∨ li+1 ∨…∨ lk ∨m1 ∨ …∨ mj-1 ∨mj+1 ∨ …∨ mn)θ whereUNIFY(li,¬mj)=θ. Forexample, ¬Rich(x)∨ Unhappy(x) Rich(Ken) Unhappy(Ken) withθ={x/Ken} Apply resolutionstepstoCNF(KB∧ ¬α);completeforFOL

  37. Conversion to CNF

  38. Conversion to CNF contd.

  39. Resolution proof: definite clauses ¬

More Related