control algorithms 1 chapter 6 control algorithms 1 chapter 6 pattern search
TRANSCRIPT
![Page 1: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/1.jpg)
Control Algorithms 1Chapter 6
Pattern Search
![Page 2: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/2.jpg)
So Far
◦Problem solving: search through states◦Predicate calculus: medium for describing
states◦Sound inference: method for generating new
states◦Formal search techniques: BT,DF,BF◦Reducing search space
Heuristic search AB pruning Passed over stochastic methods: will be explored
in machine learning units
![Page 3: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/3.jpg)
Next
◦Further search techniques that are part of AI Pattern search Production systems
![Page 4: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/4.jpg)
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
--Basis for prolog
![Page 5: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/5.jpg)
Knight’s Tour
Given a 3X3 matrixOne move paths (place on board)
1 2 3
4 5 6
7 8 9
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)
![Page 6: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/6.jpg)
Two-Move Paths
),(2),(),(( yxpathyzmvzxmvzyx
(Place on board)
![Page 7: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/7.jpg)
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
),(3),(2),(( yxpathyzpathzxmvzyx
(Place on board)
![Page 8: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/8.jpg)
Example: path3(1,4)
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 TT
TT
![Page 9: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/9.jpg)
What if mv(8,1) appeared before mv(8,3)?
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
TT
![Page 10: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/10.jpg)
To Generalize
We have 1 move paths, 2 move paths, three move paths and, in general,
),(),(),(( yxpathyzpathzxmvzyx
But how do we stop?
![Page 11: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/11.jpg)
Base Case
)),(( xxpathx
![Page 12: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/12.jpg)
Produces an endless loop
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)
![Page 13: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/13.jpg)
Solution
Global Closed List: If a path has been tried, don’t retry
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
TT
![Page 14: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/14.jpg)
Leads To: Pattern Search
Goal DirectedDepth First Control StructureBasis of PrologGoal: return the substitution set that will
render the expression true.
![Page 15: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/15.jpg)
Here’s the Surprise
Found on pp. 198-99We’ve been running the algorithm
informally all along
![Page 16: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/16.jpg)
![Page 17: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/17.jpg)
Six Cases: 1 - 3
1. If Current Goal is a member of the closed list--return F, Backtrack
2. If Current Goal unifies with a fact--Current Goal is T
3. If Current Goal unifies with a rule conclusion--apply unifying substitutions to the premise--try to prove premise
--if successful, T
![Page 18: Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649ef65503460f94c09a44/html5/thumbnails/18.jpg)
Six Cases: 4 - 6
4. Current Goal is a disjunction--Prove each disjunct until you exhaust them or find one that is T.
5. 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
6. 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)