1 / 6

Ch. 9 – FOL Inference

Ch. 9 – FOL Inference. Supplemental slides for CSE 327 Prof. Jeff Heflin. EBNF Grammar for Prolog. <program>  <clause> { <clause> } <clause>  <fact> | <rule> <fact>  <compound> . <compound>  <atom> ( <termlist> ) <rule>  <head> :- <body> . <head>  <compound>

tyra
Download Presentation

Ch. 9 – FOL Inference

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. EBNF Grammar for Prolog <program>  <clause> { <clause> }<clause>  <fact> | <rule><fact>  <compound> .<compound>  <atom> ( <termlist> )<rule>  <head> :- <body> .<head>  <compound> <body>  <compound> { , <compound> } <termlist>  <term> { , <term> } <term>  <atom> | <num> | <var> | … • Notes: • { <a> } means 0, 1 or more <a>’s • This grammar is slightly more restrictive than the actual language

  3. Backward Chaining functionFOL-BC-Ask (KB, goals, ) returns a set of substitutionslocalanswers, a set of substitutions, initially empty if goals is empty then return { }q’ Subst( ,First(goals))for each sentence rin KB whereStandardize-Apart(r) = (p1… pn  q) and ’ Unify(q,q’) succeedsnew_goals  Prepend([p1,…,pn],Rest(goals))answers  FOL-BC-Ask(KB, new_goals, Compose(’, ))  answersreturnanswers Alternative description of Figure 9.6, p. 338

  4. Backward Chaining Example Set of sentences: S1: x1,y1 child(x1,y1)  parent(y1,x1) S2: x2,y2 parent(x2,y2)  female(x2)  mother(x2,y2) S3: child(Lisa,Homer) S4: child(Lisa,Marge) S5: female(Marge) Note: variables have already been standardized apart using subscripts Query: x mother(x,Lisa)

  5. Backward Chaining Search Tree mother(x0,Lisa) match rule S2’={x2/x0, y2/Lisa} parent(x0,Lisa), female(x0) match rule S1’={y1/x0, x1/Lisa} child(Lisa,x0), female(x0) match S4 ’={x0/Marge} match S3 ’={x0/Homer} female(Homer) female(Marge) matches S5 ’={ x0/Marge} no matches answers={} (FAIL!)  answers={ x0/Marge}

  6. Forward Chaining functionFOL-FC-Ask (KB,) returns a substitution or falselocalnew, the new sentences inferred on each iteration repeat until new is emptynew  {}for each sentence rin KBdo (p1… pn  q )  Standardize-Apart (r)for each  such thatSubst( , p1… pn)=Subst( , p1’ … pn’) for some p1’ ,…, pn’ in KBq’ Subst( ,q)if q’ does not unify with some sentence already in KB or newthen do add q’ to new Unify(q’, ) if  is not failthen return add new to KBreturnanswers From Figure 9.3, p. 332

More Related