control algorithms 2 chapter 6
DESCRIPTION
Control Algorithms 2 Chapter 6. Production Systems. Emil Post (40’s): production systems as a formal theory of computation. Equivalent to a Turing machine. Set of rewrite rules for strings Newell and Simon (60’s, 70’s, 80’s): General Problem Solver - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/1.jpg)
Control Algorithms 2Chapter 6
Production Systems
![Page 2: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/2.jpg)
A Model of Computation
Emil Post (40’s): production systems as a formal theory of computation. Equivalent to a Turing machine. Set of rewrite rules for strings
Newell and Simon (60’s, 70’s, 80’s): General Problem Solver
John Anderson, Newell and Simon (80’s): learning models, ACT*, SOAR
Everyone (80’s): Expert systems
![Page 3: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/3.jpg)
Components
1. Set of rewrite rulesS NP VPLHS: Condition PartRHS: Action Part
![Page 4: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/4.jpg)
Components
2. Working Memory--Contains the current state of the world--Contains pattern that is matched against the condition of the production--When a match occurs, an action is performed
![Page 5: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/5.jpg)
Components
3. Recognize-Act Cycle--Isolate a subset of productions whose conditions match patterns in working memory: conflict set--Choose one of them
---Fire---Change contents of working memory
--Stop when there are no matches
![Page 6: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/6.jpg)
Example: Production system to generate the set of palindromes over the alphabet {0,1}
Productions1. N 0N02. N 1N13. N 04. N 15. N λ
Iteration Working Memory Conflict Set Fired0 N 1,2,3,4,511 0N0 1,2,3,4,512 00N00 1,2,3,4,523 001N100 1,2,3,4,534 0010100
![Page 7: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/7.jpg)
Knight’s Tour As a Production System
Given a 3X3 matrixWhat squares can a knight land on
What values of X, Y satisfy mv(X,Y) X,Y are elements of {1,2,…,9}
1 2 3
4 5 6
7 8 9
1. mv(1,8) 7. mv(4,9) 13. mv(8,3)
2. mv(1,6) 8. mv(4,3) 14. mv(8,1)
3. mv(2,9) 9. mv(6,1) 15. mv(9,2)
4. mv(2,7) 10. mv(6,7) 16. mv(9,4)
5. mv(3,4) 11. mv(7,2)
6. mv(3,8) 12. mv(7,6)
![Page 8: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/8.jpg)
The General Case (write on board)
),(),(),(( yxpathyzpathzxmvzyx
)),(( xxpathx
![Page 9: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/9.jpg)
Changes
1. Every expression of the form mv(x,y) becomes on(x) on(y)
2. Use no path expression3. Working memory is the current state and
goal state4. Conflict set is the set of rules that match
the current state5. Apply all rules until the current state
equals the goal state
![Page 10: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/10.jpg)
Productions (write on board)
1. mv(1,8) 7. mv(4,9) 13. mv(8,3)
2. mv(1,6) 8. mv(4,3) 14. mv(8,1)
3. mv(2,9) 9. mv(6,1) 15. mv(9,2)
4. mv(2,7) 10. mv(6,7) 16. mv(9,4)
5. mv(3,4) 11. mv(7,2)
6. mv(3,8) 12. mv(7,6)
1. on(1) -> on(8) 7. on(4) -> on(9) 13. on(8) -> on(3)
2. on(1) -> on(6) 8. on(4) -> on(3) 14. on(8) -> on(1)
3. on(2) -> on(9) 9. on(6) -> on(1) 15. on(9) -> on(2)
4. on(2) -> on(7) 10. on(6) -> on(7) 16. on(9) -> on(4)
5. on(3) -> on(4) 11. on(7) -> on(2)
6. on(3) -> on(8) 12. on(7) -> on(6)
![Page 11: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/11.jpg)
Can We Get from 1 to 2?
Iteration --Working Memory-- Conflict Set FiredCurrent Goal
0 1 2 1,2 11 8 2 13,14 132 3 2 5,6 5
3 4 2 7,8 74 9 2 15,16 155 2 2 Halt
![Page 12: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/12.jpg)
Pattern Search
path(1,2) {1/x,2/y}mv(1,z)^path(z,2) {8/z}mv(1,8)^path(8,2) mv(8,z)^path(z,2) {3/z} mv(8,3)^path(3,2) mv(3,z)^path(z,2) {4/z} mv(3,4)^path(4,2) mv(4,z)^path(z,2) {9/z} mv(4,9)^path(9,2) mv(9,z)^path(z,2) {2/z} mv(9,2)^path(2,2) t t t tt
Now look at working memory in the production system
![Page 13: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/13.jpg)
Equivalences
Production System Pattern Searchproductions mvworking memory path(X,Y)Fire lowest numbered production Choose first rule that unifies
Conclusion:Production Systems and pattern search are
equivalent (almost)
![Page 14: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/14.jpg)
Almost?
Loop DetectionPattern Search: global list of visited states
(closed)Production Systems: Record previously visited
states in working memory
Two new productions1. assert(X) causes X to be stored in WM2. been(X) is T if X has been visited3. assert(been(X)) records in wm that we’ve
already visited X
![Page 15: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/15.jpg)
Can be expressed in PC notation like this
),(),(^
))(()^(),((
yxpathyzpath
zbeenassertzbeenzxmvzyx
)),(( xxpathx
![Page 16: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/16.jpg)
Can We Get from 1 to 7?
Iteration --Working Memory-- Conflict Set FiredCurrent Goal been
0 1 7 1 1,2 11 8 7 8 13,14 132 3 7 3 5,6 53 4 7 4 7,8 74 9 7 9 15,16 155 2 7 2 3,4 3
(firing 3 causes been(9) to fail)2 7 2 4 47 7 7
Notice that this search is data driven
![Page 17: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/17.jpg)
Can Also Be Goal Driven
Instead of starting with current state=1 and goal = 7
Start with current state = 7 and goal = 1
![Page 18: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/18.jpg)
Works great for a 3x3 matrix
What about 8x8?Either enumerate all moves or encode them8 possible situations1. d(2),r(1) 5. u(2),r(1)2. d(2),l(1) 6. u(2),l(1)3. d(1),r(2) 7. u(1),r(2)4. d(1),l(2) 8. u(1),l(2)
![Page 19: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/19.jpg)
Not applicable everywhere
Situation have preconditions:Pre: row <=6, col <=7Situation 1: d(2),r(1)
Requires 4 new functionssq(r,c) returns cell number, left to right, top to
bottom where r is row number, c is column number
plus(r,2) returns r + 2eq(X,Y) T if X = Ylte(X,Y) T if X<=Y
![Page 20: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/20.jpg)
Encoding of situation 1: d(2),r(1)
mv(sq(R,C),sq(Nr,Nc))
lte(R,6)^eq(Nr,plus(R,2)) ^ %down two rows
lte(C,7)^eq(Nc,plus(c,1)) %right 1 col
There are 7 more analogous to this
![Page 21: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/21.jpg)
Control Loop for Knight’s Tour
))),(),,((
))),((()),(()),(),,(((
)),(),,(((
)),(),,(((
NcNrsqZcZrsqpath
ZcZrsqbeenassertZcZrsqbeenZcZrsqCRsqmvZcZr
NcNrsqCRsqpathNcNrCR
CRsqCRsqpathCR
![Page 22: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/22.jpg)
Strength of Production Systems
1. Said to model human cognition2. Separation of knowledge from control3. Natural mapping onto state space
search4. Modularity of production rules5. Simple tracing and explanation—
compare a rule with a line of c++ code6. Language independence
![Page 23: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/23.jpg)
And (this is the best part)
Production systems are easily rendered in prolog
We’ll consider several versions of the knight’s tour
![Page 24: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/24.jpg)
Record of Squares Visited
knight1
![Page 25: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/25.jpg)
Knight2
Put Visited Squares on a List
![Page 26: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/26.jpg)
Knight3
Stack Displays Path to Goal
![Page 27: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/27.jpg)
Knight4 (continued next class)
Queue Displays Path to Goal
![Page 28: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/28.jpg)
Cut
!◦Always succeeds the first time it is encountered◦When backtracked to, it causes the entire goal
in which it was contained to failWithout ! (4 2 path moves from 1)With ! (2 2 path moves from 1)
![Page 29: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/29.jpg)
Farmer Problem
A farmer (f) has a dog (d), a goat (g),and a cabbage (c)
A river runs North and SouthThe farmer has a boat that can hold only
the farmer and one other itemWithout the farmer
◦The goat will eat the cabbage◦The dog will eat the goat
How does the farmer (and his cohort) cross the river
![Page 30: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/30.jpg)
State Predicate
Define a predicate:state(F,D,G,C)Where F,D,G,C can be set to e or w
indicating the side of the river each is on.
![Page 31: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/31.jpg)
As State-Space
st(w,w,w,w)
st(e,e,w,w) st(e,w,e,w) s(e,w,w,e)
st(w,w,e,w)
s(e,e,e,w) st(e,w,e,e)
etc.
![Page 32: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/32.jpg)
Constructing a Move Predicate
st(e,e,-,-) st(w,w,-,-)Means Farmer and dog went from east to
westCan be rewritten:mv(st(X,X,G,C),st(Y,Y,G,C))
![Page 33: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/33.jpg)
Facts
opp(e,w)opp(w,e)
Givingmv(st(X,X,G,C),st(Y,Y,G,C)) :- opp(X,Y).opp(e,w).opp(w,e).
Four of these: 3 items to move + 1 solo return trip
![Page 34: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/34.jpg)
Unsafe
Goat and cabbage are together◦unsafe(st(X,D,Y,Y)) if X != Y◦unsafe(st(X,D,Y,Y)) :- opp(X,Y)
Dog and goat are together◦Unsafe(st(X,Y,Y,C) if X != Y◦Unsafe(st(X,Y,Y,C) :- opp(X,Y)
![Page 35: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/35.jpg)
Never move to an unsafe state
mv(st(X,X,G,C),st(Y,Y,G,C)) :- opp(X,Y), not(unsafe(st(Y,Y,G,C))).
![Page 36: Control Algorithms 2 Chapter 6](https://reader036.vdocument.in/reader036/viewer/2022062309/56814657550346895db371d9/html5/thumbnails/36.jpg)
Finding a Solution
Use Move/Control Technique from Knight3
Farmer Problem