Cps270 First Order Logic

29
CPS 270: Artificial Intelligence http://www.cs.duke.edu/courses/fall08/cps270/ First-Order Logic Instructor: Vincent Conitzer

description

FirstOrderLogic

Transcript of Cps270 First Order Logic

CPS 270: Artificial Intelligencehttp://www.cs.duke.edu/courses/fall08/cps270/irst!"rder #ogicInstructor: Vincent Conitzer Limitations of propositional logicSo far we studied propositional logicSome English statements are hard to model in propositional logic:If your roommate is wet because of rain your roommate must not be carrying an$ umbrella!"athetic attempt at modeling this:#oommate$et%ecause&f#ain '( )*&+)#oommateCarrying,mbrella-. /*0 *&+)#oommateCarrying,mbrella1. /*0 *&+)#oommateCarrying,mbrella2. /*0 3. "roblems with propositional logic*o notion of ob4ects*o notion of relations among ob4ects#oommateCarrying,mbrella- is instructi5e to us suggesting 6there is an ob4ect we call #oommate6there is an ob4ect we call ,mbrella-6there is a relationship Carrying between these two ob4ects7ormally none of this meaning is there68ight as well ha5e replaced #oommateCarrying,mbrella-by " Elements of first9order logic&b4ects: can gi5e these names such as ,mbrella- "erson- :ohn Earth 3#elations: Carrying); ;. Is/n,mbrella);.6Carrying)"erson- ,mbrella-. Is,mbrella),mbrella-.6#elations with one ob4ect ' unary relations ' properties7unctions: #oommate);.6#oommate)"erson-.Ee@s bas>etball team defeats any other bas>etball team!for all =: ))Is%as>etball+eam)=. /*0 *&+)='%as>etball+eam&f)0u>e... '( 0efeats)%as>etball+eam&f)0u>e. =..E5ery team defeats some other team!for all =: )Is+eam)=. '( )there e=ists y: )Is+eam)y. /*0 *&+)='y. /*0 0efeats)=y.... Is this a tautologyA"roperty " implies property B or propery " implies property B )or both.!for all =: ))")=. '( B)=.. )B)=. '( ")=...)for all =: )")=. '( B)=.. )for all =: )B)=. '( ")=... #elationship between uni5ersal and e=istentialfor all =: ais e@s roommate then any property of :ohn is also a property of :ac>@s roommate!):ohn'#oommate):ac>.. '( for all p: )p):ohn. '( p)#oommate):ac>... If a property is inherited by children then for any thing if that property is true of it it must also be true for any child of it!for all p: )IsInherited%yChildren)p. '( )for all = y: ))IsChild&f)=y. /*0 p)y.. '( p)=.... /=ioms and theorems/=ioms: basic facts about the domain our initial! >nowledge base+heorems: statements that are logically deri5ed from a=ioms S,%S+S,%S+ replaces one or more 5ariables with something else7or e=ample: 6S,%S+)C=D:ohnE Is?ealthy)=. '( *&+)?as/Cold)=... gi5es us6Is?ealthy):ohn. '( *&+)?as/Cold):ohn.. Instantiating E a.where > is a constant that does not appear elsewhere in the >nowledge base )S>olem constant.0on@t need original sentence anymore Instantiating e=istentials after uni5ersalsfor all =: there e=ists y: Is"arent&f)y=.$#&*F: for all =: Is"arent&f)> =.#IF?+: for all =: Is"arent&f)>)=. =.Introduces a new function )S>olem function.3 again assuming > has not been used pre5iously Feneralized modus ponensfor all =: Lo5es):ohn =.6 :ohn lo5es e5ery thingfor all y: )Lo5es)y :ane. '( 7eels/ppreciated%y):ane y..6 :ane feels appreciated by e5ery thing that lo5es herCan infer from this:7eels/ppreciated%y):ane :ohn.?ere we used the substitution C=D:ane yD:ohnE6*ote we used different 5ariables for the different sentencesFeneral ,*I7G algorithms for finding a good substitution Heeping things as general as possible in unificationConsider Edible%y$ith 6 e;g; Edible%y$ith)Soup :ohn Spoon. 6 :ohn can eat soup with a spoonfor all =: for all y: Edible%y$ith)%read = y.6 /nything can eat bread with anythingfor all u: for all 5: )Edible%y$ith)u 5 Spoon. '( Can%eSer5edIn%owl+o)u5..6 /nything that is edible with a spoon by something can be ser5ed in a bowl to that somethingSubstitution: C=Dz yDSpoon uD%read 5DzEFi5es: for all z: Can%eSer5edIn%owl+o)%read z./lternati5e substitution C=D:ohn yDSpoon uD%read 5D:ohnE would only ha5e gi5en Can%eSer5edIn%owl+o)%read :ohn. which is not as general #esolution for first9order logicfor all =: )*&+)Hnows):ohn =.. Is8ean)=. Lo5es):ohn =..6:ohn lo5es e5erything he >nows with the possible e=ception of mean thingsfor all y: )Lo5es):ane y. Hnows)y :ane..6:ane lo5es e5erything that does not >now her$hat can we unifyA$hat can we concludeA,se the substitution: C=D:ane yD:ohnEFet: Is8ean):ane. Lo5es):ohn :ane. Lo5es):ane :ohn.Complete )i;e; if not satisfiable will find a proof of this. if we can remo5e literals that are duplicates after unification6/lso need to put e5erything in canonical form first *otes on inference in first9order logic0eciding whether a sentence is entailed is semidecidable: there are algorithms that will e5entually produce a proof of any entailed sentenceIt is not decidable: we cannot always conclude that a sentence is not entailed )E=tremely informal statement of. FIdel@s Incompleteness +heorem7irst9order logic is not rich enough to model basic arithmetic7or any consistent system of a=ioms that is rich enough to capture basic arithmetic )in particular mathematical induction. there e=ist true sentences that cannot be pro5ed from those a=ioms / more challenging e=erciseSuppose:6+here are e=actly J ob4ects in the world6If = is the spouse of y then y is the spouse of = )spouse is a function i;e; e5erything has a spouse."ro5e:6Something is its own spouse 8ore challenging e=ercisethere e=ist = y z: )*&+)='y. /*0 *&+)='z. /*0 *&+ )y'z..for all w = y z: )w'= w'y w'z ='y ='z y'z.for all = y: ))Spouse)=.'y. '( )Spouse)y.'=..for all = y: ))Spouse)=.'y. '( *&+)='y.. (for the sake of contradiction)Try to do this on the board ,mbrellas in first9order logicGou >now the following things:6Gou ha5e e=actly one other person li5ing in your house who is wet6If a person is wet it is because of the rain the sprin>lers or both6If a person is wet because of the sprin>lers the sprin>lers must be on6If a person is wet because of rain that person must not be carrying any umbrella6+here is an umbrella that li5es in! your house which is not in its house6/n umbrella that is not in its house must be carried by some person who li5es in that house6 Gou are not carrying any umbrellaCan you conclude that the sprin>lers are onA +heorem pro5er on the web http:DDwww;spass9pro5er;orgDwebspassDinde=;html )use 90oc"roof option. beginKproblem)+iny"roblem.; listKofKdescriptions; name)CL+iny"roblemLE.; author)CLVincent ConitzerLE.; status)un>nown.; description)CL:ust a testLE.; endKofKlist; listKofKsymbols; predicatesM)71.)F1.N; endKofKlist; listKofKformulae)a=ioms.; for%ula&e'ists&()*+&),,,. for%ula&forall&(-*+i%plies&&-,+.&-,,,,. endKofKlist; listKofKformulae)con4ectures.; for%ula&e'ists&(/*+.&/,,,. endKofKlist; endKproblem; +heorem pro5er on the web3 beginKproblem)+hreeSpouses.; listKofKdescriptions; name)CL+hreeSpousesLE.; author)CLVincent ConitzerLE.; status)un>nown.; description)CL+hree SpousesLE.; endKofKlist; listKofKsymbols; functionsMspouseN; endKofKlist; listKofKformulae)a=ioms.; for%ula&e'ists&(0*+e'ists&(1*+e'ists&(2*+and&not&e3ual&0+1,,+and&not&e3ual&0+2,,+not&e3ual&1+2,,,,,,,,. for%ula&forall&(/*+forall&(0*+forall&(1*+forall&(2*+or&e3ual&/+0,+or&e3ual&/+1,+or&e3ual&/+2,+or&e3ual&0+1,+or&e3ual&0+2,+e3ual&1+2,,,,,,,,,,,. for%ula&forall&(0*+forall&(1*+i%plies&e3ual&spouse&0,+1,+e3ual&spouse&1,+0,,,,,. endKofKlist; listKofKformulae)con4ectures.; for%ula&e'ists&(0*+e3ual&spouse&0,+0,,,. endKofKlist; endKproblem; +heorem pro5er on the web3 beginKproblem)+wo&r+hreeSpouses.; listKofKdescriptions; name)CL+wo&r+hreeSpousesLE.; author)CLVincent ConitzerLE.; status)un>nown.; description)CL+wo&r+hreeSpousesLE.; endKofKlist; listKofKsymbols; functionsMspouseN; endKofKlist; listKofKformulae)a=ioms.; for%ula&e'ists&(0*+e'ists&(1*+not&e3ual&0+1,,,,,. for%ula&forall&(/*+forall&(0*+forall&(1*+forall&(2*+or&e3ual&/+0,+or&e3ual&/+1,+or&e3ual&/+2,+or&e3ual&0+1,+or&e3ual&0+2,+e3ual&1+2,,,,,,,,,,,. for%ula&forall&(0*+forall&(1*+i%plies&e3ual&spouse&0,+1,+e3ual&spouse&1,+0,,,,,. endKofKlist; listKofKformulae)con4ectures.; for%ula&e'ists&(0*+e3ual&spouse&0,+0,,,. endKofKlist; endKproblem; +heorem pro5er on the web3 beginKproblem),mbrellas.; listKofKdescriptions; name)CL,mbrellasLE.; author)CLC"S2O-LE.; status)un>nown.; description)CL,mbrellasLE.; endKofKlist; listKofKsymbols; functionsM)?ouse1.)Gou-.N; predicatesM)"erson1.)$et1.)$et0ue+o#1.)$et0ue+oS1.)Sprin>lers&n-.),mbrella1.)Carrying2.)*ot/t?ome1.N; endKofKlist; listKofKformulae)a=ioms.; formula)forall)MPNforall)MGNimplies)and)"erson)P.and)"erson)G.and)not)e