10
PracticalProblemswithPropositionalization
YPropositionalizationseemstogeneratelotsofirrelevantsentences.
YE.g.,from ¦x Kingx,GreedyxÔEvilx
KingJohn
¦y Greedyy
BrotherRichard;John
itseemsobviousthatEvilJohn,butpropositionalizationproduceslotsoffacts
suchasGreedyRichardthatareirrelevant
YWithp-arypredicatesandnconstants,therearepn
k
instantiations
YWithfunctionsymbols,itgetsnuchmuchworse!
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
11
unication
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
12
Plan
YWehavetheinferencerule
¦x Kingx,GreedyxÔEvilx
YWehavefactsthat(partially)matchtheprecondition
KingJohn
¦y Greedyy
YWeneedtomatchthemupwithsubstitutions: x~John;y~Johnworks
unication
generalizedmodusponens
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
13
Unication
YUNIFY;if
p q
KnowsJohn;xKnowsJohn;Jane
KnowsJohn;xKnowsy;Mary
KnowsJohn;xKnowsy;Mothery
KnowsJohn;xKnowsx;Mary
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
14
Unication
YUNIFY;if
p q
KnowsJohn;xKnowsJohn;Janex~Jane
KnowsJohn;xKnowsy;Mary
KnowsJohn;xKnowsy;Mothery
KnowsJohn;xKnowsx;Mary
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
15
Unication
YUNIFY;if
p q
KnowsJohn;xKnowsJohn;Janex~Jane
KnowsJohn;xKnowsy;Mary x~Mary;y~John
KnowsJohn;xKnowsy;Mothery
KnowsJohn;xKnowsx;Mary
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
16
Unication
YUNIFY;if
p q
KnowsJohn;xKnowsJohn;Janex~Jane
KnowsJohn;xKnowsy;Mary x~Mary;y~John
KnowsJohn;xKnowsy;Motheryy~John;x~MotherJohn
KnowsJohn;xKnowsx;Mary
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
17
Unication
YUNIFY;if
p q
KnowsJohn;xKnowsJohn;Janex~Jane
KnowsJohn;xKnowsy;Mary x~Mary;y~John
KnowsJohn;xKnowsy;Motheryy~John;x~MotherJohn
KnowsJohn;xKnowsx;Mary fail
YStandardizingapart Knowsz17;Mary
KnowsJohn;xKnowsz17;Mary z17~John;x~Mary
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
18
generalizedmodusponens
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
20
forwardchaining
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
21
ExampleKnowledge
YThelawsaysthatitisacrimeforanAmericantosellweaponstohostilenations.
The country Nono, an enemy of America, has some missiles, and all of its
missilesweresoldtoitbyColonelWest,whoisAmerican.
YProvethatCol.Westisacriminal
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
22
ExampleKnowledgeBase
Y:::itisacrimeforanAmericantosellweaponstohostilenations:
Americanx,Weapony,Sellsx;y;z,HostilezÔCriminalx
YNono:::hassomemissiles
,i.e.,§xOwnsNono;x,Missilex:
OwnsNono;M1andMissileM1
Y:::allofitsmissilesweresoldtoitbyColonelWest
¦x Missilex,OwnsNono;xÔSellsWest;x;Nono
YMissilesareweapons:
MissilexWeaponx
YAnenemyofAmericacountsashostile:
Enemyx;AmericaÔHostilex
YWest,whoisAmerican:::
AmericanWest
YThecountryNono,anenemyofAmerica :::
EnemyNono;America
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
23
ForwardChainingProof
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
24
ForwardChainingProof
(Note:¦x Missilex,OwnsNono;xÔSellsWest;x;Nono)
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
25
ForwardChainingProof
(Note:Americanx,Weapony,Sellsx;y;z,HostilezÔCriminalx)
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
26
PropertiesofForwardChaining
YSoundandcompleteforrst-orderdeniteclauses
(proofsimilartopropositionalproof)
YDatalog(1977)=rst-orderdeniteclauses+nofunctions(e.g.,crimeKB)
ForwardchainingterminatesforDataloginpolyiterations: atmostpn
k
literals
YMaynotterminateingeneralifisnotentailed
YThisisunavoidable: entailmentwithdeniteclausesissemidecidable
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
27
EfciencyofForwardChaining
YSimpleobservation: noneedtomatcharuleoniterationk
ifapremisewasn'taddedoniterationk1
Ômatcheachrulewhosepremisecontainsanewlyaddedliteral
YMatchingitselfcanbeexpensive
YDatabaseindexing O1retrievalofknownfacts
e.g.,queryMissilexretrievesMissileM1
YMatchingconjunctivepremisesagainstknownfactsisNP-hard
YForwardchainingiswidelyusedin
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
28
HardMatchingExample
Diffwa;nt,Diffwa;sa,
Diffnt;qDiffnt;sa,
Diffq;nsw,Diffq;sa,
Diffnsw;v,Diffnsw;sa,
Diffv;saÔColorable
DiffRed;BlueDiffRed;Green
DiffGreen;RedDiffGreen;Blue
DiffBlue;RedDiffBlue;Green
YColorableisinferredifftheconstraintsatisfactionproblemhasasolution
YCSPsinclude3SATasaspecialcase,hencematchingisNP-hard
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
29
ForwardChainingAlgorithm
functionFOL-FC-ASK(KB,)returnsasubstitutionorfalse
repeat untilnewisempty
newg
for eachsentencerinKBdo
p1,:::,pnÔqSTANDARDIZE-APART(r)
for eachsuchthatp1,:::,pnp
1
,:::,p
n
forsomep
1
;:::;p
ninKB
q
SUBST(,q)
ifq
isnotarenamingofasentencealreadyinKBornewthen do
addq
tonew
UNIFY(q
,)
ifisnotfailthen return
addnewtoKB
returnfalse
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
30
backwardchaining
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
31
BackwardChaining
YStartwithquery
YCheckifitcanbederivedbygivenrulesandfacts
applyrulesthatinferthequery
recurseoverpre-conditions
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
32
BackwardChainingExample
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
33
BackwardChainingExample
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
34
BackwardChainingExample
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
35
BackwardChainingExample
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
36
BackwardChainingExample
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
37
BackwardChainingExample
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
38
BackwardChainingExample
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
39
PropertiesofBackwardChaining
YDepth-rstrecursiveproofsearch: spaceislinearinsizeofproof
YIncompleteduetoinniteloops
Ôxbycheckingcurrentgoalagainsteverygoalonstack
YInefcientduetorepeatedsubgoals(bothsuccessandfailure)
Ôxusingcachingofpreviousresults(extraspace!)
YWidelyused(withoutimprovements!) for
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
40
BackwardChainingAlgorithm
functionFOL-BC-ASK(KB,goals,)returnsasetofsubstitutions
inputs:KB,aknowledgebase
goals,alistofconjunctsformingaquery(alreadyapplied)
,thecurrentsubstitution,initiallytheemptysubstitutiong
local variables:answers,asetofsubstitutions,initiallyempty
ifgoalsisemptythen return
q
SUBST(,FIRST(goals))
for eachsentencerinKB
whereSTANDARDIZE-APART(r)=p1,:::,pnq
and
UNIFY(q,q
)succeeds
newgoalsp1;:::;pnSREST(goals)
answersFOL-BC-ASK(KB,newgoals,COMPOSE(
,))8answers
returnanswers
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
41
logicprogramming
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
44
PrologSystems
YEfcientunicationby
YEfcientretrievalofmatchingclausesbydirectlinking
YDepth-rst,left-to-rightbackwardchaining
YBuilt-inpredicatesforarithmeticetc.,e.g.,X is Y*Z+3
YClosed-worldassumption(negationasfailure)
e.g.,givenalive(X) :- not dead(X).
alive(joe)succeedsifdead(joe)fails
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
45
resolution
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017
46
Resolution:BriefSummary
YFullrst-orderversion:
`1--`k; m 1--mn
`1--`i1-`i1--`k-m1--mj1-mj1--mn
whereUNIFY`i; mj.
YForexample,
Richx-Unhappyx
RichKen
UnhappyKen
withx~Ken
YApplyresolutionstepstoCNFKB, ;completeforFOL
Philipp Koehn Articial Intelligence: Inference in First-Order Logic 16 March 2017