Ch 9 FOL Inference Supplemental slides for CSE

  • Slides: 5
Download presentation
Ch. 9 – FOL Inference Supplemental slides for CSE 327 Prof. Jeff Heflin

Ch. 9 – FOL Inference Supplemental slides for CSE 327 Prof. Jeff Heflin

Backward Chaining function FOL-BC-ASK (KB, goals, ) returns a set of substitutions local answers,

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 … pn q) and ’ UNIFY(q, q’) succeeds new_goals PREPEND([p 1, …, pn], REST(goals)) answers FOL-BC-ASK(KB, new_goals, COMPOSE( ’, )) answers return answers From Figure 9. 6, p. 288

Backward Chaining Example Set of sentences: S 1: x 1, y 1 child(x 1,

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)

Backward Chaining Search Tree match rule S 2 ’={x 2/x 0, y 2/Lisa} mother(x

Backward Chaining Search Tree match rule S 2 ’={x 2/x 0, y 2/Lisa} mother(x 0, Lisa) parent(x 0, Lisa), female(x 0) match rule S 1 ’={y 1/x 0, x 1/Lisa} match S 3 ’={x 0/Homer} female(homer) no matches answers={} (FAIL!) child(Lisa, x 0), female(x 0) match S 4 ’={x 0/Marge} female(marge) matches S 5 ’={ x 0/Marge} answers= { x 0/Marge}

Forward Chaining function FOL-FC-ASK (KB, ) returns a substitution or false local new, the

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 … pn q ) STANDARDIZE-APART(r) for each such that SUBST( , p 1 … pn)= SUBST( , p 1’ … pn’) for some p 1’ , …, pn’ 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