Download presentation
Presentation is loading. Please wait.
Published byKory Boone Modified over 8 years ago
1
Ch. 9 – FOL Inference Supplemental slides for CSE 327 Prof. Jeff Heflin
2
Backward Chaining function FOL-BC-ASK (KB, goals, ) returns a set of substitutions local answers, a set of substitutions, initially empty if goals is empty then return { } q’ SUBST( ,FIRST(goals)) for each sentence r in KB where STANDARDIZE-APART(r) = (p 1 … p n q) and ’ UNIFY(q,q’) succeeds new_goals PREPEND([p 1,…,p n ], REST(goals)) answers FOL-BC-ASK(KB, new_goals, COMPOSE( ’, )) answers return answers From Figure 9.6, p. 288
3
Backward Chaining Example Set of sentences: S 1 : x 1,y 1 child(x 1,y 1 ) parent(y 1,x 1 ) S 2 : x 2,y 2 parent(x 2,y 2 ) female(x 2 ) mother(x 2,y 2 ) S 3 : child(Lisa,Homer) S 4 : child(Lisa,Marge) S 5 : female(Marge) Note: variables have already been standardized apart using subscripts Query: x mother(x,Lisa)
4
Backward Chaining Search Tree mother(x 0,Lisa) parent(x 0,Lisa), female(x 0 ) child(Lisa,x 0 ), female(x 0 ) female(homer)female(marge) match S 4 ’={x 0 /Marge} match rule S 2 ’={x 2 /x 0, y 2 /Lisa} match rule S 1 ’={y 1 /x 0, x 1 /Lisa} match S 3 ’={x 0 /Homer} no matches answers={} (FAIL!) matches S 5 ’={ x 0 /Marge} answers= { x 0 /Marge}
5
Forward Chaining function FOL-FC-ASK (KB, ) returns a substitution or false local new, the new sentences inferred on each iteration repeat until new is empty new {} for each sentence r in KB do (p 1 … p n q ) STANDARDIZE-APART(r) for each such that SUBST( , p 1 … p n )= SUBST( , p 1 ’ … p n ’) for some p 1 ’,…, p n ’ in KB q’ SUBST( ,q) if q’ is not a renaming of some sentence already in KB or new then do add q’ to new UNIFY(q’, ) if is not fail then return add new to KB return answers From Figure 9.3, p. 282
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.