1 / 14

Control Algorithms 1 Chapter 6

Control Algorithms 1 Chapter 6. Pattern Search. Problem with Predicate Calculus --No mechanism for applying rules Task --Develop a general search procedure for predicate calculus by applying recursive search to a space of logical inferences Forms the basis for prolog. Given a 3X3 matrix

damisi
Télécharger la présentation

Control Algorithms 1 Chapter 6

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. Control Algorithms 1Chapter 6 Pattern Search

  2. Problem with Predicate Calculus --No mechanism for applying rules Task --Develop a general search procedure for predicate calculus by applying recursive search to a space of logical inferences Forms the basis for prolog

  3. Given a 3X3 matrix • One move paths mv(1,8) mv(4,9) mv(8,3) mv(1,6) mv(4,3) mv(8,1) mv(2,9) mv(6,1) mv(9,2) mv(2,7) mv(6,7) mv(9,4) mv(3,4) mv(7,2) mv(3,8) mv(7,6) 1 2 3 Knight’s Tour 5 6 4 7 8 9

  4. Two-Move Paths

  5. Three Move Paths There is a three move path from x to y if there is a 1 move path from x to some state z and a two move path from z to y

  6. path3(1,4) {1/x,4/y) mv(1,z)^path2(z,4) prove 1st conjunct {8/z} mv(1,8)^path2(8,4) 1st conjunct is T, prove 2nd conjunct {8/x,4/y} mv(8,z)^mv(z,4) prove 1st conjunct {3/z} mv(8,3)^mv(3,4) both conjuncts are T T T T Two move paths Three move paths One move paths mv(1,8) mv(4,9) mv(8,3) mv(1,6) mv(4,3) mv(8,1) mv(2,9) mv(6,1) mv(9,2) mv(2,7) mv(6,7) mv(9,4) mv(3,4) mv(7,2) mv(3,8) mv(7,6) Example

  7. path3(1,4) {1/x,4/y) mv(1,z)^path2(z,4) {8/z} mv(1,8)^path2(8,4) {8/x,4/y} mv(8,z)^mv(z,4) {1/z} mv(8,1)^mv(1,4) f backtrack mv(8,z)^mv(z,4) {3/z} mv(8,3)^mv(3,4) T T T What if mv(8,1) appeared before mv(8,3)?

  8. To Generalize We have 1 move paths, 2 move paths, three move paths and, in general, But how do we stop?

  9. Base Case

  10. Suppose, again, that mv(8,1) appears before mv(8,3) path(1,4) mv(1,z)^path(z,4) {8/z} mv(1,8)^path(8,4) mv(8,z)^path(z,4) {1/z} mv(8,1)^path(1,4) Produces an endless loop

  11. path(1,4) mv(1,z)^path(z,4) {8/z} mv(1,8)^path(8,4) mv(8,z)^path(z,4) {1/z} mv(8,1)^path(1,4) Backtrack mv(8,z)^path(z,4) {3/z} mv(8,3)^path(3,4) mv(3,z)^path(z,4) {4/z} mv(3,4)^path(4,4) T T T T SolutionIf a path has been tried, don’t retry(global closed list)

  12. Goal Directed • Depth First Control Structure • Basis of Prolog • We’ve been running the algorithm on pp. 198-99 informally all along. There are six cases • The goal is to return the substitution set that will render the expression true. Leads To: Pattern Search

  13. If Current Goal is a member of the closed list --return F, Backtrack • If Current Goal unifies with a fact--Current Goal is T • If Current Goal unifies with a rule conclusion --apply unifying substitutions to the premise --try to prove premise --if successful, T Six Cases

  14. If Current Goal is a disjunction (or’d) --try to prove each disjunct until you exhaust them or find one that is T • If Current Goal is a conjunction --try to prove each conjunct --if successful, apply substitutions to other conjuncts --if unsuccessful, backtrack, trying new substitutions until they are exhausted • If Current Goal is negated (~p) --Try to prove p --If successful, current goal is F --If unsuccessful, current goal is T--In the algorithm, returned substitution set is {} when ~p is true, because the algorithm failed to find a substitution set that would make p true (i.e., ~p is T only when p is F) Continued

More Related