17
Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

Embed Size (px)

Citation preview

Page 1: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

Inference in FOL

Compared to predicate logic,more abstract reasoning and specific conclusions

Page 2: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

FOL knowledge bases

Facts about environment involve statements about specific objects E.g., Dentist(Bill), Likes(Mary, Candy)

General knowledge is mainly statements about sets of objects involving quantifiers E.g., x Dentist(x) ⇒ Likes(x, Candy)

Page 3: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Deductive reasoningfrom general to specific

how do quantified sentences get applied to facts? universal quantifier existential quantifier

instantiation: substituting a reference to an object for a variable

inference: conclusions entailed in KB

Page 4: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Instantiating Universal quantifier (UI)

x p(x) statement is always true any substitution makes a legitimate

statement format:

x p(x)subst( {x/k}, p(x) )

(K is any constant or function from KB)p(K)

Page 5: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Instantiating Existential quantifier (UI) x p(x) statement is true for some object name the object for which it is true format:

x p(x)subst( {x/k}, p(x) )

(k is a new constant, never used beforeSkolem constant)

p(k)

Page 6: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Brute force reasoning

use instantiation to create a ‘propositional’ logic KB

completeBUT... presence of functions causes infinitely

large set of sentences (Father(Al), Father(Father(Al))

semi-decidable (disproofs never end)

Page 7: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Direct reasoning

x man(x) mortal(x) man(Socrates)1. Substitute for instantiation:subst( {x/Socrates}, man(x) mortal(x))man(Socrates) mortal(Socrates)2. modus ponensmortal(Socrates)

Page 8: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Substitutions for reasoning

generalized modus ponens

p1, p2, p3, (p1 ^ p2 ^ p3 )=> q

subst( {x1/k1, x2/k2..}, q)

Unification: substitutions so that the sentences are consistently instantiated

Page 9: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Substitutions for reasoning generalized modus ponens example

Parent(Art,Barb),

Parent(Barb,Carl),

(Parent(x,y) ^ Parent(y,z ) ⇒ Grandparent(x,z)

subst( {x/Art, y/Barb,z/Carl}, q)

(Parent(Art,Barb) ^ Parent(Barb,Carl )⇒ Grandparent(Art,Carl)

Grandparent(Art,Carl)

Page 10: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Consistent substitutions

unification algorithm – p.278 or variant here

examplex likes(Bill, x) (Bill likes everyone)y likes(y, Mary) (everyone likes Mary)subst( {Bill/y, Mary/x}, likes(Bill, Mary)) makes two predicates identical

Page 11: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Application

examplex likes(Bill, x)y likes(y, Mary) => ~trusts(y,Father(Mary))

subst( {Bill/y, Mary/x}, likes(Bill, Mary)) makes two predicates identicallikes(Bill, Mary),likes(Bill, Mary) => ~trusts(Bill,Father(Mary)) ~trusts(Bill,Father(Mary))

Page 12: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Examples

unify: Likes(x,Art), Likes(Father(y), y)

{Art/y} Likes(x,Art), Likes(Father(Art), Art)

{Art/y, Father(Art)/x}

unify: Likes(x,Art), Likes(Bart, x)

fails, can’t subst x for Art and Bart

Page 13: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Examples unify:

Likes(x,Art), Likes(Bart, x) fails, can’t subst x for Art and Bart

BUT where did ‘x’ come from? Art likes everybody: x Likes(x, Art) Everybody likes Bart: x Likes(Bart, x)standardize apart: z0 Likes(Bart, z0)

then Likes(Bart, Art) is OK withsubst ( {Bart/x, Art/z0} )

Page 14: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

Unify(L1, L2) // L1, L2 are both predicates or both objects

1. If (L1 or L2 is variable or constant)i. if (L1==L2) return {} (no subst required)

ii. if (L1 is variable) – if L1 in L2 return fail else return {L2/L1}

iii. if (L2 is variable) – if L2 in L1 return fail else return {L1/L2}iv. return fail // both constants or functions

// L1,L2 are predicates if we get to here

2. If predicate symbols of L1,L2 not identical, return fail

3. If L1,L2 have different number of arguments, return fail4. Subst = {}5. For (i = 1 to number of arguments in L1,L2)

i. S = Unify(L1.argument[i],L2.argument[i])ii. if (S==fail) return failiii. if (S!={})

apply S to remainder of L1,L2

Subst = Subst U S

6. Return Subst

Unification algorithm

Page 15: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

Unify(L1, L2) // L1, L2 are predicates or objects1. If (L1 or L2 is variable or constant)

i. if (L1==L2) Art, Art x,x

ii. if (L1 is variable) – if L1 in L2 return fail else return {L2/L1}x, Father(x) x, Mother(y)

i. if (L2 is variable) – if L2 in L1 return fail else return {L1/L2} <similar>ii. return fail Art, Bart

// L1,L2 are predicates if we get to here

2. If predicates of L1,L2 not identical Likes(x,y) Brother(z,w)

3. If L1,L2 have different # of arguments Band(x,y,z), Band(t,v)4. Subst = {}5. For (i = 1 to # of args in L1,L2)

i. S = Unify(L1.arg[i],L2.arg[i]) Likes(Bill,x) Likes(y,Father(y)) ii. if (S==fail) return failiii. if (S!={})

apply S to remainder of L1,L2 Likes(Bill,x) Likes(Bill,Father(Bill)) Subst = Subst U S

6. Return Subst

Unification algorithm - examples

Page 16: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Inference: Reasoning methods

Forward chaining Backward chaining Resolution

Page 17: Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions

D. Goforth, COSC 4117, fall 2006

Resolution

1. convert sentences to equivalent conjunctive normal form (CNF)

2. apply resolution refutation