Open Collections

UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

A recursively controlled production system : an implementation of a theory Girard, Jean-Louis 1983

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Notice for Google Chrome users:
If you are having trouble viewing or searching the PDF with Google Chrome, please download it here instead.

Item Metadata

Download

Media
831-UBC_1983_A6_7 G57.pdf [ 5.15MB ]
Metadata
JSON: 831-1.0051845.json
JSON-LD: 831-1.0051845-ld.json
RDF/XML (Pretty): 831-1.0051845-rdf.xml
RDF/JSON: 831-1.0051845-rdf.json
Turtle: 831-1.0051845-turtle.txt
N-Triples: 831-1.0051845-rdf-ntriples.txt
Original Record: 831-1.0051845-source.json
Full Text
831-1.0051845-fulltext.txt
Citation
831-1.0051845.ris

Full Text

A RECURSIVELY CONTROLLED PRODUCTION SYSTEM: AN IMPLEMENTATION OF A THEORY by JEAN-LOUIS GIRARD B.Sc. (Hons.) U n i v e r s i t y of B r i t i s h Columbia, 1982 A THESIS SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF SCIENCE in THE FACULTY OF GRADUATE STUDIES (Department of Computer Science) We accept t h i s t h e s i s as conforming to the r e q u i r e d standard. THE UNIVERSITY OF BRITISH COLUMBIA October, 1983 (c) Jean-Louis G i r a r d , 1983 In p r e s e n t i n g t h i s t h e s i s i n p a r t i a l f u l f i l m e n t o f the requirements f o r an advanced degree a t the U n i v e r s i t y o f B r i t i s h Columbia, I agree t h a t the L i b r a r y s h a l l make i t f r e e l y a v a i l a b l e f o r r e f e r e n c e and study. I f u r t h e r agree t h a t p e r m i s s i o n f o r e x t e n s i v e copying o f t h i s t h e s i s f o r s c h o l a r l y purposes may be granted by the head o f my department o r by h i s o r her r e p r e s e n t a t i v e s . I t i s understood t h a t copying o r p u b l i c a t i o n o f t h i s t h e s i s f o r f i n a n c i a l g a i n s h a l l not be allowed without my w r i t t e n p e r m i s s i o n . Department o f C'.nrn piA h r i^nc.p. The U n i v e r s i t y o f B r i t i s h Columbia 1956 Main Mall Vancouver, Canada V6T 1Y3 Date ( f f r k W I <T, I 9 8 ?> DE-6 (3/81) 11 ABSTRACT Pro d u c t i o n Systems are an i n h e r e n t l y n o n d e t e r m i n i s t i c computational model used i n the p a r s i n g of languages, i n a r t i f i c i a l i n t e l l i g e n c e r e s e a r c h , and i n formal c o m p u t a b i l i t y theory. For p r a c t i c a l purposes, a number of schemes have been proposed to e f f e c t the n o n d e t e r m i n i s t i c c h o i c e of p r o d u c t i o n s . These c o n t r o l techniques are o f t e n domain dependent and imbedded i n the i n t e r p r e t e r ; thus, reducing the g e n e r a l i t y and sometimes even the power of the model. T h i s t h e s i s i s concerned with a p r o d u c t i o n system which r e c u r s i v e l y determines the set of r u l e s to c o n s i d e r at the next higher l e v e l . Issues of metaknowledge r e p r e s e n t a t i o n and r e c u r s i v e c o n t r o l s t r u c t u r e s are d i s c u s s e d . The technique i s implemented i n a r e c u r s i v e l y c o n t r o l l e d p r o d u c t i o n system which i s used to a u t o m a t i c a l l y program a robot arm to accomplish an e l e c t r o n i c wire-wrapping tas k . i i i T a b l e o f C o n t e n t s A b s t r a c t i i T a b l e o f C o n t e n t s i i i T a b l e o f F i g u r e s v 1 I n t r o d u c t i o n 1 1.1 D e f i n i t i o n s 1 1 . 2 Mot i v a t i o n 3 1.3 T h e s i s O v e r v i e w 4 2 Framework o f t h e F i e l d 6 2.1 H i s t o r i c a l P e r s p e c t i v e 6 2.2 The Q u e s t f o r t h e E x p l i c i t C o n t r o l o f R e a s o n i n g 11 2.3 T h e s i s F o u n d a t i o n 16 2.4 Judgement C r i t e r i a 26 2.5 Domain Framework 27 3 The D e s i g n o f RCPS 31 3.1 R e p r e s e n t i n g t h e C o n t r o l L a n g u a g e 31 3.2 E x t e n d i n g t h e C o n t r o l L a n g u a g e R e p r e s e n t a t i o n 34 3.3 The C o n t r o l L e v e l PS 35 4 RCPS 38 4.1 S e a r c h S t r a t e g y 38 4.2 R u l e S y n t a x , S e m a n t i c s , a n d R e p r e s e n t a t i o n 39 4.3 R e p r e s e n t i n g S t a t e I n f o r m a t i o n i n P l a n s 43 4.4 The R e c u r s i v e V i r t u a l M a c h i n e 46 4.5 The RCPS Run-Time S y s t e m 49 4.6 C o n t e n t R e f e r e n c e : An E x a m p l e T e r m i n a l S e s s i o n 50 i v 5 R e s u l t s and E v a l u a t i o n 56 5.1 Problem S p e c i f i c a t i o n and Expected R e s u l t s 56 5.2 Rules f o r an Exhaustive U n c o n t r o l l e d D e r i v a t i o n 60 5.3 Adding a Goal D i r e c t e d S t r a t e g y v i a Meta Rules 65 5.4 Augmenting the Goal D i r e c t e d S t r a t e g y with H e u r i s t i c s 68 5.5 Rules f o r Connecting Many Chains 71 5.6 Pragmatic C o n s i d e r a t i o n s f o r S o l v i n g a Real Problem .. 74 6 C o n c l u s i o n 78 6.1 R e c a p i t u l a t i o n of the R e s u l t s 78 6.2 R e l a t e d Issues and D i r e c t i o n f o r F u r t h e r Research .... 80 B i b l i o g r a p h y 82 APPENDIX A Trace of the Content Reference Example 87 APPENDIX B C i r c u i t Design 89 APPENDIX C Complete Set of Multiwrap Rules 91 APPENDIX D A u x i l i a r y P r e d i c a t e s f o r Wire-Wrapping Problems .. 95 APPENDIX E Trace of Metawrap Problem 97 APPENDIX F Using RCPS on MTS 111 APPENDIX G RCPS I n t e r p r e t e r 112 APPENDIX H U t i l i t i e s f o r RCPS I n t e r p r e t e r 121 Table of F i g u r e s 1. Data Dependency L i n k s f o r the Rules of Inference 19 2. U n c o n t r o l l e d D e r i v a t i o n of an I t e r a t e d Sequence 33 3. I n t r o d u c t o r y Problem S o l u t i o n 60 4. Exhaustive Deduction and R e s u l t i n g S o l u t i o n 64 5. I n t e l l i g e n t S o l u t i o n 71 6. R e a l i s t i c Problem S o l u t i o n 77 1 CHAPTER 1 Introduct ion "Production Systems are a c o n t r o l s t r u c t u r e with promising a t t r i b u t e s f o r b u i l d i n g g e n e r a l l y i n t e l l i g e n t systems with l a r g e knowledge bases." Rychener, 1977 The computer s c i e n c e community has used, as a formal b a s i s f o r computational engines, a v a r i e t y of models i n c l u d i n g the Von Neumann machine and r e c u r s i v e f u n c t i o n theory. Because of i t s modular and a d d i t i v e nature, the p r o d u c t i o n system (PS) has become a popular model for a r t i f i c i a l i n t e l l i g e n c e (Al) re s e a r c h . 1.1 Def i n i t i o n s The term "production system" i s used in t h i s paper to denote a rule-based system. For a t u t o r i a l i n t r o d u c t i o n to PSs c o n s u l t [Davis & King, 76] [ S t e f i k , A i k i n s , B a l z e r , Benoit, Birnbaum, Hayes-Roth, & S a c e r d o t i , 82]. A PS c o n s i s t s of a set of p r o d u c t i o n s ( r u l e s , or a c t i o n s are used synonomously), c a l l e d the knowledge base, and an a l g o r i t h m , c a l l e d the i n t e r p r e t e r . Each p r o d u c t i o n has two components, a p r e c o n d i t i o n and a p o s t c o n d i t i o n . These components are sometimes c a l l e d a 1 I n t r o d u c t i o n 2 condition-action pair or if-then rule. The basic nondeterministic algorithm, modelled aft e r [Nilsson, 80], which u t i l i z e s these rules is presented below. Procedure PS(Si, Sf) Begin Database = i n i t i a l state Si U n t i l Database = f i n a l state Sf Begin Construct from the t o t a l set of rules the active set A { Control } Construct the c o n f l i c t set, C, from those rules in A whose precondition holds in current database { Condition S a t i s f a c t i o n } Select rule R from from c o n f l i c t set C { C o n f l i c t Resolution } Database = state where the postcondition of R holds { Rule Application } End End Given an i n i t i a l state, S i , the purpose of the PS is to apply rules to Si in order to achieve the f i n a l state Sf. We say that such a PS i s operating in a forward manner using forward rules or i t is said to be data-driven. By interchanging the rules' conditions and specifying the f i n a l state as the i n i t i a l and the i n i t i a l as the f i n a l , the PS is said to be operating in a backward fashion using backward rules or i t i s said to be goal-driven. If every rule chosen by the c o n f l i c t set i s simultaneously applied to the current state, resulting in possibly many successors, we say the search is breadth-first, otherwise i t is de p t h - f i r s t . The term "search strategy" is used to denote the dir e c t i o n of search, the manner in which the space i s searched ( i . e . breadth-first or d e p t h - f i r s t ) , and the c o n f l i c t resolution used [Georgeff, 82], The c o n f l i c t 1 Introduction 3 r e s o l u t i o n i s a p r o c e d u r e w h i c h s e l e c t s , b a s e d on h e u r i s t i c m e r i t , some s u b s e t o f t h e a p p l i c a b l e r u l e s . The c o n t r o l s t r a t e g y i s t h e p r o c e d u r e u s e d t o s e l e c t a s e t o f a c t i v e r u l e s f r o m t h e t o t a l k n o w l e d g e b a s e . A PS may r e t u r n , a s r e s u l t , e i t h e r t h e f i n a l s t a t e w h i c h s a t i s f i e s , s a y , a t o t a l p r e d i c a t e o v e r t h a t s t a t e o r t h e s e q u e n c e o f r u l e s w h i c h a c c o m p l i s h e s t h a t s t a t e . The f i n a l s t a t e c a n t h e n be o b t a i n e d by a p p l y i n g t h e s e q u e n c e o f r u l e s t o t h e i n i t i a l s t a t e i n t h e o r d e r s t a t e d . The s e q u e n c e o f r u l e s i s t y p i c a l l y c a l l e d a " p l a n " and t h e PS i s c a l l e d a " p l a n n e r " . T h i s document i s c o n c e r n e d w i t h PS c o n t r o l s t r a t e g i e s ; i n p a r t i c u l a r , i t d e s c r i b e s t h e i m p l e m e n t a t i o n o f a p l a n n e r w h i c h r e c u r s i v e l y p l a n s i t s own c o n t r o l s t r a t e g y . The t e r m " m e t a p l a n n i n g " i s u s e d t o d e s c r i b e t h i s p r o c e s s . 1.2 M o t i v a t i o n The r e s e a r c h i n m e t a p l a n n i n g i s m o t i v a t e d by two f u n d a m e n t a l c h a r a c t e r i s t i c s o f any a u t o m a t o n [ M a c k w o r t h , 8 3 ] : 1) i t s p r o c e d u r a l a d e q u a c y 2) i t s d e s c r i p t i v e a d e q u a c y . I n t h e c o n t e x t o f P S s , t h e g o a l of t h e r e s e a r c h i s t o i n c r e a s e b o t h of t h e s e . T y p i c a l l y , a l t h o u g h a PS h a s a s i n g l e i n f e r e n c e p a t h t h a t l e a d s t o t h e g o a l , a c o m b i n a t o r i a l number o f p a t h s a r e 1 I n t r o d u c t i o n 4 considered before the correct one is found. A number of h e u r i s t i c a l l y based procedures (e.g. A*) have been developed to increase the probability of choosing the correct path to expand. The approach taken here is to attempt to refine the process of chosing a rule to the point where numerous paths are not generated; that i s , the goal is to decrease the branching factor at every state. An i n v a l i d branch is one with a branching factor of 0; that i s , the control strategy suggests an empty set of active rules. In e f f e c t , the technique advocated only produces h e u r i s t i c a l l y v a l i d branches as opposed to pruning i n v a l i d ones after the fact, as in A*. Whereas h e u r i s t i c s were t y p i c a l l y imbedded in the interpreter, or a special evaluation function, and represented in a non-standard language, the language of choice for representing control h e u r i s t i c s is the same language that has been used so extensively in Al - namely, production rules. These second order rules are- c a l l e d metarules since they describe how to use the rules. 1.3 Thesis Overview This thesis proposes a metalanguage for reasoning about control in PSs. This language i s implemented in.a PS c a l l e d a Recursively Controlled Production System (RCPS) which i s then used in the domain of robotics to judge i t s e f f i c a c y . 1 Introduction 5 A l t h o u g h t h e RCPS i m p l e m e n t a t i o n , programmed i n PROLOG, i s c o n s i d e r e d i n d e p t h , a w o r k i n g k n o w l e d g e o f t h i s l a n g u a g e i s n o t n e c e s s a r y . C h a p t e r two c o n s i d e r s PROLOG, i n t h e c o n t e x t o f P S s , i n s u f f i c i e n t d e p t h t o c l a r i f y t h e few b r i e f p a s s a g e s o f c o d e . C h a p t e r two p r o v i d e s a f r a m e w o r k a nd b a c k g r o u n d t o t h e a p p r o a c h w h i c h h a s been t a k e n ; i n p a r t i c u l a r , a d e f i n i t i o n o f p r o c e d u r a l c o n t r o l i n PSs i s p r e s e n t e d w h i c h i s t h e b a s i s t o t h i s r e s e a r c h . W h i l e p a y i n g p a r t i c u l a r a t t e n t i o n t o t h e c o n t r o l u s e d , a number of PSs a r e c o n s i d e r e d . C h a p t e r t h r e e e x p l i c a t e s t h e d e s i g n o f RCPS i n t e r m s o f t h e d e f i n i t i o n s i n c h a p t e r two. C h a p t e r f o u r p r e s e n t s t h e RCPS l a n g u a g e a n d t h e a l g o r i t h m s and d a t a s t r u c t u r e s u s e d t o i m p l e m e n t i t . The RCPS l a n g u a g e i s u s e d i n c h a p t e r f i v e , i n t h e d o m a i n o f r o b o t i c s , t o j u d g e i t s w o r t h i n t e r m s o f p r o c e d u r a l and d e s c r i p t i v e a d e q u a c y . C h a p t e r s i x c o n c l u d e s by s u m m a r i z i n g t h e r e s u l t s a n d t h e i m p a c t t h e y may h a v e on f u t u r e P S s . 1 I n t r o d u c t i o n 6 CHAPTER 2 Framework o f t h e F i e l d T h r o u g h o u t t h e h i s t o r y o f P S s , v a r i o u s methods f o r c o n t r o l l i n g t h e i r i n h e r e n t n o n d e t e r m i n a c y h a v e been p r o p o s e d . I n d e e d , t h e q u e s t i s s t i l l u n d e r way. 2.1 H i s t o r i c a l P e r s p e c t i v e H i s t o r i c a l l y , PSs h a v e t h e i r b a s i s i n f o r m a l l o g i c a n d a r e a t t r i b u t e d j o i n t l y t o M a r k o v a n d P o s t [ C u t l a n d , 8 0 ] . I t c a n be e a s i l y p r o v e d [ M i n s k y , 67] t h a t PSs a r e e q u i v a l e n t i n power t o a T u r i n g m a c h i n e (TM) a n d t h u s c a n compute any TM c o m p u t a b l e f u n c t i o n . As d e f i n e d by [ C u t l a n d , 8 0 ] , a P o s t s y s t e m , P, i s a t r i p l e : P = ( I , A, Q) w h e r e : I i s a f i n i t e a l p h a b e t A, a s u b s e t o f I * , i s t h e s e t o f a x i o m s Q i s a s e t o f p r o d u c t i o n s o f t h e f o r m : g 0 S 1 g 1 S 2 ... gm-1Smgm -> h 0 S i 1 h 1 S i 2 ... S i n h n w h e r e : g 0,...,gm,h 0,...,hn a s u b s e t o f I * a r e f i x e d s t r i n g s 2 Framework o f t h e F i e l d 7 S 1 f...,Sm a r e a r b i t r a r y s t r i n g s S i S i n a r e a r b i t r a r y s t r i n g s whose s u b s c r i p t s , i t , . . . , i n , a r e f r o m 1,2,...,m. A s t r i n g w i s g e n e r a t e d f r o m a s t r i n g a by p r o d u c t i o n p i f t h e r e e x i s t s a p e Q o f t h e f o r m a -> We s a y , i s c o m p u t e d f r o m a by P o s t s y s t e m P a n d i s d e n o t e d a => co. The s o l u t i o n s e t f o r t h e P o s t s y s t e m P i s t h e r e f l e x i v e t r a n s i t i v e c l o s u r e o f => t h u s : S ( P ) = { u> | a e A, w e L*, a =>* u>] M a r k o v ' s n o t i o n o f c o m p u t a b l e i s s i m i l a r t o P o s t ' s a n d d i f f e r s i n t h e f o l l o w i n g ways: 1) e v e r y p r o d u c t i o n i n Q has t h e f o r m S , g S 2 -> S , ! ^ 2) t h e r e may be p r o d u c t i o n s i n Q s i n g l e d o u t a s b e i n g " t e r m i n a l 3) an e x p l i c i t s t r a t e g y i s g i v e n t o u n i q u e l y d e t e r m i n e t h e n e x t r u l e a n d how i t s h o u l d be a p p l i e d . A M a r k o v a l g o r i t h m a p p l i e s p r o d u c t i o n s i n Q s e q u e n t i a l l y a c c o r d i n g t o t h e f o l l o w i n g s t r a t e g y : 1) i f more t h a n one p r o d u c t i o n a p p l i e s , t h e n u s e t h e t o p most ( i . e . t h e f i r s t i n t h e f i x e d o r d e r ) 2) i f a p r o d u c t i o n a p p l i e s t o a s t r i n g i n more t h a n one way, a p p l y i t t o t h e l e f t m o s t s t r i n g 3) t h e a l g o r i t h m h a l t s when e i t h e r no p r o d u c t i o n a p p l i e s , o r a t e r m i n a l p r o d u c t i o n i s a p p l i e d . T h i s s t r a t e g y i s s o m e t i m e s c a l l e d t h e t o p - t o - b o t t o m l e f t - t o - r i g h t s t r a t e g y . 2 Framework o f t h e F i e l d 8 Consider, as an example, taken from [Galer & P e r l i s , 70], the fol lowing Markov algorithm to reverse a s t r ing e Z*. The per iod is used to denote terminal product ions. For X, Y e I, aux i l i a r y symbols a, /3 / L, ca l l ed markers or tokens, and the nu l l s t r ing A, the fol lowing set of productions accomplish the sa id funct ion. Q1 aa -> /3 Q2 (3a -> 0 Q3 0X -> X/3 Q4 0 "> A. Q5 aXY -> YaX Q6 A -> a The order of the productions is c r u c i a l and i s the only f l e x i b i l i t y in the contro l s t r u c tu r e 1 . Consider the fol lowing l abe l l i ng technique presented by [Galer & P e r l i s , 70] as an a l te rna t i ve contro l s t rategy. Each production may have a labe l appended to i t which denotes some production in Q. If a production is appl icable. and a label is appended to i t , then the transfer of contro l i s to the production bearing that labe l name. The fol lowing set of l abe l l ed productions from [Tremblay & Sorenson, 76] w i l l reverse a s t r ing e I*. Q1: aa -> A (Q4) Q2: aXY -> YaX (Q2) Q3: A -> a (QI) Q4: a -> A (Q4) We claim that th i s algorithm is procedural ly more adequate than 1 I f Q6 were the f i r s t product ion, for instance, the algorithm would never terminate. 2 Framework of the F i e l d 9 t h e f i r s t . T h i s c l a i m i s s u b s t a n t i a t e d f r o m t h e f a c t t h a t 57 t e s t s f o r r u l e a p p l i c a b i l i t y a r e n e e d e d i n t h e f i r s t a l g o r i t h m t o r e v e r s e a s t r i n g o f l e n g t h 3, w h i l e o n l y 18 t e s t s a r e n e e d e d i n t h e s e c o n d . I t i s f u r t h e r c l a i m e d t h a t t h i s a l g o r i t h m i s more d e s c r i p t i v e l y a d e q u a t e s i n c e we h a v e e x p l i c i t l y e x p r e s s e d ( a t l e a s t p a r t o f ) t h e c o n t r o l s t r a t e g y . The f i r s t s e t o f p r o d u c t i o n s d o e s n o t e a s i l y c o n v e y t h e c o n t r o l s t r a t e g y ; h o w e v e r , s i n c e i t i s e x p l i c i t l y s t a t e d i n t h e s e c o n d s e t , t h e c o n t r o l s t r a t e g y i s more u n d e r s t a n d a b l e a n d m a n i p u l a b l e . As i n t h i s c a s e , a d e s c r i p t i v e l y more a d e q u a t e a u t o m a t o n o f t e n l e a d s  t o an i n c r e a s e i n p r o c e d u r a l a d e q u a c y ( b y a l l o w i n g more k n o w l e d g e t o be s p e c i f i e d ) . T h i s i n c r e a s e i s e s p e c i a l l y t r u e when t h e d e s c r i p t i v e a d e q u a c y o f t h e c o n t r o l s p e c i f i c a t i o n i s i n c r e a s e d . F o r an e x c e l l e n t a r g u m e n t c o n c e r n i n g t h i s l a t t e r c l a i m , c o n s u l t [ K o w a l s k i , 7 9 a ] . By d e f i n i n g v a r i o u s c o n t r o l s t r a t e g i e s we i n v i t e q u e s t i o n s r e g a r d i n g t h e power of t h e c o n t r o l component a n d t h e r e s u l t i n g power o f t h e PS i t c o n t r o l s . The Chomsky h i e r a r c h y i s u s e d a s t h e g r a d a t i o n o f power. The c o n t r o l s t r a t e g y o f t h e f i r s t M a r k o v a l g o r i t h m i s t o r e p e a t e d l y s c a n t h e p r o d u c t i o n s e t i n t h e o r d e r t h a t t h e p r o d u c t i o n s were a s s e r t e d . T h i s c o n t r o l s t r a t e g y c a n be r e p r e s e n t e d by t h e r e g u l a r ( t y p e 3) e x p r e s s i o n (Q1; Q2; Q3; Q4; Q5; Q 6 ) * . . The c o n t r o l s t r a t e g y f o r t h e s e c o n d a l g o r i t h m c a n a l s o be r e p r e s e n t e d by a t y p e 3 e x p r e s s i o n ; n a m e l y , (Q1; ( ( Q 2 ) + ; Q 3 ) * ; (Q4)*)*. The K l e e n e "+" i n t h e p r e v i o u s 2 Framework o f t h e F i e l d 10 e x p r e s s i o n e n s u r e s t h a t Q2 i s t r i g g e r e d a t l e a s t o n c e s i n c e i t s f a i l u r e i s t h e s o l e means by w h i c h Q3 c a n be t r i g g e r e d . The l a t t e r c o n t r o l s t r a t e g y d o e s n o t a d d ( o r remove) c o m p u t a t i o n a l power [ G a l e r & P e r l i s , 7 0 ] ; t h a t i s , a l l TM c o m p u t a b l e f u n c t i o n s c a n be c o m p u t e d b u t no more. A l t h o u g h t h e c o m p u t a t i o n a l m o d e l s o f P o s t a n d M a r k o v w i t h i t s v a r i o u s c o n t r o l s t r a t e g i e s a r e r u d i m e n t a r y , t h e y a r e n e v e r t h e l e s s t h e f o u n d a t i o n f o r many v e r y h i g h l e v e l p r o g r a m m i n g l a n g u a g e s . One s u c h l a n g u a g e 2 i s M i c r o - P l a n n e r [ H e w i t t , 7 2 ] . The p r o d u c t i o n s o f M i c r o - P l a n n e r ( o r t h e o r e m s a s t h e y a r e c a l l e d ) may s u g g e s t t h e name o f t h e n e x t p r o d u c t i o n t o a t t e m p t v i a a THUSE c l a u s e . As an a l t e r n a t i v e m e t h o d , t h e t h e o r e m b a s e f i l t e r , THTBF c l a u s e , may s u g g e s t t h e n e x t p r o d u c t i o n by s p e c i f y i n g p r o p e r t i e s i t must h a v e . These c o n t r o l c o n s t r u c t s d i f f e r s l i g h t l y f r o m t h e l a b e l l e d M a r k o v a l g o r i t h m , w h i c h a l l o w s o n l y one s u g g e s t i o n p e r p r o d u c t i o n , by a l l o w i n g a number o f s u g g e s t i o n s w h i c h a r e a t t e m p t e d i n t h e o r d e r g i v e n . The s e q u e n c i n g o f p r o d u c t i o n s c a n o n l y be e f f e c t e d by t h e s e c o n t r o l c o n s t r u c t s a n d t h e o r d e r o f a s s e r t i o n i s i r r e l e v a n t . A l t h o u g h we may have g a i n e d d e s c r i p t i v e a d e q u a c y by h a v i n g t o e x p l i c i t l y e x p r e s s t h e o r d e r t o a t t e m p t t h e p r o d u c t i o n s , no c o m p u t a t i o n a l power h a s been g a i n e d a t t h e c o n t r o l l e v e l , n o r i n t h e o v e r a l l c o m p u t a t i o n a l m o d e l . The m a i n a d v a n t a g e t o t h e s e c o n t r o l c o n s t r u c t s i s i n t h e p r o c e d u r a l a d e q u a c y . I n t u i t i v e l y , t h e r e i s z A n o t h e r i s SNOBOL. 2 Framework o f t h e F i e l d 11 considerable evidence that h e u r i s t i c a l l y v a l i d suggestions w i l l help the ove ra l l performance of the system; however, th i s i s under the caveat that the e f f o r t needed to compute the suggestion i s less than the e f fo r t to exhaustively attempt a l l the product ions. 2.2 The Quest for the E x p l i c i t Control of Reasoning Such a var iety of methods have been proposed for the contro l of reasoning that some common ground for comparison i s needed. Since every technique has i t s own j u s t i f i c a t i o n and re l a t i ve c r i t e r i a for judgement, a more g loba l , theoret ic c r i t e r i o n is proposed. The techniques are categor ized according to the amount of expl ic i t cont ro l knowledge that can be spec i f i ed and i t s ease of access. There are bas i ca l l y three categor i e s . 1) The contro l strategy is imbedded in the rule interpreter and can be accessed only by modifying the in te rpre te r . An example of th i s strategy is the o r i g ina l Markov contro l strategy. This is ca l l ed "hard-coded". 2) The contro l strategy is ava i lab le as a program leve l object . For example, the l abe l l ed Markov algorithm allows the e x p l i c i t spec i f i c a t i on of the next rule to attempt and is ca l l ed " so f t l y-coded" . 3) The contro l strategy is completely separate. Examples of th is f l e x i b l e contro l strategy have not yet been considered and 2 Framework of the F i e l d 1 2 i s c a l l e d " s e p a r a t e l y - c o d e d " . M o s t o f t h e e a r l y PSs a r e c l a s s e d i n t h e h a r d - c o d e d c o n t r o l s t r a t e g y c a t e g o r y . GPS [ E r n s t & N e w e l l , 69] r e q u i r e s b o t h a h e u r i s t i c e v a l u a t i o n f u n c t i o n , t o a p p r o x i m a t e t h e d i s t a n c e b e t w een t h e c u r r e n t s t a t e a n d t h e g o a l s t a t e , a n d a d i f f e r e n c e - o p e r a t o r t a b l e t o be s p e c i f i e d a s t h e s t r a t e g y t h a t c o n t r o l s t h e i n t e r p r e t e r . The t a b l e i s u s e d a s a method of a s s o c i a t i n g a s i n g l e r u l e w i t h a p a r t i c u l a r ( s t a t e - s t a t e ) d i f f e r e n c e . G i v e n a d i f f e r e n c e f r o m t h e e v a l u a t i o n f u n c t i o n , t h e s t r a t e g y i s t o l o o k up i n t h e t a b l e t h e a s s o c i a t e d r u l e . The d i f f e r e n c e s a r e o r d e r e d , t y p i c a l l y f r o m l a r g e s t t o s m a l l e s t . I f a r u l e , t h u s r e t r i e v e d by t h i s i n d e x i n g scheme, f a i l s , t h e n t h e r u l e a s s o c i a t e d w i t h t h e n e x t d i f f e r e n c e i s a t t e m p t e d . When r e c u r s i n g on t h e s u b g o a l s , o n l y t h e t a b l e f r o m t h e c u r r e n t d i f f e r e n c e i s u s e d ; t h u s , t h e s t r a t e g y f o r a t a b l e s o r t e d by d e s c e n d i n g d i f f e r e n c e i n s u r e s t h a t s u b g o a l s a r e n e v e r more d i f f i c u l t t h a n any a n c e s t o r . The o n l y f l e x i b i l i t y i n t h e c o n t r o l s t r u c t u r e i s t h e o r d e r i n g o f t h e d i f f e r e n c e s ( i . e . rows o f t h e t a b l e ) ; i n p a r t i c u l a r , t h e r u l e s ( i . e . c o l u m n s ) a r e n o t o r d e r e d . STRIPS [ F i k e s & N i l s s o n , 71] [ F i k e s , H a r t , & N i l s s o n , 72] i s a PS b a s e d on GPS w h i c h e v o l v e d t h r o u g h many d i f f e r e n t c o n t r o l schemes - a l l o f them h a r d c o d e d . The s e a r c h s t r a t e g y of STRIPS i s b a c k w a r d a n d d e p t h - f i r s t . The o v e r a l l s t r a t e g y i s t o s o l v e t h e g o a l s i n l e f t - t o - r i g h t o r d e r by c h o o s i n g a r u l e , 2 Framework o f t h e F i e l d 1 3 i n d e x e d by g o a l , w h i c h s o l v e s t h e c u r r e n t g o a l . The r u l e w i t h t h e f e w e s t p r e c o n d i t i o n s i s a t t e m p t e d f i r s t , w i t h t h e o p t i o n o f b a c k t r a c k i n g t o any t h a t r e m a i n i n c a s e o f f a i l u r e . The p r e c o n d i t i o n s o f t h e a p p l i c a b l e r u l e a r e t h e n r e c u r s i v e l y s o l v e d i n t h e o r d e r s p e c i f i e d . The o n l y c o n t r o l t h a t c a n be e f f e c t e d i s t h r o u g h t h e o r d e r i n g o f t h e g o a l a n d t h e o r d e r i n g o f t h e s u b g o a l s i n t h e p r e c o n d i t i o n s . I n g e n e r a l , t h e a s s u m p t i o n t h a t g o a l s c a n be l i n e a r l y s o l v e d i s n o t w a r r a n t e d a s g o a l s may i n t e r a c t [ T a t e , 7 5 ] . Two c l a s s i c p r o p o s a l s f o r s o l v i n g g o a l i n t e r a c t i o n s a r e NOAH [ S a c e r d o t i , 77] and W a r p l a n [ W a r r e n , 7 4 ] , NOAH p r o d u c e s n o n - l i n e a r p l a n s i n t h e f o r m o f a n e t w o r k w h i c h i s t h e n l i n e a r i z e d by s p e c i a l p u r p o s e c r i t i c s . W a r p l a n p r o d u c e s p l a n s i n n o n - l i n e a r o r d e r by b a c k t r a c k i n g t h r o u g h t h e p l a n u n t i l t h e g o a l s no l o n g e r i n t e r a c t . A p r i o r i t y q u e u e , s o m e t i m e s c a l l e d an a g e n d a , h a s been s u g g e s t e d by many r e s e a r c h e r s a s a c o n t r o l s t r u c t u r e f o r d e c i d i n g upon t h e s c h e d u l i n g o f a r u l e o r g o a l . H e a r s a y I I , [ E r m a n , H a y e s - R o t h , L e s s e r , & Reddy, 80], u s e s a f u n c t i o n o f f i v e v a r i a b l e s , known a s t h e h e u r i s t i c s c h e d u l e r , t o a s s i g n p r i o r i t i e s t o t h e r u l e s i n t h e c o n f l i c t s e t . The a c t i o n w i t h t h e h i g h e s t p r i o r i t y i s c h o s e n f i r s t . I f t h e s e p r i o r i t i e s were a c c e s s i b l e f r o m t h e r u l e s , a s a p r o g r a m l e v e l o b j e c t , we c o u l d c l a s s i f y t h e s e s y s t e m s a s s o f t l y - c o d e d ; h o w e v e r , i n H e a r s a y I I t h i s i s n o t t h e c a s e a n d t h u s i t i s h a r d - c o d e d . Agenda b a s e d s y s t e m s h a v e been h e a v i l y c r i t i c i z e d ( e . g . [ D a v i s , 80a]) a s 2 Framework o f t h e F i e l d 1 4 b e i n g o p a q u e . The A l p r o g r a m m i n g l a n g u a g e PROLOG [ C o l m e r a u e r , 70] [ R o u s s e l , 7 5 ] , u s e d t o i m p l e m e n t RCPS, i s a s o f t l y - c o d e d PS. The s e a r c h s t r a t e g y i s b a c k w a r d a nd d e p t h - f i r s t w i t h a u t o m a t i c f a i l u r e - d r i v e n b a c k t r a c k i n g . The c o n t r o l s t r a t e g y i s t o p - t o - b o t t o m l e f t - t o - r i g h t . PROLOG h a s been c a t e g o r i z e d a s a s o f t l y - c o d e d PS s i n c e t h e p r e d i c a t e ", a v a i l a b l e a t t h e o b j e c t l e v e l , c a n be u s e d t o r e s t r i c t a l t e r n a t i v e r u l e s . T h i s p r e d i c a t e i s t h e o n l y f l e x i b i l i t y i n t h e c o n t r o l s t r u c t u r e . C o n s i d e r t h e f o l l o w i n g e x a m p l e f i r s t p r e s e n t e d by [ B y r d , 8 0 ] , A SPY p r e d i c a t e 3 , a l s o d i s c u s s e d i n t h e l a s t r e f e r e n c e , i s u s e d t o t r a c e t h e f l o w o f c o n t r o l . /* E x a m p l e PROLOG r u l e s , f a c t s , a n d g o a l */ P <- Q & R. Q <- S. Q <- T. R <- A & B. S. A. <-P. E n t e r i n g P E n t e r i n g Q E n t e r i n g S E x i t i n g S E x i t i n g Q E n t e r i n g R E n t e r i n g A E x i t i n g A E n t e r i n g B F a i l e d B Redo A 3 T h e SPY p r e d i c a t e , i m p l e m e n t e d by t h e a u t h o r , i s a v a i l a b l e on t h e U.B.C. MTS/G s y s t e m , i n f i l e J G I R : S P Y . 2 Framework o f t h e F i e l d 1 5 F a i l e d A F a i l e d R Redo Q Redo S F a i l e d S E n t e r i n g T F a i l e d T F a i l e d Q F a i l e d P ? The r u l e s i n t h e c o n f l i c t s e t , w h i c h PROLOG may b a c k t r a c k t o , a r e o r d e r e d a c c o r d i n g t o t h e o r d e r a s s e r t e d . The c u t , "/", a v a i l a b l e a t t h e p r o g r a m l e v e l , i s u s e d t o p r u n e t h e r e m a i n i n g c o n f l i c t s e t . The use of t h e c u t has a l r e a d y spun a c o n t r o v e r s y a n d c e r t a i n r u l e s f o r i t s u s e h a v e been p r o p o s e d [ C l o c k s i n & M e l l i s h , 8 1 ] . 1) C o n f i r m i n g t h e c h o i c e o f a r u l e : o n c e a r u l e i s known t o be t h e c o r r e c t one, t h e o t h e r s c a n be r e j e c t e d . 2) C u t - f a i l c o m b i n a t i o n : u s e d t o i m p l e m e n t n e g a t i o n a s f a i l u r e [ C l a r k , 78] 3) T e r m i n a t e a g e n e r a t e a n d t e s t : c u t t i n g o u t f u r t h e r a n s w e r s ( i . e . b a c k t r a c k i n g ) i n m u l t i a n s w e r p r o b l e m s . F o r p r a c t i c a l c o n s i d e r a t i o n s , t h e c u t i s u s e d e x t e n s i v e l y i n t h e i m p l e m e n t a t i o n of RCPS. I t s use i s d o c u m e n t e d a c c o r d i n g t o t h e r u l e s a bove and a b b r e v i a t e d t h u s : 1) CR ( c o n f i r m r u l e ) 2) CF ( c u t - f a i l ) 3) GT ( g e n e r a t e - t e s t ) A s i m p l e means of a c h i e v i n g a s e p a r a t e c o n t r o l component i s 2 Framework o f t h e F i e l d 1 6 s u g g e s t e d by O n c o c i n [ S h o r t l i f f e , S c o t t , B i s h o f f , C a m p b e l l , Van M e l l e , & J a c o b s , 8 1 ] , a s y s t e m f o r o n c o l o g y p r o t o c o l management. A c o n t r o l b l o c k , a s s o c i a t e d w i t h a g o a l , s e r v e s a s a h i g h l e v e l d e s c r i p t i o n o f how t h e t a s k i s t o be a c c o m p l i s h e d . T h e s e c o n t r o l b l o c k s a r e c o d e d s e p a r a t e l y f r o m t h e r u l e s ( a n d t h e i n t e r p r e t e r ) a n d s p e c i f y t h e r e l e v a n t d a t a , t h e r u l e s t o be i n v o k e d on t h i s d a t a , o r a n o t h e r c o n t r o l b l o c k . T h e s e c o n t r o l b l o c k s a r e r e g a r d e d a s s c r i p t s w h i c h g u i d e t h e i n t e r p r e t e r . The n e x t s e c t i o n p r e s e n t s o t h e r s e p a r a t e l y c o d e d c o n t r o l s t r a t e g i e s . 2.3 T h e s i s F o u n d a t i o n The t h e s i s i s f o u n d e d on two m a j o r w o r k s . The f l o w o f c o n t r o l w i t h i n t h e RCPS i n t e r p r e t e r i s b a s e d on a s y s t e m by [ D a v i s , 8 0 a ] , w h i l e t h e d e f i n i t i o n o f c o n t r o l u s e d i s by [ G e o r g e f f , 8 2 ] . A t h i r d work by [de K l e e r , D o y l e , S t e e l e , S ussman, 77] p l a y s a m i n o r r o l e a n d w i l l be p r e s e n t e d f i r s t . A s o f t l y - c o d e d r u l e - b a s e d s y s t e m f o r t h e e x p l i c i t c o n t r o l o f r e a s o n i n g , c a l l e d AMORD, h a s been p r e s e n t e d by [de K l e e r , D o y l e , S t e e l e , Sussman, 7 7 ] . The c o n t r o l s t r u c t u r e o f t h e p r o b l e m s o l v e r i s e x p l i c i t l y r e p r e s e n t e d i n t h e r u l e s o f t h e s y s t e m . E v e r y f a c t d e d u c e d must have an e x p l i c i t d a t a d e p e n d e n c y l i n k a l s o r e p r e s e n t e d i n t h e r u l e s . T h e s e b a s i c i d e a s a r e t o be e l u c i d a t e d by t h e f o l l o w i n g e x a m p l e w h i c h u s e s a t y p e o f f i r s t o r d e r l o g i c s y n t a x . The "*" p r e f i x i s u s e d t o d e n o t e a v a r i a b l e . The a c t u a l AMORD c o n s t r u c t s w i l l n o t be 2 Framework o f t h e F i e l d 1 7 c o n s i d e r e d . C o n s i d e r t h e f o l l o w i n g f a c t s and r u l e s o f i n f e r e n c e . 2 Framework o f t h e F i e l d 18 HUMAN(*X) -> F A L L I B L E ( * X ) HUMAN(TURING) A B A -A > B A & B B An e x h a u s t i v e u n c o n t r o l l e d s e a r c h p r o d u c e s a w e a l t h o f f a c t s n o t p e r t i n e n t t o t h e d e r i v a t i o n o f t h e g o a l F A L L I B L E ( T U R I N G ) & HUMAN(TURING) ( s u c h a s : HUMAN(TURING) & HUMAN(TURING)); h o w e v e r , t h e r u l e s o f i n f e r e n c e c a n be r e s t r i c t e d t o a p p l y o n l y when a n e e d f o r i t h a s been shown by a u g m e n t i n g t h e p r e c o n d i t i o n , t h u s : SHOW(A & B) SHOW(B) A A -> B B A A & B B S u b g o a l s a r e g e n e r a t e d by t h e f o l l o w i n g r u l e s : SHOW(A & B) SHOW(A & B) SHOW(A) I f we a r e a g a i n g i v e n t h e i n i t i a l f a c t s a s w e l l as t h e f a c t SHOW(FALLIBLE(TURING) & HUMAN(TURING)) t o show i n t e r e s t , t h e o n l y f a c t s now g e n e r a t e d a r e : SHOW(FALLIBLE(TURING)) SHOW(HUMAN(TURING)) F A L L I B L E ( T U R I N G ) F A L L I B L E ( T U R I N G ) & HUMAN(TURING) S i n c e t h e g o a l h a s e f f e c t i v e l y been a s s e r t e d a s a f a c t a n d s i n ^ e e v e r y r u l e h a s been r e s t r i c t e d t o f i r e o n l y t o s o l v e a g o a l o r A SHOW(A) SHOW(B) SHOW(B) A -> B 2 Framework o f t h e F i e l d 19 subgoal,- there i s l i t t l e doubt that the d e r i v a t i o n i s g o a l d i r e c t e d " . The problem with t h i s approach i s t h a t c o n c l u s i o n s are dependent on the c o n t r o l a s s e r t i o n s . To s e p a r a t e these dependencies, e x p l i c i t , j u s t i f i c a t i o n s are a s s e r t e d with the f a c t s . S i n c e a f a c t i s b e l i e v e d o n l y i f i t has w ell-founded-support i n terms of other f a c t s , the c o n t r o l over the d e r i v a t i o n of f a c t s no l o n g e r a f f e c t s the t r u t h of the d e r i v e d f a c t s . F i g u r e 1 shows the dependency l i n k s f o r the two main r u l e s of i n f e r e n c e . B /L SHOV/(ft L B ) \ / \ ft I B SWOW(B) SHow(fl) F i g u r e 1. Data Dependency L i n k s f o r the Rules of I n f e r e n c e We see, f o r example, "A & B" i s t r u e because "A" and "B" are t r u e and t h e r e i s no dependency on the c o n t r o l a s s e r t i o n "SHOW(A & B)". Although these techniques are not used i n RCPS, the r e are a few p o i n t s of s i m i l a r i t y worth n o t i n g . The b a s i c "The problem of g e n e r a t i n g . non i n t e r a c t i n g subgoals i s not always such an easy t a s k . 2 Framework of the F i e l d 20 c o n c e p t i s t h e e x p l i c i t a s s e r t i o n o f c o n t r o l f a c t s . S i n c e , by t h e i r i n t r o d u c t i o n , t h e c o n t r o l f a c t s a r e no l o n g e r d i s t i n g u i s h e d , t h e e x p l i c i t d a t a d e p e n d e n c y l i n k i s n e e d e d . RCPS c a n a l s o e x p l i c i t l y a s s e r t a n d do i n f e r e n c e on c o n t r o l f a c t s ; h o w e v e r , t h e d e d u c t i o n i s w i t h i n t h e s c o p e o f t h e o b j e c t l e v e l d e d u c t i o n . The e f f e c t o f t h i s s c o p e i s t h a t o b j e c t l e v e l f a c t s a r e a v a i l a b l e a t t h e m e t a l e v e l b u t n o t v i c e v e r s a a n d t h u s , t h e d a t a d e p e n d e n c i e s a r e s t i l l d i s t i n g u i s h e d a n d nee d n o t be e x p l i c i t l y r e s t a t e d . The t e r m " j u s t i f i c a t i o n " i n RCPS r e f e r s t o t h e e x p l i c i t c o n t r o l d e p e n d e n c y r e t u r n e d t o t h e o b j e c t l e v e l f r o m t h e c o n t r o l l e v e l ; t h a t i s , t h e j u s t i f i c a t i o n i s f o r t h e c o n t r o l o f i n f e r e n c e a n d n o t t h e t r u t h o f t h e r e s u l t i n g c o n c l u s i o n 5 . T h e r e f o r e , a s i n AMORD, t h e c o n t r o l o v e r t h e d e r i v a t i o n d o e s n o t a f f e c t t h e t r u t h o f t h e d e r i v e d f a c t s . A g e n e r a l f r a m e w o r k f o r r e a s o n i n g a b o u t c o n t r o l i s p r o p o s e d by [ D a v i s , 8 0 a ] . A l t h o u g h i t i s c l a i m e d t h a t t h e t e c h n i q u e s a r e a p p l i c a b l e t o any c o m p u t a t i o n a l m e c h a n i s m a n d k n o w l e d g e s o u r c e , i t w i l l be d i s c u s s e d i n t h e c o n t e x t o f P S s 6 . The m o t i v a t i o n f o r t h e e x p l i c i t r e a s o n i n g a b o u t c o n t r o l i s t h e n o t i o n o f i n e v i t a b l e s a t u r a t i o n ; t h a t i s , t h e i n a b i l i t y o f a PS t o e x h a u s t i v e l y s e a r c h a s p a c e e i t h e r due t o t h e i n h e r e n t n o n d e t e r m i n i s m o r s i m p l y t h e l a r g e number o f r u l e s . The 5 T h i s i s , i n some ways, c o m p l e t e l y o r t h o g o n a l t o AMORD. 6 T h e work r e p o r t e d i s f r o m t h e d e v e l o p m e n t o f t h e r u l e - b a s e d s y s t e m T e i r e s i a s [ D a v i s , 79] and t h u s much o f t h e o r i g i n a l d i s c u s s i o n i s i n t e r m s o f r u l e s a n d m e t a r u l e s . 2 Framework o f t h e F i e l d 21 s o l u t i o n o f f e r e d t o t h i s p r o b l e m i s t o r e f i n e t h e s e t o f a p p l i c a b l e r u l e s by o r d e r i n g o r p r u n i n g i t . Though t h i s n o t i o n , g e n e r a l l y known a s c o n f l i c t r e s o l u t i o n 7 , i s n o t new, t h e t e c h n i q u e f o r a c c o m p l i s h i n g t h i s t a s k i s . The c o n f l i c t s e t r e f i n e m e n t i s c o n s i d e r e d a f u l l f l e d g e d p r o b l e m t o be s o l v e d by a g e n e r a l i n f e r e n c e s y s t e m . The t e c h n i q u e i s h i g h l y d e p e n d e n t on t h e s e a r c h s t r a t e g y ; more s p e c i f i c a l l y , i t i s d e p e n d e n t on t h e i n d e x scheme u s e d t o a c c e s s t h e r u l e s . A s y s t e m l i k e GPS, f o r i n s t a n c e , i n d e x e s i t s o p e r a t o r s a c c o r d i n g t o t h e d i f f e r e n c e b e t w e e n t h e c u r r e n t s t a t e a n d t h e g o a l . The s e a r c h s t r a t e g y o f MYCIN i s u s e d h e r e f o r t h e e x p o s i t i o n o f t h e i d e a s . S i n c e t h e s e a r c h s t r a t e g y i s d e p t h - f i r s t and b a c k w a r d s , t h e r u l e s a r e i n d e x e d a c c o r d i n g t o t h e g o a l t h e y s o l v e . The s p e c i f i c a t i o n o f c o n t r o l s t r a t e g i e s i s a c c o m p l i s h e d by s e c o n d o r d e r r u l e s , known as m e t a r u l e s , w h i c h a r e a l s o a s s o c i a t e d w i t h t h e g o a l . The p u r p o s e o f t h e s e m e t a r u l e s , w h i c h a r e i n t e r p r e t e d by the. same i n f e r e n c e e n g i n e a s t h e o b j e c t l e v e l r u l e s , i s t o r e f i n e t h e s e t o f o b j e c t l e v e l r u l e s . I n o p e r a t i o n , t h e i n t e r p r e t e r r e t r i e v e s t h e s e t o f r u l e s a s s o c i a t e d w i t h t h e g o a l a n d t h e n p r o c e e d s t o r e t r i e v e any h i g h e r o r d e r s e t s . The h i g h e s t o r d e r s e t i s i n t e r p r e t e d , by t h e common i n t e r p r e t e r , t o r e f i n e t h e n e x t l o w e r o r d e r s e t . The p r o c e s s u n w i n d s w i t h t h e n e t e f f e c t o f p r o d u c i n g a p o t e n t i a l l y ( p a r t i a l l y ) o r d e r e d a n d / o r s h o r t e n e d s e t o f o b j e c t 7 T h e t e r m " c o n f l i c t r e s o l u t i o n " o f t e n means t h e i r r e v o c a b l e c h o o s i n g o f a s i n g l e r u l e ( s e e [McDermott & F o r g y , 7 8 ] ) ; t h u s , i n t h i s c a s e we may p r e f e r " c o n f l i c t r e f i n e m e n t " . 2 Framework o f t h e F i e l d 22 l e v e l r u l e s w h i c h a r e t h e n i n t e r p r e t e d . A l t h o u g h t h e scheme i s s i m p l e , t h e e x p l i c i t r e p r e s e n t a t i o n o f c o n t r o l , v i a m e t a r u l e s , p r o v i d e s a u n i f o r m k n o w l e d g e r e p r e s e n t a t i o n and common means o f i n t e r p r e t a t i o n . T h e s e a r e a p p e a l i n g i d e a s . The n o t i o n o f a d e p e n d e n c y on t h e s e a r c h s t r a t e g y a n d t h e d e f i n i t i o n o f c o n t r o l a s r e f i n e m e n t , h o w e v e r , i s n o t a p p e a l i n g a n d t h u s t h e a l t e r n a t i v e p r o v i d e d by [ G e o r g e f f , 82] i s c o n s i d e r e d n e x t . [ G e o r g e f f , 82] p r e s e n t s a t h e o r y f o r e f f e c t i n g p r o c e d u r a l c o n t r o l i n PSs w h i c h i s i n d e p e n d e n t o f t h e s e a r c h s t r a t e g y a n d i s n o t b a s e d on r e f i n i n g t h e c o n f l i c t s e t . A b s t r a c t l y , a c o n t r o l l a n g u a g e o v e r t h e p r o d u c t i o n s e t i s u s e d t o s p e c i f y t h e a l l o w a b l e s e q u e n c e s o f p r o d u c t i o n s . I n e f f e c t , when a p r o d u c t i o n i s f i r s t r e t r i e v e d , i t i s c h e c k e d a g a i n s t t h e c o n t r o l l a n g u a g e e v e n b e f o r e i t i s c h e c k e d f o r a p p l i c a b i l i t y . N o t i c e t h a t , u n l i k e AMORD, c o n t r o l i n f o r m a t i o n i s s e p a r a t e f r o m t h e a p p l i c a b i l i t y c r i t e r i a a n d t h u s t h e r e i s no p r o b l e m o f d i s t i n g u i s h i n g b e t w e e n them. A l s o n o t i c e t h a t , u n l i k e D a v i s ' s y s t e m , t h e c o n t r o l o v e r t h e r u l e s i s a c c o m p l i s h e d b e f o r e c h e c k i n g f o r a p p l i c a b i l i t y a s o p p o s e d t o r e f i n i n g t h e t o t a l s e t o f a p p l i c a b l e r u l e s . More f o r m a l l y , G e o r g e f f d e f i n e s a c o n t r o l l e d p r o d u c t i o n s y s t e m ( C P S ) a s a f o u r t u p l e , t h u s : C P S = ( I , D, h, C ) w h e r e : 2 Framework o f t h e F i e l d 23 I i s a s e t o f p r o d u c t i o n names D i s a s e t o f d a t a b a s e s ( s t a t e s ) h i s an i n t e r p r e t a t i o n w h i c h a s s i g n s t o e a c h e l e m e n t o f Z a p a i r ( q , r ) wh e r e : q i s a t o t a l p r e d i c a t e on D ( c o n d i t i o n ) r i s a b i n a r y r e l a t i o n on D ( a c t i o n ) C i s a c o n t r o l l a n g u a g e o v e r Z ( i . e . a s u b s e t o f Z * ) . A s t a t e o f a CPS i s d e f i n e d t o be a p a i r : S = ( u , x) wh e r e : u i s a p r e f i x o f some wo r d i n C x e D. I n d u c t i v e l y , a s t a t e ( u p , x 2 ) i s d i r e c t l y c o m p u t e d f r o m a s t a t e ( u , x , ) , d e n o t e d ( u , x,) -> ( u p , x 2 ) , where u e Z* and p e Z, i f and o n l y i f q ( x , ) i s t r u e a n d ( x , , x 2 ) e r . L e t ->* be t h e r e f l e x i v e t r a n s i t i v e c l o s u r e o f ->. The s o l u t i o n s e t i s : S ( C P S , s, g) = {x : ( s , x) e R ( C P S ) a nd g ( x ) i s t r u e } w h e r e : s e D i s t h e i n i t i a l s t a t e g i s a p r e d i c a t e o v e r D ( g o a l ) R ( C P S ) = { ( x , y) : x ->* y} F o r e x a m p l e , f o r s t a r t s y m b o l S and t h e f o l l o w i n g p r o d u c t i o n s : Q1: S -> ABC Q2: A -> aA 2 Framework o f t h e F i e l d 24 Q3: B -> bB Q4: C -> cC Q5: A -> a Q6: B -> b Q7: C -> c t h e s o l u t i o n s e t i s : S ( P S ) = { a * * l , b**m, c * * n : 1 > 1, m > 1, n > 1}. I f we d e f i n e t h e c o n t r o l l a n g u a g e C = Q1; (Q2; Q3; Q 4 ) * Q5; Q6; Q7, t h e s o l u t i o n s e t i s : S ( C P S ) = { a * * n , b * * n , c**n : n > 1}. I n g e n e r a l , c o n t e x t f r e e r e w r i t i n g s y s t e m s w i t h r e g u l a r c o n t r o l l a n g u a g e s g e n e r a t e a l l r e c u r s i v e l y e n u m e r a b l e l a n g u a g e s [ S a l o m a a , 7 7 ] . I n o p e r a t i o n , t h e r e c o g n i z e - a c t c y c l e o f a PS i s a u g m e n t e d w i t h a s t a g e t h a t d e t e r m i n e s t h e a c t i v e s e t o f p r o d u c t i o n s a s a f u n c t i o n o f t h e s p e c i f i e d c o n t r o l l a n g u a g e . The c o n t r o l l a n g u a g e n e e d n o t be s p e c i f i e d e x p l i c i t l y b u t may be g e n e r a t e d a t t h e moment when t h e n e x t p r o d u c t i o n i s n e e d e d . The a u t o m a t o n u s e d i n RCPS t o g e n e r a t e t h e c o n t r o l l a n g u a g e i s t h e PS b e i n g c o n t r o l l e d . T h u s , t h e e x p l i c i t s p e c i f i c a t i o n o f c o n t r o l k n o w l e d g e , i n .the f o r m o f m e t a r u l e s , f o r m s an i m p l i c i t r e p r e s e n t a t i o n o f t h e c o n t r o l l a n g u a g e . I t i s i n t e r e s t i n g t o n o t e t h e o r t h o g o n a l i t y o f G e o r g e f f ' s scheme and t h a t o f D a v i s . T r i v i a l l y , i f we l e t t h e c o n t r o l l a n g u a g e be £*, a CPS i s r e d u c e d t o a PS. S i m i l a r l y , i f we do n o t r e f i n e t h e p l a u s i b l e k n o w l e d g e s o u r c e , no c o n t r o l i s e f f e c t e d . The use o f G e o r g e f f ' s scheme t o d e t e r m i n e t h e a c t i v e 2 Framework o f t h e F i e l d 25 p r o d u c t i o n s e t , h o w e v e r , d o e s n o t p r e c l u d e t h e u s e o f D a v i s ' scheme t o r e f i n e t h i s s e t a f t e r i n s u r i n g .for a p p l i c a b i l i t y . I n c o m p a r i n g t h e s e two m e t h o d s o f a c h i e v i n g c o n t r o l , we n o t e t h a t G e o r g e f f ' s t e c h n i q u e s i m p l y p r u n e s t h e s e t o f r u l e s w h i l e D a v i s ' may a l s o r e o r d e r i t . I f we s e e k a g e n e r a l m e t h o d o f a c h i e v i n g c o n t r o l i n d e p e n d e n t o f t h e s e a r c h s t r a t e g y , t h e r e o r d e r i n g o f t h e r u l e s i s o n l y a d v a n t a g e o u s i n a d e p t h - f i r s t s e a r c h . S i n c e a b r e a d t h - f i r s t s e a r c h w o u l d a p p l y e v e r y r u l e i n t h e s e t , t h e o r d e r i s o f l i t t l e c o n s e q u e n c e . T h u s , t h e p o i n t o f c o m p a r i s o n i s t h e p r u n i n g o f t h e s e t . I f we p r u n e t h e s e t a f t e r c o n d i t i o n s a t i s f a c t i o n , t h e e n t i r e s e t i s a v a i l a b l e f o r t h e m u t u a l c o m p a r i s o n o f t h e r u l e s ; h o w e v e r , r e d u c i n g t h i s s e t i m p l i e s t h e e f f o r t r e q u i r e d t o compute t h e s a t i s f i a b i l i t y c r i t e r i a i s w a s t e d ( e x c e p t p e r h a p s i f i t i s n e e d e d f o r t h e c o m p a r i s o n ) . On t h e o t h e r h a n d , t h e d e t e r m i n a t i o n o f t h e a c t i v e s e t c a n n o t be b a s e d on t h e c o m p l e t e s e t of a p p l i c a b l e r u l e s u n l e s s t h e e n t i r e s e t of r u l e s c a n be a c c e s s e d and r u l e a p p l i c a b i l i t y c h e c k e d . T h i s l a t t e r t e c h n i q u e i s o n l y e f f e c t i v e , h o w e v e r , i f t h e r u l e a p p l i c a b i l i t y c r i t e r i a i s n o t r e d u n d a n t l y c h e c k e d a f t e r t h e a c t i v e s e t has b een d e t e r m i n e d . I n e f f e c t , G e o r g e f f ' s scheme c a n be r e d u c e d t o D a v i s ' u n d e r t h e a b o v e c o n d i t i o n s a n d i s t h e t e c h n i q u e u s e d by RCPS. An i m p o r t a n t c h a r a c t e r i s t i c o f G e o r g e f f ' s t e c h n i q u e i s t h e a b i l i t y t o d e f i n e a l i n e o f t h o u g h t v i a t h e c o n t r o l w o r d s ; t h a t i s , t h e a b i l i t y t o s u g g e s t a s e q u e n c e o f r u l e s . D a v i s s a i d t h a t 2 Framework o f t h e F i e l d 26 s u c h a c a p a b i l i t y i s n o t p r o v i d e d by h i s t e c h n i q u e a nd i s a l i m i t a t i o n . 2.4 Judgement C r i t e r i a The c r i t e r i o n u s e d t o j u d g e t h e p r o c e d u r a l a d e q u a c y o f t h e PSs i s t h e p e n e t r a n c e f a c t o r [ N i l s s o n , 8 0 ] . I n t u i t i v e l y , t h e p e n e t r a n c e f a c t o r m e a s u r e s t h e d e g r e e t o w h i c h a s e a r c h i s d i r e c t e d t o w a r d s t h e g o a l . A l g e b r a i c a l l y , i t i s d e f i n e d t o be: P = L / T w h e r e : L i s t h e l e n g t h o f t h e p a t h f o u n d t o t h e g o a l T i s t h e t o t a l number o f n o d e s g e n e r a t e d d u r i n g t h e s e a r c h . A l t h o u g h t h e p e n e t r a n c e may r a t e t h e d e g r e e t o w h i c h a s e a r c h i s g o a l - d i r e c t e d , i t d o e s n o t , h o w e v e r , a c c u r a t e l y r e f l e c t t h e e f f o r t n e e d e d t o a c c o m p l i s h t h i s g u i d a n c e . S i n c e t h e g u i d a n c e o f f e r e d by RCPS i s f r o m a c o n t r o l l e v e l PS, t h e s t a t e s g e n e r a t e d by t h i s PS a r e c o u n t e d a s p a r t o f T, t h u s more a c c u r a t e l y r a t i n g t h e e f f o r t n e e d e d t o a c c o m p l i s h t h e g o a l . I f , f o r e x a m p l e , t h e c o n t r o l l e v e l e x p a n d s t h e e n t i r e t r e e t o d e t e r m i n e t h e c o r r e c t r u l e s , t h e p e n e t r a n c e r e m a i n s t h e same a s t h e u n c o n t r o l l e d v e r s i o n . The p e n e t r a n c e , a s d e f i n e d , i s u s e d i n c h a p t e r f i v e t o j u d g e t h e r e s u l t s o f u s i n g RCPS i n t h e d o m a i n . The c r i t e r i a f o r j u d g i n g t h e d e s c r i p t i v e a d e q u a c y c a n n o t be s o e a s i l y d e f i n e d s i n c e t h e y a r e o f a more s u b j e c t i v e n a t u r e . 2 Framework o f t h e F i e l d ' 27 S i n c e t h e c o n t r o l i s e f f e c t e d by a PS, e v e r y c o m p u t a b l e s t r a t e g y c a n be d e s c r i b e d ; h e n c e , t h e e a s e o f d e s c r i p t i o n i s t h e c h a r a c t e r i s t i c w h i c h i s t o be r a t e d . S i n c e t h e a u t h o r h a s been t h e o n l y u s e r t h u s f a r , a s u b j e c t i v e a c c o u n t o f t h e e a s e w i t h w h i c h t h e d o m a i n k n o w l e d g e o f c h a p t e r f o u r was c o d e d i n RCPS i s p r e s e n t e d i n p r o s e f o r m i n c h a p t e r f i v e . Some s u b j e c t i v e c r i t e r i a a r e a l s o l i s t e d t h e r e so t h a t r e a d e r s c a n f o r m t h e i r own o p i n i o n s . 2.5 Domain Framework RCPS i s a p l a n n e r w h i c h r e t u r n s a s e q u e n c e o f a c t i o n s w h i c h i f a p p l i e d t o t h e c u r r e n t s t a t e , w i l l r e s u l t i n t h e g o a l s t a t e . The m a c h i n e w h i c h w i l l e x e c u t e t h e s e a c t i o n s i s a PUMA r o b o t arm [ C o n d e c , U n i m a t i o n ] . The c l a s s o f p r o b l e m s t o be s o l v e d by RCPS an d t h e r o b o t arm, f o r t h i s t h e s i s , i s t h e w i r e - w r a p p i n g o f e l e c t r o n i c c i r c u i t b o a r d s . The w i r e - w r a p p i n g d o m a i n h a s been c h o s e n f o r t h e f o l l o w i n g r e a s o n s . 1) M a n u a l w i r e - w r a p p i n g i s t e d i o u s a n d e r r o r p r o n e . 2) The p r o g r a m m i n g o f n o n - i n t e l l i g e n t w i r e - w r a p p i n g m a c h i n e s i s t e d i o u s a n d e r r o r p r o n e . 3) The r e s u l t i n g p r o d u c t s h o u l d be u s e f u l f o r c i r c u i t p r o t o t y p i n g , m o d i f i c a t i o n , a n d p r o d u c t i o n . 4) The i n t e l l i g e n c e r e q u i r e d i s j u s t w i t h i n c u r r e n t t e c h n o l o g i c a l l i m i t s a n d t h u s p r o v i d e s a good t e s t f o r RCPS. 2 Framework o f t h e F i e l d 28 The p r o b l e m c o n s i s t s o f s p e c i f y i n g a number o f p i n s t o be c o n n e c t e d . The s o l u t i o n t o t h e p r o b l e m i s t h e s e q u e n c e o f r o b o t a c t i o n ' s t h a t w i l l a c c o m p l i s h t h e s e c o n n e c t i o n s . I n o r d e r t o p h y s i c a l l y a c c o m p l i s h t h e c o n n e c t i o n s , a s s p e c i f i e d by t h e p l a n , t h e r o b o t arm i s f i t t e d w i t h a w i r e w r ap t o o l . The t o o l h a s two f u n c t i o n s : 1) w r a p t h e w i r e a r o u n d t h e c u r r e n t p i n 2) c u t t h e w i r e . I n p a r t i c u l a r , t h e t o o l c a n w r ap a number o f c o n s e c u t i v e p i n s i f t h e w i r e i s n o t c u t . The t a s k o f m o v i n g t h e t o o l f r o m one p i n t o t h e n e x t i s a c c o m p l i s h e d by t h e r o b o t arm. M a c h i n e s , l i k e c o m p u t e r s and r o b o t s , t y p i c a l l y have a l a n g u a g e by w h i c h o t h e r s may c o m m u n i c a t e . The l a n g u a g e u s e d t o c o m m u n i c a t e w i t h t h e arm i s c a l l e d VAL [ C o n d e c , U n i m a t i o n ] . The VAL l a n g u a g e i s s i m i l a r t o c o m p u t e r l a n g u a g e s and i n p a r t i c u l a r r e s e m b l e s B A S I C . I t h a s f a c i l i t i e s f o r c o n d i t i o n a l s , i n t e r r u p t s , i t e r a t i o n , and o t h e r c o n t r o l s t r u c t u r e s . U s i n g t h i s l a n g u a g e , one i s a b l e t o command t h e m a c h i n e t o a c c o m p l i s h t h e s t e p s w h i c h s o l v e t h e p r o b l e m . I n d e e d , t h e programmer must s o l v e t h e p r o b l e m a s f a r a s t h e a l g o r i t h m b e f o r e commanding t h e m a c h i n e . The t a s k t o be a c c o m p l i s h e d by RCPS i s t o a u t o m a t i c a l l y p r o g r a m t h e r o b o t arm f r o m a p r o b l e m  spec i f i c a t i o n . I n t u i t i v e l y , we a r e a s k i n g t h e s y s t e m o f RCPS and t h e r o b o t arm t o a c c o m p l i s h a g o a l w i t h o u t s p e c i f y i n g how t o s o l v e t h a t p a r t i c u l a r g o a l . The a u t o m a t i c p r o g r a m m i n g o f 2 Framework o f t h e F i e l d 29 c o n d i t i o n a l s and l o o p s i s a t a s k much more d i f f i c u l t t h a n s i m p l y s e q u e n t i a l p l a n s . An e x c e l l e n t e x a m p l e i s o f f e r e d by [Manna & W a l d i n g e r , 8 0 ] . T y p i c a l l y , t h e few m a c h i n e s t h a t a r e a u t o m a t i c a l l y programmed s i m p l y e x e c u t e s e q u e n t i a l p l a n s . F o r e x a m p l e , GARI [ D e s c o t t e & L a t o m b e , 81] p r e s e n t a PS w h i c h p l a n s t h e s e q u e n c e o f m a c h i n e c u t s t o p r o d u c e m e c h a n i c a l p a r t s . M o s t i n d u s t r i a l r o b o t s o f t o d a y a r e e i t h e r m a n u a l l y programmed o r a r e " t a u g h t " . A number o f l a n g u a g e s h a v e been p r o p o s e d t o p r o g r a m r o b o t s [ B i s o n , L o r e n z i n & P a g e l l o , 81] [Week, E v e r s h e i m & Z u e h l k e , 81] [ A b e , Ueno, T s u j i k a d o & T a k a g i , 8 1 ] . The t e r m " t a u g h t " , i n r o b o t i c s , r e f e r s t o t h e p r o c e s s o f m a n u a l l y g u i d i n g t h e r o b o t t h r o u g h a new o p e r a t i o n . The r o b o t i s t h e n e x p e c t e d t o r e p e a t t h i s t a u g h t s e q u e n c e . I n most c a s e s , t h e r o b o t m o t i o n i s s e r v o e d u s i n g p r o x i m i t y s e n s o r s o r , more r e c e n t l y , s m a l l a r r a y c a m e r a s [ M a s a k i , Gorman & S h u l m a n , 8 1 ] . The n e g a t i v e f e e d b a c k i s most o f t e n a c c o m p l i s h e d by low l e v e l h a r d w a r e and t h e r o b o t d o e s n o t h a v e t h e a b i l i t y t o r e a s o n w i t h t h e i n f o r m a t i o n f e d b a c k f r o m t h e s e n s o r s [ F u t a m i , K i j u r a & M a t s u m o t o , 8 1 ] . I n o r d e r t o r e a l i z e a s e l f - s u f f i c i e n t a u t o m a t o n , a number of open l o o p s must be c l o s e d . I n t e r m s o f t h e p r e v i o u s d i s c u s s i o n , t h e a u t o m a t o n m u s t : 1) r e a l i z e t h e c u r r e n t s t a t e o f t h e w o r l d 2) f i n d and p o s e i t s own p r o b l e m s 3) l e a r n g e n e r a l k n o w l e d g e . 2 Framework o f t h e F i e l d 30 The p r a c t i c e o f u s i n g v i s i o n t o p e r c e i v e t h e c u r r e n t s t a t e o f t h e w o r l d i s a p o p u l a r e x p e r i m e n t a l a r e a . The S t a n f o r d A l l a b o r a t o r y c a r t [ M o r a v e c , 81], f o r e x a m p l e , u s e s s t e r e o v i s i o n t o p l a n a r o u t e t h r o u g h a s e r i e s o f o b s t a c l e s . A s t u d y g r o u p h a s p r o p o s e d a d e m o n s t r a t i o n m i s s i o n t o T i t a n ( l a r g e s t s a t e l l i t e o f S a t u r n ) by a g e n e r a l - p u r p o s e s p a c e e x p l o r a t i o n s y s t e m [ F r e i t a , H e a l y & L o n g , 81]. A l t h o u g h s t i l l i n r a d i o c o n t r o l r a n g e , v e r y l o n g d e l a y s i n c o m m u n i c a t i o n s r e q u i r e some au t o m o n o u s b e h a v i o u r a n d t h u s t h e d e m o n s t r a t i o n i s an e x p e r i m e n t t o w a r d s a c h i e v i n g t h e a b o v e t h r e e c h a r a c t e r i s t i c s . 2 Framework o f t h e F i e l d 31 CHAPTER 3 The D e s i g n o f RCPS " V e r i l y , a s much k n o w l e d g e i s n e e d e d t o e f f e c t i v e l y u s e a f a c t a s t h e r e i s i n t h e f a c t . " De K l e e r , D o y l e , S t e e l e , & Sussman, 1977 T h i s c h a p t e r p r o p o s e s t h e d e s i g n o f a r e c u r s i v e l y c o n t r o l l e d p r o d u c t i o n s y s t e m i n t e r m s o f t h e d e f i n i t i o n a n d t h e o r y o f c o n t r o l p u t f o r t h by [ G e o r g e f f , 8 2 ] . The t h e o r y o f e f f e c t i n g c o n t r o l i s t h e n g e n e r a l i z e d w i t h o u t c h a n g i n g t h e f u n d a m e n t a l d e f i n i t i o n . 3.1 R e p r e s e n t i n g t h e C o n t r o l Language "And we have now moved down a n o t h e r l e v e l , t o t h e i n t e r p r e t e r o f t h e i n t e r p r e t e r - w r i t i n g l a n g u a g e o f t h e r e p r e s e n t a t i o n l a n g u a g e . " H a y e s , 1977 R e c a l l , f r o m c h a p t e r two, t h e d e f i n i t i o n o f c o n t r o l i n t e r m s o f a c o n t r o l l a n g u a g e o v e r t h e r u l e names o f t h e PS. The c o n t r o l l a n g u a g e s p e c i f i e s e v e r y a l l o w a b l e r u l e s e q u e n c e . A s e q u e n c e of' r u l e s i s c a l l e d t h e c o n t r o l w ord w h i l e t h e l a s t r u l e i n t h e s e q u e n c e ( i . e . t h e l a s t r u l e t o be a p p l i e d ) i s c a l l e d 3 The D e s i g n o f RCPS 32 t h e s u f f i x . T h e r e a r e e s s e n t i a l l y two ways o f i m p l e m e n t i n g s u c h a l a n g u a g e w h i c h we s h a l l c a l l t h e " a c c e p t " method and t h e " g e n e r a t e " m e thod. I n t h e a c c e p t m e t h o d , t h e r u l e s c h o s e n f r o m t h e t o t a l s e t a r e c o m p a r e d t o t h e s u f f i x o f t h e c o n t r o l w o r d s w h i c h m a t c h t h e c u r r e n t i n f e r e n c e p a t h ( i . e . t h e s e q u e n c e o f r u l e s a p p l i e d so f a r ) u n t i l a m a t c h i n g r u l e i s f o u n d . The g e n e r a t e m e t h o d f i n d s a m a t c h i n g c o n t r o l word and r e t u r n s t h e s u f f i x a s t h e n e x t r u l e t o c o n s i d e r . T h i s l a t t e r method i s t h e one u s e d by RCPS. S i n c e t h e c o n t r o l w o r d i s b u t a s e q u e n c e o f r u l e names, we s h a l l c a l l i t a " p l a n " , w h i l e t h e s u f f i x o f t h e c o n t r o l w o r d s h a l l be c a l l e d t h e " n e x t - r u l e " . We c a n r e p r e s e n t a c o n t r o l l a n g u a g e by a s e t o f r u l e s , t h u s : P L A N ( R 1 ; R2; ... ; Rn) -> N E X T_RULE(R). The a l g o r i t h m w h i c h w o u l d o p e r a t e on t h e s e r u l e s s i m p l y a t t e m p t s t o m a t c h t h e c u r r e n t p l a n w i t h t h e p r e c o n d i t i o n ( i . e . l e f t - h a n d s i d e ) of t h e r u l e and upon s u c c e s s r e t u r n s t h e n e x t r u l e t o be a p p l i e d . T h i s a l g o r i t h m a n d s e t o f r u l e s i s s i m p l y a PS w i t h a maximum d e p t h o f one l e v e l o f i n f e r e n c e . B e f o r e e x t e n d i n g t h i s c o n c e p t t o d e a l w i t h more m e t a f a c t s t h a n s i m p l y t h e c u r r e n t p l a n , an e x a m p l e of i t s u s e i s g i v e n . C o n s i d e r t h r e e r u l e s , Q1, Q2, and Q3. The p r e c o n d i t i o n o f Q1 a n d Q2 a l w a y s h o l d s and t h u s t h e r u l e s c a n a l w a y s be a p p l i e d . The r u l e Q3 h a s some p r e c o n d i t i o n . The s o l u t i o n s o u g h t i s t o a l t e r n a t e b e t w e e n Q1 a n d Q2 u n t i l t h e p r e c o n d i t i o n o f Q3 h o l d s a n d c a n be a p p l i e d ; t h a t i s , we want t o e f f e c t s e q u e n c i n g and 3 The D e s i g n o f RCPS 33 i t e r a t i o n . A concrete example is to input and echo a value u n t i l an ed i t condi t ion i s s a t i s f i e d . If l e f t uncont ro l l ed , a forward breadth-f i r s t search would produce the deduction in f igure 2, assuming two i t e r a t i o n s . Figure 2. Uncontrol led Der iva t ion of an I terated Sequence This so lu t ion is not only procedura l ly inadequate but, since the cont ro l strategy is not eas i l y express ib le in the object l e ve l ru l e s , i t is a lso d e s c r i p t i v e l y inadequate. The remedy to th i s problem is to def ine the fo l lowing cont ro l language where " * " denotes any p l an . 3 The Design of RCPS 34 -•PLAN ( * ) -> NEXT_RULE (Q1 ) P L A N ( * ; Q1) -> NEXT_RULE(Q2) P L A N ( * ; Q2) -> NEXT_RULE(Q3) P L A N ( * ; Q2) -> NEXT_RULE(Q1) T h i s s t r a t e g y c a n be e x p r e s s e d by t h e r e g u l a r ( t y p e 3) e x p r e s s i o n (Q1; Q 2 ) * ; Q3. I f t h e c o n t r o l s t r a t e g y o f t h e c o n t r o l PS i s t o a t t e m p t t h e a b o v e r u l e s i n t h e o r d e r s p e c i f i e d , b a c k t r a c k i n g t o t h e n e x t r u l e i f t h e r u l e s u g g e s t e d d o e s n o t a p p l y , t h e d e d u c t i o n p r o d u c e d i s l i n e a r . The l a s t two r u l e s b o t h h a v e t h e same p r e c o n d i t i o n t h u s t h e r u l e Q3 i s a t t e m p t e d f i r s t a n d i f i t d o e s n o t h o l d , t h e i t e r a t i o n i s c o n t i n u e d by s c h e d u l i n g Q1. 3.2 E x t e n d i n g t h e C o n t r o l L a n g u a g e R e p r e s e n t a t i o n We a r e c u r r e n t l y a b l e t o g e n e r a t e a c o n t r o l l a n g u a g e d e p e n d i n g on t h e c u r r e n t p l a n m e t a f a c t ; h o w e v e r , t h e r e i s no r e a s o n why o t h e r m e t a f a c t s c a n n o t be i n t r o d u c e d p r o v i d i n g t h e y a r e w a r r r a n t e d . A l s o , t h e r e i s no r e a s o n why t h e c o n t r o l l e v e l PS c a n n o t be augme n t e d t o more t h a n one l e v e l o f i n f e r e n c e a nd t h u s be a b l e t o r e a s o n w i t h t h e m e t a f a c t s . The a u g m e n t a t i o n o f t h e c o n t r o l l e v e l PS i s c o n s i d e r e d i n t h e n e x t s e c t i o n . The m e t a f a c t s a r e c a t e g o r i z e d i n t o : 1) d o m a i n i n d e p e n d e n t 2) d o m a i n d e p e n d e n t . S i n c e d o main d e p e n d e n t m e t a f a c t s c a n n o t be g e n e r a l i z e d , a 3 The D e s i g n o f RCPS 35 f a c i l i t y must be p r o v i d e d t o a l l o w t h e i r s p e c i f i c a t i o n by t h e u s e r . We a r e c o n c e r n e d w i t h d o m a i n i n d e p e n d e n t m e t a f a c t s where PLAN i s b u t one. I d e a l l y , we want a c o m p l e t e i n s t a n t a n e o u s d e s c r i p t i o n o f t h e o b j e c t l e v e l PS. We c l a i m , w i t h o u t p r o o f , t h a t t h e f o l l o w i n g m e t a f a c t s p r o v i d e s u c h a d e s c r i p t i o n : 1) t h e s e q u e n c e o f r u l e s a p p l i e d so f a r ( i . e . PLAN) 2) t h e c o m p l e t e s e t o f r u l e s 3) e v e r y o b j e c t l e v e l s t a t e o f t h e d a t a b a s e ; i n p a r t i c u l a r , t h e i n i t i a l , t h e c u r r e n t , and t h e f i n a l . The s e t o f r u l e s i s p r o v i d e d by m e t a f a c t s o f t h e f o r m R U L E ( < r u l e name>) an d by p r o v i d i n g a c c e s s t o t h e r u l e d a t a b a s e w h i c h i s i n d e x e d by r u l e name. T h u s , t h e c o n t e n t o f a r u l e c a n be o b t a i n e d v i a i t s name w h i c h i s p r o v i d e d a s m e t a f a c t . S i m i l a r l y , f r o m t h e PLAN m e t a f a c t and t h e RULE m e t a f a c t , e v e r y o b j e c t l e v e l s t a t e i s a c c e s s i b l e . The a c c e s s t o t h i s i n f o r m a t i o n i s s y s t e m d e p e n d e n t and t h u s i s c o n s i d e r e d i n t h e n e x t c h a p t e r . 3.3 The C o n t r o l L e v e l PS "We need t o be a b l e t o d e s c r i b e p r o c e s s i n g s t r a t e g i e s i n a l a n g u a g e a t l e a s t a s r i c h as t h a t i n w h i c h we d e s c r i b e t h e e x t e r n a l d o m a i n , a n d f o r good e n g i n e e r i n g , i t s h o u l d be t h e same l a n g u a g e . " H a y e s , 1977 R a t h e r t h a n h a v i n g a s e p a r a t e c o n t r o l l e v e l PS, t h e o b j e c t l e v e l PS i s u s e d t o r e c u r s i v e l y p l a n i t s own c o n t r o l s t r a t e g y , h e n c e t h e name RCPS. W i t h s u c h a scheme, we a r e n o t l i m i t e d t o 3 The D e s i g n o f RCPS 36 a s i n g l e l e v e l o f c o n t r o l . As w i t h any r e c u r s i v e p r o c e d u r e t h e f o l l o w i n g c o n d i t i o n s must be s p e c i f i e d : 1) t h e r e c u r s i v e c a l l 2) t h e manner i n w h i c h a s u b o r d i n a t e r e s u l t i s a m a l g a m a t e d i n t o t h e c u r r e n t l e v e l t o r e d u c e t h e p r o b l e m 3) t h e c o n d i t i o n on w h i c h t h e r e c u r s i o n s t o p s 4) t h e b o u n d a r y c o n d i t i o n u s e d a t t h e b o t t o m o f t h e r e c u r s i o n . T h e s e c o n d i t i o n s a r e d e p e n d e n t on t h e p a r t i c u l a r i m p l e m e n t a t i o n a n d t h u s w i l l be p r e s e n t e d i n d e t a i l i n t h e n e x t c h a p t e r ; h o w e v e r , we a r e i n a p o s i t i o n t o c o n s i d e r them a t t h e i n t u i t i v e l e v e l . The l a n g u a g e RCPS i s u s e d t o r e t u r n a p l a n g i v e n i n i t i a l a n d f i n a l s t a t e s . The r e c u r s i v e c a l l i s a c t u a l l y c o d e d i n RCPS, as o p p o s e d t o t h e h o s t l a n g u a g e ( i . e . The l a n g u a g e u s e d t o i m p l e m e n t RCPS) where t h e i n i t i a l s t a t e g i v e n i s t h e i n s t a n t a n e o u s d e s c r i p t i o n o f t h e c u r r e n t l e v e l PS and t h e f i n a l s t a t e i s t h e n e x t r u l e s o u g h t . The s o l u t i o n t o t h i s p a r t i c u l a r RCPS g o a l i s t h e n e x t r u l e t o c o n s i d e r a t t h e c u r r e n t l e v e l . When RCPS s o l v e s t h e p r o b l e m o f c h o s i n g t h e n e x t r u l e , t h e c o n d i t i o n o f t h e r u l e i s c h e c k e d and t h e c u r r e n t p l a n i s e x p a n d e d . S i n c e we a r e one r u l e c l o s e r t o t h e g o a l , t h e p r o b l e m h a s been r e d u c e d and t h u s w i l l e v e n t u a l l y t e r m i n a t e . The c o n d i t i o n on w h i c h t h e r e c u r s i o n s t o p s i s t h e l a c k o f k n o w l e d g e t o s o l v e t h e c u r r e n t p r o b l e m . T h u s , t h e r e c u r s i o n 3 The D e s i g n o f RCPS 37 b o t t o m s - o u t when no r u l e c a n be a p p l i e d t o an i n i t i a l s t a t e . S i n c e t h e r e c u r s i o n s t o p s when t h e r e i s no k n o w l e d g e a b o u t t h e n e x t r u l e t o c o n s i d e r , t h e b o u n d a r y c o n d i t i o n i s t o c h o s e a r u l e n o n d e t e r m i n i s t i c a l l y . The r u l e s t o c h o s e f r o m a nd t h e o r d e r o f c h o i c e must be s p e c i f i e d by t h e u s e r . S i n c e m e t a p l a n n i n g i s done e v e r y t i m e a r u l e i s n e e d e d , r u l e s a t a p a r t i c u l a r l e v e l may be s u g g e s t e d by p l a n s o f v a r y i n g d e p t h s . F o r e x a m p l e , k n o w l e d g e may e x i s t t o s u g g e s t a r u l e i n a p a r t i c u l a r c i r c u m s t a n c e b u t n o t i n a n o t h e r a n d t h u s , i n t h i s l a t t e r c a s e , a r u l e w i l l s i m p l y be c h o s e n n o n d e t e r m i n i s t i c a l l y . 3 The D e s i g n o f RCPS 38 CHAPTER 4 RCPS "Would y o u t e l l me, p l e a s e , w h i c h way I o u g h t t o go f r o m h e r e ? " , s a i d A l i c e . "That d e p e n d s a dood d e a l on where y o u want t o go" , s a i d t h e C a t . L e w i s C a r o l l The RCPS d e s i g n , i n t e r m s o f s p e c i f i c a l g o r i t h m s a n d d a t a s t r u c t u r e s , i s p r e s e n t e d i n . t h i s c h a p t e r . A l t h o u g h t h e d e t a i l s o f t h e d e s i g n a r e d e p e n d e n t on t h e c h o i c e o f ( h o s t ) i m p l e m e n t i n g l a n g u a g e , t h e d i s c u s s i o n i s g e n e r a l e nough t h a t any l a n g u a g e c a n be u s e d . 4.1 S e a r c h S t r a t e g y " Examine y o u r g u e s s . Don't l e t y o u r s u s p i c i o n , o r g u e s s , o r c o n j e c t u r e grow w i t h o u t e x a m i n a t i o n t i l l i t becomes i n e r a d i c a b l e . " P o l y a , 1945. S i n c e t h e d e f i n i t i o n o f c o n t r o l d o e s n o t r e l y on t h e s e a r c h s t r a t e g y , we a r e n o t l i m i t e d on t h e c h o i c e . The s e a r c h s t r a t e g y c h o s e n i s f o r w a r d a n d b r e a d t h - f i r s t . A b r e a d t h - f i r s t s t r a t e g y i s more a p p e a l i n g s i n c e we a r e g u a r a n t e e d t h a t i t w i l l f i n d t h e o p t i m a l s o l u t i o n i f one e x i s t s . A d e p t h - f i r s t s e a r c h , on t h e 4 RCPS 39 o t h e r h a n d , may p l u n g e i n t o an i n f i n i t e b r a n c h w i t h no hope o f d e t e c t i n g i t s p r e d i c a m e n t . [ K o w a l s k i , 79b] p r o v e s t h a t , i n g e n e r a l , t h e p r o b l e m o f d e t e c t i n g c y c l e s i n a p l a n i s u n d e c i d a b l e . The f o r w a r d c h a r a c t e r i s t i c i s a p p e a l i n g a s t h e r e i s no p r o b l e m w i t h i n t e r a c t i n g g o a l s [ K i b l e r & M o r r i s , 8 1 ] ; h o w e v e r , g e n e r a l l y t h e s e a r c h i s much l e s s g o a l - d i r e c t e d t h a n i t s c o u n t e r p a r t . I r o n i c a l l y , t h e u n i n f o r m e d n a t u r e o f t h e f o r w a r d s e a r c h i s a p p e a l i n g i n t h i s c o n t e x t s i n c e i t i s e x a c t l y t h e p r o b l e m t o w h i c h a s o l u t i o n i s s o u g h t . The c o n f l i c t r e s o l u t i o n i s s i m p l e . R u l e s a r e r e s t r i c t e d i f t h e y do n o t add ( o r remove) k n o w l e d g e f r o m t h e c u r r e n t s t a t e . T h i s h a s t h e e f f e c t o f , a t l e a s t , p r e v e n t i n g a s i n g l e r u l e f r o m c y c l i n g . The p r o b l e m o f p r e v e n t i n g c y c l e s a l t o g e t h e r i n a f i n i t e u n i v e r s e i s p r e s e n t e d by [ R o s e n s c h e i n , 8 1 ] . 4.2 R u l e S y n t a x , S e m a n t i c s , a n d R e p r e s e n t a t i o n RCPS r e c o g n i z e s t h r e e c o n s t r u c t s : 1) r u l e s t a t e m e n t s 2) p r o b l e m s t a t e m e n t s 3) m e t a f a c t s . The f o l l o w i n g D e f i n i t e C l a u s e Grammar (DCG) d e f i n e s t h e s y n t a x o f .RCPS and c a n a l s o s e r v e a s a s y n t a c t i c c h e c k e r . The s y n t a x o f a v a r i a b l e a n d an a t o m i c f o r m u l a i s n e c e s s a r i l y d e p e n d e n t on t h e p a r t i c u l a r PROLOG i m p l e m e n t a t i o n ; t h u s , f o r t h e s a k e o f g e n e r a l i t y , t h e y have been d e f i n e d i n t e r m s o f s y s t e m 4 RCPS 40 p r e d i c a t e s . /* D e f i n i t e C l a u s e Grammar f o r RCPS s t a t e m e n t s */ /* N o n - T e r m i n a l s */ RCPS => PROBLEM. RCPS => RULE. RCPS => METAFACT. PROBLEM RULE METAFACT => GIVEN & i m p l i e s & l e f t _ e n c l o s u r e & PLAN_VARIABLE & r i g h t _ e n c l o s u r e & GOAL. => PRECONDITION Sc i m p l i e s & l e f t _ e n c l o s u r e Sc ACTION S< r i g h t _ e n c l o s u r e & POSTCONDITION. => i m p l i e s Si l e f t _ e n c l o s u r e S< m e t a f a c t s S< r i g h t _ e n c l o s u r e S< GIVEN. GIVEN = > CONJUNCT. GOAL = > CONJUNCT. POSTCONDITION => CONJUNCT. PRECONDITION = > CONJUNCT. PRECONDITION = > CONJUNCT Sc o r S< PRECONDITION. PLAN VARIABLE = > v a r . PLAN VARIABLE = > PLAN Sc s e q u e n c e Sc v a r . ACTION = > a t o m i c . CONJUNCT = > SIGNED ATOMIC. CONJUNCT = > SIGNED ATOMIC Sc and Sc CONJUNCT. PLAN = > ACTION. PLAN = > ACTION Sc s e q u e n c e S< PLAN. SIGNED ATOMIC = > a t o m i c . SIGNED_ATOMIC = > SIGN Sc a t o m i c . SIGN = > NOT. SIGN = > i n d i r e c t i o n . SIGN = > NOT Sc i n d i r e c t i o n . SIGN = > NOT Sc i n d i r e c t i o n Sc NOT. SIGN = > i n d i r e c t i o n Sc NOT. NOT = > n o t . NOT = > n o t Sc NOT. /* T e r m i n a l s */ i m p l i e s => '->'.NIL. l e f t e n c l o s u r e => ' { ' . N I L . 4 RCPS 41 r i g h t _ e n c l o s u r e => m e t a f a c t s => o r => s e q u e n c e => an d => n o t => i n d i r e c t i o n => }'.NIL. 'METAFACTS'.NIL. |' . N I L . ; ' . N I L . &'.NIL. - ' . N I L . ! ' . N I L . /* S y s t e m D e p e n d e n t T e r m i n a l s V v a r ( * S 0 . * S 1 , * S 1 ) < - S T R I N G ( * S 0 , ' * ' . * ) . a t o m i c ( * S 0 . * S 1 , * S 1 ) <-( ATOM(*S0) | S K E L ( * S 0 ) ) & - S T R I N G ( * S 0 , ' * ' . * ) . The f o l l o w i n g a r e e x a m p l e s o f r u l e a n d p r o b l e m s t a t e m e n t s r e s p e c t i v e l y . ONTABLE(*X) & CLEAR(*X) & HANDEMPTY -> { P I C K U P ( * X ) } HOLDING(*X) & -•ONTABLE (*X) & --CLEAR (*X) & -HANDEMPTY. ONTABLE(A) & ONTABLE(B) & ON(C,A) & CLEAR(C) & CLEAR(B) & HANDEMPTY -> { * } ON(A,B) & ON ( B , C ) . The f o l l o w i n g r e a d i n g c a n be u s e d t o e x p r e s s t h e s e m a n t i c s o f t h e r u l e s t a t e m e n t : i f < p r e c o n d i t i o n > h o l d s , t h e n a f t e r < a c t i o n > , < p o s t c o n d i t i o n > h o l d s . The p r o b l e m s t a t e m e n t h a s a s i m i l a r r e a d i n g : i f < g i v e n > h o l d s , t h e n a f t e r what s e q u e n c e o f a c t i o n s ( i . e . p l a n ) d o e s t h e <goal> h o l d . The o n l y d i f f e r e n c e b e t w e e n t h e s e s t a t e m e n t s i s t h a t t h e p r o b l e m s t a t e m e n t h a s a v a r i a b l e where t h e a c t i o n w o u l d be ( a c t u a l l y , 4 RCPS 42 f o r c o n v e n i e n c e , a r u l e may a l s o have d i s j u n c t s i n t h e p r e c o n d i t i o n ) . T h i s v a r i a b l e w i l l be i n s t a n t i a t e d t o t h e p l a n a f t e r t h e e x e c u t i o n o f t h e s t a t e m e n t . The p r e c o n d i t i o n i s t h e w e a k e s t c o n d i t i o n t h a t must h o l d f o r a p p l i c a b i l i t y o f t h e r u l e . S i m i l a r l y , t h e g i v e n c o n s i s t s o f a l l t r u e f a c t s . E v e r y t h i n g e l s e i s c o n s i d e r e d f a l s e . The t e r m " c l o s e d w o r l d a s s u m p t i o n " (CWA) h a s b een g i v e n t o t h i s a s s u m p t i o n [ R e i t e r , 7 8 ] . The p o s t c o n d i t i o n i s s i m i l a r l y t h e w e a k e s t ; t h a t i s , o n l y f a c t s whose t r u t h h a s c h a n g e d n e e d be m e n t i o n e d . S i m i l a r l y , t h e g o a l c o n s i s t s o f o n l y t h e f a c t s t h a t n e e d t o h o l d . The a c t i o n p l a y s a v e r y i m p o r t a n t r o l e i n t h e r u l e s a s i t i s c o n s i d e r e d a f r a m e w h i c h c o n t a i n s t h e r u l e s ' b i n d i n g s . The a c t i o n f r a m e s a r e u s e d i n a d e e p b i n d i n g manner t o d e d u c e t h e f a c t s t h a t a r e t r u e a f t e r t h e a c t i o n . H e n c e , t h e a r g u m e n t l i s t o f t h e a c t i o n must m e n t i o n e v e r y a r g u m e n t i n c l u d e d i n t h e p o s t c o n d i t i o n . The a l g o r i t h m f o r a c c o m p l i s h i n g t h i s f e a t i s c o n s i d e r e d i n t h e n e x t s e c t i o n . T h e r e a r e a l s o two b i n a r y o p e r a t o r s a n d two u n a r y . The "&" a n d t h e "|" a r e s i m p l y t h e l o g i c a l c o n n e c t i v e s "and" a n d " o r " . The u n a r y o p e r a t o r i s t h e " n o t " c o n n e c t i v e w h i c h i s a c c o m p l i s h e d v i a ' n e g a t i o n a s f a i l u r e ' [ C l a r k , 78] ( t h u s e f f e c t i n g a CWA). The i n d i r e c t i o n o p e r a t o r , "!", i s s i m p l e b u t i s v e r y u s e f u l i n RCPS. N o t i c e , f r o m t h e s y n t a x , t h a t o n l y one l e v e l o f i n d i r e c t i o n i s a l l o w e d . T h i s o p e r a t o r i s u s e d t o p a s s i t s o p e r a n d t o t h e h o s t l a n g u a g e . T h i s h a s t h e e f f e c t o f p r o v i d i n g a c c e s s t o t h e h o s t f r o m w i t h i n any c o n s t r u c t a t any l e v e l . The i n d i r e c t i o n o p e r a t o r i s most u s e f u l f o r a c c e s s i n g p r o c e d u r e s 4 RCPS 43 w r i t t e n i n t h e h o s t l a n g u a g e ( l i k e a r i t h m e t i c and I / O ) . The m e t a f a c t s c o n s t r u c t i s u s e d t o s p e c i f y d o m a i n d e p e n d e n t m e t a f a c t s a c c e s s i b l e a t a l l c o n t r o l l e v e l s ( i . e . e v e r y l e v e l e x c e p t t h e o b j e c t ) . The r u l e s a r e r e p r e s e n t e d a s a s s e r t i o n s i n a r e l a t i o n a l d a t a b a s e . The p a r t i c u l a r r e p r e s e n t a t i o n i s c h o s e n f o r t h e c o n v e n i e n c e o f t h e a l g o r i t h m s w h i c h o p e r a t e on them. The r e p r e s e n t a t i o n i s c o n s i d e r e d i n more d e t a i l when t h i s a l g o r i t h m i s p r e s e n t e d i n t h e n e x t s e c t i o n . T h e r e a r e two t y p e s o f a s s e r t i o n s f o r e v e r y r u l e , b o t h i n d e x e d b y . t h e r u l e name ( i . e . t h e a c t i o n ) . The f i r s t t y p e o f a s s e r t i o n c o n t a i n s t h e e n t i r e p r e c o n d i t i o n o f t h e r u l e . T h e r e i s a l w a y s e x a c t l y one o f t h e s e . T h e r e a r e a number o f a s s e r t i o n s o f t h e s e c o n d t y p e ; t h a t i s , one f o r e v e r y a t o m i c f o r m u l a i n t h e p o s t c o n d i t i o n . The m e t a f a c t s a r e t h e d e g e n e r a t e c a s e where o n l y t h e s e c o n d t y p e o f a s s e r t i o n i s p r e s e n t . 4.3 R e p r e s e n t i n g S t a t e I n f o r m a t i o n i n P l a n s "What i s p a s t , e v e n t h e f o o l knows" Homer, I l i a d R a t h e r t h a n s t o r e s t a t e i n f o r m a t i o n e x t e n s i o n a l l y a s i s done i n most P S s , ( e g . S T R I P S ) , t h e s t a t e i n f o r m a t i o n i s s t o r e d i n t e n s i o n a l l y i n p l a n s . I n t u i t i v e l y , c o n s i d e r a s i n g l e i n s t a n t i a t e d a c t i o n . S i n c e t h e a c t i o n c o n t a i n s , by d e f i n i t i o n , 4 RCPS 4 4 e v e r y a r g u m e n t i n t h e p o s t c o n d i t i o n , i t c a n be u s e d t o a c c e s s and i n s t a n t i a t e t h e p o s t c o n d i t i o n a s s e r t i o n s . T h u s , i t i s n o t n e c e s s a r y t o s t o r e a l l , t h e i n s t a n t i a t e d p o s t c o n d i t i o n s b u t s i m p l y t h e a c t i o n . The a l g o r i t h m w h i c h d e t e r m i n e s t h e t r u t h o f f a c t s f r o m a p l a n ( i . e . a s e q u e n c e o f a c t i o n s ) , i s known as a r e g r e s s i o n [ W a l d i n g e r , 7 7 ] . T h i s a l g o r i t h m i s i m p r e s s i v e l y e x p l o i t e d by [ W a r r e n , 7 4 ] i n W a r p l a n . T h u s , a p l a n s e r v e s t h e d u a l p u r p o s e o f r e p r e s e n t i n g t h e s e q u e n c e o f a c t i o n s w h i c h r e s u l t i n a s t a t e a n d , u s i n g t h e r e g r e s s i o n a l g o r i t h m , o f s t o r i n g t h e i n s t a n t i a t i o n s t o d e t e r m i n e t h e t r u t h o f f a c t s i n t h a t s t a t e 8 . T h i s a l g o r i t h m f o r m s t h e d e g e n e r a t e c a s e o f t r u t h m a i n t e n a n c e s y s t e m s (TMS) [ D o y l e , 7 9 ] where t h e a c t i o n i s c o n s i d e r e d a s t h e s o l e j u s t i f i c a t i o n f o r t h e t r u t h o f t h e f a c t . The a c t u a l t r u t h m a i n t e n a n c e PROLOG c o d e i s p r e s e n t e d a s a means o f c o m m u n i c a t i n g t h e a l g o r i t h m and t h e s y n t a x o f t h e r u l e a s s e r t i o n s . /* T r u t h M a i n t e n a n c e S y s t e m V TRUE({*ACTS}*FACT & *REST) /* C o n j u n c t i o n s */ <-/ /* CR */ & TRUE({*ACTS}*FACT) & T R U E ( { * A C T S } * R E S T ) . TRUE({*ACTS}*FACT | *REST) /* D i s j u n c t i o n s */ <- / /* CR */ & ( TRUE({*ACTS}*FACT) | T R U E ( { * A C T S } * R E S T ) ) . 8 A f a c t i s t r u e o n l y r e l a t i v e t o an i n t e r p r e t a t i o n . I n t h i s c a s e , t h e p o s t c o n d i t i o n a s s e r t i o n s f o r m t h e i n t e r p r e t a t i o n t o t h e a c t i o n ; t h a t i s , c h a n g i n g t h e a s s e r t i o n s c h a n g e s t h e t r u t h o f t h e f a c t s . 4 RCPS 45 TRUE( {* ACTS j " 1 * FACT) /* <-/ /* CR */ & -TRUE({*ACTS}*FACT). TRUE({*}!*FACT) /* <-/ /* CR */ & *FACT. TRUE({*REST;*ACT}*FACT) /* <-({*ACT}*FACT)7. /* TRUE({*REST;*ACT}*FACT) /* <-/ /* CR */ /* & TRUE((*REST}*FACT) & N O T ( ( { * A C T } - * F A C T ) ? ) . TRUE({*ACT}*FACT) /* <-/ /* CR */ /* & ( ( * A C T } * F A C T ) ? . TRUE(<*ACT>*FACT) /* <-(<*ACT>*FACT)?. N e g a t i o n */ I n d i r e c t i o n */ A t o m i c f a c t made t r u e by */ l a s t a c t i o n i n p l a n */ A t o m i c f a c t made t r u e by */ some o t h e r a c t i o n i n p l a n */ A t o m i c f a c t made t r u e by */ l a s t ( o n l y ) a c t i o n i n p l a n * / U s e d t o r e t r i e v e p r e c o n d i t i o n */ S i n c e a p l a n r e p r e s e n t s a s t a t e , t h e e n t i r e s t a t e s p a c e c a n be r e p r e s e n t e d by a number o f p l a n s . A p l a n i s r e p r e s e n t e d as a f a c t , t h u s : PLAN(<ACTI0N1>; <ACTI0N2>; ... <ACTIONn>, <DEPTH>) wh e r e : ACTIONi i s an a c t i o n DEPTH i s t h e number o f a c t i o n s - 1 ( i . e . t h e d e p t h o f t h e b r a n c h i n t h e d e d u c t i o n t r e e ) . The p l a n s a r e a s s e r t e d , w i t h i n a g i v e n d e p t h , i n t h e o r d e r g e n e r a t e d . 4 RCPS 46 4.4 The R e c u r s i v e V i r t u a l M a c h i n e We a r e now i n a p o s i t i o n t o p r e s e n t i n d e t a i l t h e i d e a s i n t r o d u c e d i n t h e p r e v i o u s c h a p t e r i n t e r m s o f t h e r e p r e s e n t a t i o n s a n d a l g o r i t h m s o f t h i s c h a p t e r . The TMS, a s d e s c r i b e d i n t h e p r e v i o u s s e c t i o n , i s u s e d e x t e n s i v e l y by t h e RCPS i n t e r p r e t e r . R e c a l l t h a t t h e TMS c a n a s s o c i a t e f a c t s w i t h some a c t i o n . I n e f f e c t , i t f o r m s a p a r t i t i o n e d memory where e v e r y i n s t a n t i a t i o n c a n be r e g a r d e d a s a s e p a r a t e p a r t i t i o n . The p u r p o s e o f t h e TMS i s t o k e e p a s e q u e n c e o f s u c h p a r t i t i o n s c o n s i s t e n t . The TMS i s u s e d t o s t o r e t h e f o l l o w i n g i n f o r m a t i o n : 1) t h e r u l e s ' c o n d i t i o n s a s d e s c r i b e d i n t h e p r e v i o u s s e c t i o n : ASSERT(<*ACTION> *PRECONDITION) ASSERT({*ACTION} *POSTCONDITION) 2) t h e r u l e names: ASSERT({RULES} RULE(*ACTION)) 3) t h e s t a t e s p a c e : A S S E R T ( { L E V E L ( * L E V E L ) } PLAN(*PLAN, *DEPTH)) w h e r e : *LEVEL i s 0 f o r t h e o b j e c t l e v e l a n d i n c r e m e n t e d f o r e v e r y m e t a l e v e l 4) t h e g i v e n f a c t s o f a p r o b l e m a t a p a r t i c u l a r l e v e l : A S S E R T ( { L E V E L ( * L E V E L ) } * G I V E N ) . E v e r y p r o b l e m h a s a s e p a r a t e o r l o c a l p a r t i t i o n , d e f i n e d by t h e l e v e l , w h i l e t h e e n t i r e s e t o f r u l e s i s g l o b a l t o e v e r y p r o b l e m ; 4 RCPS 47 in p a r t i c u l a r , rules are not d is t inguished by order. Reconsider the condit ions for recurs i v i t y introduced in sect ion 3.3. The RCPS recursive c a l l is the fol lowing problem statement. ( LEVEL(*LEVEL) & PLAN(*PLAN) & *G & DEPTH(*DEPTH) -> {METAFACTS;RULES;*MP} NEXT_RULE(*ACT) ) The l o ca l given facts to the problem of f inding the next rule are: 1) the metalevel number which we are reasoning about 2) the p lan , which is used fo r : 1) the sequence of act ions appl ied so far 2) the state information access ib le by an ind i rec t ion to the TMS 3) the current ly unsolved goals 4) the depth of inference (a convenience). The g lobal facts to the problem, represented by the p a r t i a l plan METAFACTS; RULES, are any domain dependent metafacts declared by the user using the METAFACT statement and the rule names. The content of the rules is access ib le by an ind i rec t ion to the TMS database. It is th i s set of l oca l and global facts that forms the instantaneous descr ip t ion of the PS. This problem, when solved, returns a metaplan and the act ion suggested by th i s p lan . If the precondit ion of th is act ion is true in the current p lan , the act ion is used to expand the plan thus reducing the 4 RCPS 48 p r o b l e m ; o t h e r w i s e , t h e p r o b l e m o f f i n d i n g a r u l e i s r e c o n s i d e r e d . I f a r u l e c a n n o t be f o u n d , t h e o b j e c t l e v e l p r o b l e m c a n n o t be s o l v e d a n d t h e t o p l e v e l RCPS p r o b l e m s t a t e m e n t f a i l s . The PROLOG c o d e t o f o l l o w i s t h e c o r e o f t h e RCPS v i r t u a l m a c h i n e . I t i s c a l l e d w i t h t h e g o a l , t h e l e v e l , a n d t h e d e p t h . I t i s e x p e c t e d t o r e t u r n t h e p l a n on s u c c e s s . The d e c i s i o n t o c a l l t h e p r e d i c a t e SOLVE i s c o n s i d e r e d l a t e r . /* M a i n p r o d u c t i o n s y s t e m l o g i c */ SOLVE(*GOAL,*LEVEL,*PLAN,*DEPTH) /* I f t h e g o a l i s < - T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * P L A N , * D E P T H ) ) /* t r u e a t t h e & T R U E ( { * PLAN}*GOAL). /* c u r r e n t d e p t h /* a n d l e v e l , /* r e t u r n p l a n . SOLVE(*GOAL,*LEVEL,*PLAN;*ACT,*DEPTH) /* C r e a t e g i v e n o f <-ADD1(*DEPTH,*NEXT) /* c u r r e n t p l a n a n d & T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * P L A N , * D E P T H ) ) /* u n s o l v e d g o a l s a t & GOAL_ASSERTION(*GOAL,*PLAN,*G) /* c u r r e n t l e v e l f o r & ( L E V E L ( * L E V E L ) & P L A N ( * PLAN) /* r e c u r s i v e c o n t r o l & *G & DEPTH(*DEPTH) /* c a l l . -> {METAFACTS;RULES;*MP} NEXT_RULE(*ACT) ) & TRACE3(*PLAN;*ACT,*MP,*DEPTH,*LEVEL) & TRUE(<*ACT>*PRECONDITION) /* Does c o n d i t i o n & (TRUE({*PLAN}*PRECONDITION) /* o f s u g g e s t e d r u l e | (TRACE6(*ACT,*LEVEL) & F A I L ) ) /* h o l d ? & TRACE4(*PRECONDITION,*ACT,*LEVEL) & CONFLICT_RESOLUTION(*ACT,*PLAN,*LEVEL) /* Does i t p a s s c o n -& TRACE5(*LEVEL) /* f l i c t r e s o l u t i o n ? S= A S S E R T ( { L E V E L ( * L E V E L ) } P L A N ( * P L A N ; * A C T , * N E X T ) ) & F A I L . /* A p p l y i t by /* e x p a n d i n g p l a n . SOLVE(*GOAL,*LEVEL,*PLAN,*DEPTH) /* F l u s h p r e v i o u s < - F L U S H ( ( { L E V E L ( * L E V E L ) } P L A N ( * , * D E P T H ) ) ? ) /* l e v e l . & ADD1(*DEPTH,*NEXT) /* C o n s i d e r n e x t l e v e l & T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * , * N E X T ) ) /* I s t h e r e a p a t h t o & SOLVE(*GOAL,*LEVEL,*PLAN,*NEXT). /* c o n s i d e r ? I n c r e a s e /* d e p t h o f i n f e r e n c e 4 RCPS 49 Once an RCPS p r o b l e m s t a t e m e n t i s p a r s e d and t h e g i v e n i n i t i a l s t a t e a s s e r t e d i n t o t h e TMS, t h e p r e d i c a t e PLAN b e l o w i s g i v e n c o n t r o l w i t h t h e l e v e l number and g o a l a s a r g u m e n t . I t must d e c i d e w h e t h e r t h e r e i s a p p l i c a b l e c o n t r o l k n o w l e d g e a nd t h u s c a l l SOLVE, o r c h o o s e a r u l e i f t h e r e i s no k n o w l e d g e ( p r o v i d i n g t h e g o a l i s t o f i n d t h e n e x t r u l e ) , o r e l s e i t f a i l s . /* C o n d i t i o n f o r r e c u r s i v i t y V PLAN(*LEVEL,*GOAL,*PLAN) <-TRUE({RULES}RULE(*ACT)) /* I f t h e r e i s some r u l e & TRUE(<*ACT>*PRECONDITION) /* whose p r e c o n d i t i o n h a s & ANY_POS(*PRECONDITION) /* some p o s i t i v e a t o m i c & T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * G I V E N , 0 ) ) /* a n d i s c u r r e n t l y t r u e & TRUE({*GIVEN}*PRECONDITION) /* t h e n , s o l v e g o a l & / /* GT & CR */ & SOLVE(*GOAL,*LEVEL,*PLAN,0). /* r e c u r s i v e l y . P LAN(*LEVEL,NEXT_RULE(*ACT),CHOOSE(*ACT)) /* I f no k n o w l e d g e , <-TRUE({METAFACTS}CHOOSE(*ACT)). /* c h o o s e a c t i o n s i n /* o r d e r a s s e r t e d i n /* m e t a f a c t s . 4.5 The RCPS Run-Time S y s t e m T h i s s e c t i o n c o n c l u d e s t h e d e s c r i p t i o n o f RCPS by b r i e f l y c o n s i d e r i n g i t s r u n - t i m e s y s t e m . The p u r p o s e o f t h i s t o p - l e v e l s e t o f PROLOG p r e d i c a t e s i s t o : 1) p a r s e t h e RCPS l a n g u a g e 2) p r o v i d e e r r o r d e t e c t i o n a n d r e c o v e r y 3) p r e t t y p r i n t e c h o s a nd r e s u l t s 4) c o l l e c t u n n e e d e d g a r b a g e f r o m t h e TMS 5) p r o v i d e v a r i o u s t r a c e o p t i o n s . The t e r m i n a l s o f t h e RCPS DCG, p r e s e n t e d i n s e c t i o n 4.2, 4 RCPS 50 are declared as PROLOG operators. Thus, RCPS statements are considered PROLOG goals and can be parsed by the host PROLOG. Error traps have been declared along with su i tab le error messages. The trace options are an essent ia l part of RCPS as they provide great insight on the behaviour of the interpreter and how the knowledge is used. Their use t yp i c a l l y leads to ins ights which can, hopefu l ly , be coded as RCPS knowledge. There are four opt ions: 1) no trace 2) checkpoint: writes the plan a f ter every n expansions restar t is by giv ing th is as a p a r t i a l plan 3) a l l successes: th is is the most useful and is the one used in the appendices 4) everything: every plan attempted. The use of RCPS is further presented in appendix F. 4.6 Content Reference: An Example Terminal Session Consider the fol lowing set of ru l es . true -> { A } a. true -> { B } b. true -> { C } c. true -> { D } d. These rules state that whenever " t rue" holds in a s tate , the rule (whose name is enclosed in braces thus "{ }") can be appl ied to that state resu l t ing in a state where the post 4 RCPS 51 c o n d i t i o n h o l d s . The p r o b l e m s we w i s h t o s o l v e w i t h t h e s e r u l e s have t h e f o l l o w i n g f o r m . t r u e -> {*} *GOAL w h e r e : *GOAL i s one o f a , b, c, o r d T h i s g o a l s t a t e m e n t e x p r e s s e s t h a t " t r u e " c u r r e n t l y h o l d s a n d r e q u e s t s t h e p l a n t h a t w i l l r e s u l t i n t h e s o l u t i o n o f t h e g o a l s a , b, c , o r d. The s i m p l e s t s t r a t e g y we c o u l d s t a t e i s t h e s e q u e n c e o f CHOOSE m e t a f a c t s i n t h e o r d e r we w o u l d l i k e t h e r u l e s a t t e m p t e d . I f t h e p r e c o n d i t i o n s o f t h e r u l e s were m u t u a l l y d i f f e r e n t a n d d i f f i c u l t t o c o m p u t e , we may i n d e e d want t o s p e c i f y an o r d e r . O r , a g a i n , t h e g o a l d i s t r i b u t i o n may n o t be e v e n . A b e t t e r s t r a t e g y i s t o o n l y s c h e d u l e t h e r u l e w h i c h s o l v e s t h e g o a l . A f i r s t a p p r o x i m a t i o n t o i m p l e m e n t i n g t h i s s t r a t e g y may be t o s c h e d u l e t h e r u l e by name d e p e n d i n g on t h e p a r t i c u l a r g o a l . GOAL(a) -> { SCHEDULE(A)} N E X T _ R U L E ( A ) . C o n s i d e r t h e c o n s e q u e n c e s o f c h a n g i n g , f o r i n s t a n c e , t h e r u l e names ( o r , s a y , t h e a l p h a b e t i c a l l y c o n s i s t e n t m a p p i n g o f a c t i o n t o g o a l t o , f o r e x a m p l e , A -> b, B -> a, . . . ) . The s t r a t e g y , b e i n g t o o b r i t t l e a n d s p e c i f i c , must be c h a n g e d a c c o r d i n g l y . 4 RCPS 52 The s t r a t e g y c o n s i d e r e d i n the t e r m i n a l s e s s i o n below schedules the r u l e whose p o s t c o n d i t i o n i s the goal sought. The term used for the process of i n s p e c t i n g the content of a r u l e i s , a p p r o p r i a t e l y , "content r e f e r e n c e " [Davis, 80b]. The symbol "<-" i s the RCPS prompt. *** R e c u r s i v e l y C o n t r o l l e d P r o d u c t i o n System V e r s i o n 1.1 * * * <- /* Changing the RCPS source to f i l e "content" to input r u l e s */ SOURCE(content). true -> { A } a. true -> { B } b. true -> { C } c . true -> { D } d. <- /* Oops, T e s t i n g e r r o r recovery */ GOAL(*G) & !(({*R}*G)?) -> (STRATEGY*R)} NEXT RULE(*R). I <<<SYNTAX>>> Try again <- /* A content r e f e r e n c e s t r a t e g y */ OK_TO_USE_STRATEGY & GOAL(*G) & !(({(*R}*G)) ?) -> .{ STRATEGY (*R) } NEXT_RULE(*R). <- LEVEL(0) -> { CHECK_LEVEL } OK TO USE STRATEGY. 4 RCPS 53 <- /* The m e t a s t r a t e g y V -> {METAFACTS} CHOOSE(STRATEGY(*R)). <- -> {METAFACTS} CHOOSE(CHECK_LEVEL). <- /* P r o b l e m V ( t r u e -> {*} c ) & W R I T E ( ' T h i s i s a PROLOG g o a l ' ) . T h i s i s a PROLOG g o a l . t r u e -> { L E V E L ( 0 ) ; C } c & W R I T E ( T h i s i s a PROLOG g o a l ) . <- STOP. The t r a c e p r o d u c e d by t h i s s e s s i o n , u s i n g o p t i o n 3 ( a l l s u c c e s s e s ) , i s t h e f o l l o w i n g . G i v e n F a c t s t r u e G o a l t o be S o l v e d c M e t a P l a n CHOOSE(CHECK_LEVEL) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; CHECKJLEVEL P r e c o n d i t i o n o f CHECK_LEVEL h o l d s L E V E L ( 0 ) P l a n E x p a n d e d M e t a P l a n CHOOSE(STRATEGY(* 1 ) ) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; CHECK_LEVEL ; 4 RCPS 54 STRATEGY(* 1) P r e c o n d i t i o n o f STRATEGY(C) h o l d s OK_TO_USE_STRATEGY & GOAL(c) & ! ( ( { ( C } c ) ) ?) P l a n E x p a n d e d M e t a P l a n CHOOSE(CHECK_LEVEL) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; CHECK_LEVEL ; CHECK_LEVEL P r e c o n d i t i o n o f CHECK_LEVEL h o l d s L E V E L ( 0 ) C o n f l i c t R e s o l u t i o n R e s t r i c t s R u l e CHECK_LEVEL M e t a P l a n L E V E L ( 1 ) ; CHECK_LEVEL ; STRATEGY(C) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; C P r e c o n d i t i o n o f C h o l d s t r u e P l a n E x p a n d e d S o l u t i o n t o P r o b l e m t r u e -> { L E V E L ( 0 ) ; C } c. A l t h o u g h t h e c o n t r o l s t r a t e g y c a n be s p e c i f i e d u s i n g a s i n g l e r u l e , i t i s s p e c i f i e d u s i n g two a s a s i m p l e e x a m p l e o f m e t a r e a s o n i n g . As an e x a m p l e o f : 4 RCPS 5 5 1) using the same knowledge at d i f f e ren t leve ls 2) more than one leve l of con t ro l , consider the fol lowing ru l e : LEVEL(*L) & !LE(*L,2) & GOAL(*G) & !(({*R}*G)?) & -> {STRATEGY(*R)} NEXT RULE(*R). This content reference rule is used as a strategy to invoke i t s e l f as the object l eve l strategy. The trace produced using option 3 is in appendix A. 4 RCPS 56 CHAPTER 5 R e s u l t s a n d E v a l u a t i o n T h i s c h a p t e r c o n v e y s t h e r e s u l t s o f u s i n g RCPS t o a u t o m a t i c a l l y p r o g r a m t h e PUMA r o b o t arm. The g e n e r a t e d p l a n , when e x e c u t e d by t h e arm, w i l l s o l v e t h e s p e c i f i e d w i r e - w r a p p i n g p r o b l e m . The s p e c i f i c a t i o n o f t h e w i r e - w r a p p i n g p r o b l e m s a n d t h e r e s u l t s e x p e c t e d a r e c o n s i d e r e d f i r s t . The r e m a i n d e r o f t h e c h a p t e r c o n s i d e r s a s e t o f r u l e s whose c o n t r o l component i s p r o g r e s s i v e l y r e f i n e d . T h e s e s e t s o f r u l e s a r e u s e d t o s o l v e i n c r e a s i n g l y d i f f i c u l t p r o b l e m s a n d t h e r e s u l t s a r e t h e n c o m p a r e d . 5.1 P r o b l e m S p e c i f i c a t i o n a n d E x p e c t e d R e s u l t s The w i r e - w r a p p i n g p r o b l e m i s s p e c i f i e d a s one RCPS g o a l s t a t e m e n t . The b o a r d a nd s o c k e t s p e c i f i c a t i o n s a r e t h e " g i v e n " o f t h e s t a t e m e n t w h i l e t h e c o n n e c t i o n l i s t i s t h e " g o a l " . The r e s u l t o f e x e c u t i n g t h e g o a l s t a t e m e n t i s a p l a n w h i c h c a n be c o n v e r t e d t o a s y n t a c t i c a l l y v a l i d VAL p r o g r a m . S i n c e RCPS i s a s u b l a n g u a g e o f a h o s t l a n g u a g e , we w i l l c o n s i d e r a h y p o t h e t i c a l ( p r e / p o s t ) p r o c e s s o r , w r i t t e n i n t h e h o s t l a n g u a g e , w h i c h w i l l a i d i n t h e p r e p a r a t i o n o f t h e RCPS g o a l 5 R e s u l t s a n d E v a l u a t i o n 57 s t a t e m e n t a n d r e s u l t i n g VAL p r o g r a m . T h i s p r o c e s s o r h a s t h r e e b a s i c s t e p s . The f i r s t i s t h e p r e p r o c e s s i n g s t e p w h i c h c r e a t e s t h e RCPS g o a l s t a t e m e n t ; t h e s e c o n d i s t h e e x e c u t i o n o f t h e g o a l s t a t e m e n t by t h e i m bedded RCPS l a n g u a g e i n t e r p r e t e r ; and t h e f i n a l s t e p t r a n s l a t e s t h e r e s u l t i n g p l a n t o a s y n t a c t i c a l l y v a l i d VAL p r o g r a m . I n t u i t i v e l y , t h e " g i v e n " s h o u l d c o n s i s t o f a t l e a s t t h e p h y s i c a l a b s o l u t e l o c a t i o n o f t h e p i n s t o be c o n n e c t e d on t h e b o a r d , a n d t h e " g o a l " s h o u l d c o n s i s t o f t h e p i n c o n n e c t i o n l i s t . R a t h e r t h a n h a v i n g t o s p e c i f y t h e l o c a t i o n o f e v e r y p i n , t h e l o c a t i o n o f e v e r y IC c h i p o r DIP ( d u a l i n - l i n e p a c k a g e ) h e a d e r i s s p e c i f i e d . From k n o w l e d g e a b o u t t h e p h y s i c a l t o p o l o g y o f t h e c i r c u i t c o m p o n e n t s , t h e l o c a t i o n o f e v e r y p i n c a n be e a s i l y c a l c u l a t e d . E v e r y c i r c u i t component must t h e n be c h a r a c t e r i z e d by i t s number of p i n s . I n summary, ( a s i d e f r o m a few s t a r t - u p f a c t s , ) t h e " g i v e n " c o n s i s t s o f t h e l o c a t i o n o f e v e r y c i r c u i t component and i t s number o f p i n s , w h i l e t h e " g o a l " c o n s i s t s o f t h e p i n c o n n e c t i o n l i s t . The p r e p r o c e s s o r w o u l d f i r s t p r o m pt f o r t h e p i n c o n n e c t i o n l i s t a n d c o n s t r u c t t h e c o n j u n c t i v e g o a l , a s w e l l a s a c c u m u l a t e a l i s t o f a l l t h e c i r c u i t c o m p o n e n t s . P r o m p t i n g w i t h t h e c i r c u i t c o m p o n e n t s , t h e p r e p r o c e s s o r w o u l d t h e n c o n s t r u c t t h e g i v e n . An e x a m p l e of an RCPS g o a l s t a t e m e n t i s : 5 R e s u l t s and E v a l u a t i o n 58 SYMBOLIC O R I G I N ( o r i g i n ) & LOCATIONlSTARTIC,0:0) & LOC A T I O N ( I C , 1 0 0 0 : 1 000) & NO_PINS(STARTIC,0) & N O _ P I N S ( l C , 1 4) & WRAPPED(STARTIC:0) & ABOVE(STARTIC:0) -> { *P } CONNECT(IC:2,IC:1) & C O N N E C T ( I C : 3 , I C : 1 ) . G i v e n s u c h a g o a l s t a t e m e n t , RCPS u s e s t h e r u l e s , d e f i n e d l a t e r , t o c o n s t r u c t a p l a n w h i c h i s b o u n d t o t h e v a r i a b l e *P. L E V E L ( 0 ) ; S E T ( o r i g i n ) ; SI G N A L ( 2 , S T A R T I C : 0 ) ; SHI FT(IC:1,1025:1038,MOVING_TO_START_CHAIN(IC:1)) ; APPRO(IC:1,STARTIC:0,MOVING_TO_START_CHAIN(IC:1)) ; MOVES(IC:1,MOVING_TO_START_CHAIN(lC:1)) ; SIGNAL(1,IC:1,MOVING_TO_START_CHAIN(IC:1)) ; D E P A R T S ( I C : 1 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 , S O L V I N G G O A L ( I C : 3 , I C : 1 ) ) ; APPRO(IC:2,IC:1,SOLVING G O A L l l C : 3 , I C : 1 ) ) ; MOVES(IC:2,SOLVING_GOALTlC:3,IC:1)) ; S I G N A L ( 1 , I C : 2 , S O L V I N G _ G O A L ( I C : 3 , I C : 1 ) ) ; DEP A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 3 , 1 0 7 5 : 1 0 3 8 , S O L V I N G G O A L ( I C : 2 , I C : 1 ) ) ; A P P R 0 ( I C : 3 , I C : 2 , S 0 L V I N G G O A L T l C : 2 , I C : 1 ) ) ; MOVES(IC:3,SOLVING_GOALTlC:2,IC:1)) ; S I G N A L ( 1 , I C : 3 , S 0 L V I N G _ G 0 A L ( I C : 2 , I C : 1 ) ) . T h i s p l a n c a n t h e n be p o s t p r o c e s s e d r e s u l t i n g i n t h e f o l l o w i n g VAL p r o g r a m . REMARK D e f i n e t h e b o a r d r e f e r e n c e f r a m e . REMARK T h e s e VAL l o c a t i o n s a r e p r e s u m e d t o be d e f i n e d . FRAME BOARD = ORIGIN, X, Y, REMARK S t a r t o f c o n n e c t i o n SET P I N = ORIGIN REMARK T e r m i n a t e t h i s c h a i n by c u t t i n g w i r e a t p i n 0 o f STARTIC SIGNAL 2 REMARK S h i f t o r i g i n t o p i n 1 o f IC t o s t a r t c h a i n 5 R e s u l t s a n d E v a l u a t i o n 59 SHIFT P I N BY 102.5, 103.8 REMARK A p p r o a c h p i n 1 o f IC f r o m p i n 0 of STARTIC APPRO P I N , 20 REMARK I n s e r t t o o l on p i n 1 o f I C MOVES P I N REMARK Wrap p i n 1 of IC a c c o m p l i s h i n g s t a r t o f c h a i n SIGNAL 1 REMARK L e a v e p i n 1 o f IC DEPARTS 20 REMARK S t a r t o f c o n n e c t i o n SET P I N = ORIGIN REMARK S h i f t o r i g i n t o p i n 2 o f IC t o a c c o m p l i s h REMARK c o n n e c t i o n b e tween p i n 2 o f IC and p i n 1 o f IC SHIFT P I N BY 105.0, 103.8 REMARK A p p r o a c h p i n 2 o f IC f r o m p i n 1 o f IC APPRO P I N , 20 REMARK I n s e r t t o o l on p i n 2 o f I C MOVES P I N REMARK Wrap p i n 2 o f IC a c c o m p l i s h i n g REMARK c o n n e c t i o n b e t w e e n p i n 3 o f IC and p i n 1 o f IC SIGNAL 1 REMARK L e a v e p i n 2 o f IC DEPARTS 20 REMARK S t a r t o f c o n n e c t i o n SET P I N = ORIGIN REMARK S h i f t o r i g i n t o p i n 3 o f IC t o a c c o m p l i s h REMARK c o n n e c t i o n b e tween p i n 3 o f IC and p i n 1 o f IC SHIFT P I N BY 107.5, 103.8 REMARK A p p r o a c h p i n 3 o f IC f r o m p i n 2 o f I C APPRO P I N , 20 REMARK I n s e r t t o o l on p i n 3 o f IC MOVES P I N REMARK Wrap p i n 3 o f I C a c c o m p l i s h i n g REMARK c o n n e c t i o n b e tween p i n 2 o f IC and p i n 1 o f IC SIGNAL 1 RETURN 0 The p l a n c o n t a i n s enough ( e x p l i c i t a n d i m p l i c i t ) i n f o r m a t i o n t o a l l o w t h e p o s t p r o c e s s o r t o i n c l u d e comments i n t h e VAL c o d e t h u s . s e r v i n g a s an e x p l a n a t i o n . The p r o b l e m s t o be c o n s i d e r e d p r e s e n t t h e p r o b l e m s p e c i f i c a t i o n a n d s o l u t i o n i n a p i c t o r i a l f o r m a t . I t c o n s i s t s o f a d i a g r a m o f t h e p i n l o c a t i o n s a n d r e s u l t i n g p a t h s t a k e n t o 5 R e s u l t s a n d E v a l u a t i o n 60 accomplish the c o n n e c t i o n s . The c o n n e c t i o n s s p e c i f i e d as goal are drawn as d o t t e d c o n n e c t i o n s ( u n l e s s they are a l l i d e n t i c a l to the r e s u l t a n t ) . S i n c e both s e t s of c o n n e c t i o n s are ordered, they are numbered. The p r e v i o u s problem i s p r e s e n t e d by f i g u r e 3. o STARTIC F i g u r e 3. I n t r o d u c t o r y Problem S o l u t i o n 5.2 Rules f o r an E x h a u s t i v e U n c o n t r o l l e d D e r i v a t i o n The set of r u l e s modeling the wire-wrapping domain are p r e s e n t e d and f i r s t used without a c o n t r o l s t r a t e g y ( i . e . chosen n o n d e t e r m i n i s t i c a l l y ) . These r u l e s w i l l be used, with l i t t l e m o d i f i c a t i o n , i n a l l the f o l l o w i n g problems. The domain model i s simple and makes use of the f o l l o w i n g f a c t s : 1) the symbolic VAL name of the c i r c u i t board o r i g i n 2) whether the only program v a r i a b l e i s set to the o r i g i n or a p i n l o c a t i o n 3) whether the t o o l i s at or above a p i n 5 R e s u l t s and E v a l u a t i o n 61 4) whether a pin is wrapped or not 5) the given facts; namely, the location and number of pins of each component 6) a u x i l i a r y predicates. The a u x i l i a r y predicates are procedures written in the host language and accessed via the indirection operator. They are used to calculate the pin relocation s h i f t ( i . e . Displacement) from the component reference location. The heavily commented rules, in the form of paraphrases, are presented next. The casual reader may read the comments only. /* This set of rules, c a l l e d 'WRAP', i s the main set of logic rules which can be used without a control strategy ( i . e . chosen nondeterministically). This same set can be used with other control strategies. */ /* The program variable can be set to the o r i g i n whenever the start token is true. The start token i s an example of how control knowledge can be imbedded in the logic rules and is actually needed i f we do not want a metalevel. V SYMBOLIC_ORIGIN(*NAME) & START TOKEN -> TSET(*NAME)} VAR_SET_TO_ORIGIN & -VAR_SET_TO_PIN_LOCATION(*) & -START_TOKEN. /* If the program variable is set to the o r i g i n , choose a component and an unwrapped pin and s h i f t the o r i g i n according to the location of the component and the pin number. The program variable i s now set to the unwrapped pin location. V VAR_SET_TO_ORIGIN & LOCATION(*IC,*ICLOC) & NO_PINS(*IC,*N) & !BETWEEN(*PIN,1,*N) & -WRAPPED(*IC:*PIN) & 5 Results and Evaluation 62 !REFERENCE_PIN_SHIFT(*PIN,*N,*DISP) & !RELOCATE(*ICLOC,*DISP,*PINLOC) -> (SHIFT(*IC:*PIN,*PINLOC)} VAR_SET_TO_PIN_LOCATION(*IC:*PIN) & -VAR_SET_TO_ORIGI N. /* I f the program v a r i a b l e i s set to the next unwrapped p i n l o c a t i o n and the t o o l i s n e i t h e r at or above i t , then i t can be approached l e a v i n g the pre v i o u s p i n behind. V VAR SET_TO_PIN_LOCATION(*IC:*PIN) & -ATl*IC:*PIN) & -ABOVE(*IC:*PIN) & -WRAPPED ( * IC: *PIN) & ABOVE(*OLDIC:*OLDPIN) -> (APPRO(*IC:*PIN,*OLDIC:*OLDPIN)} ABOVE(*IC:*PIN) & -ABOVE(*OLDIC:*OLDPIN). /* I f above an unwrapped p i n , then moving to i t w i l l cause the t o o l to be at i t . V ABOVE(*IC:*PIN) & -WRAPPED(*IC:*PIN) -> {MOVES(*IC:*PIN)} AT(*IC:*PIN) & -ABOVE(*IC:*PIN). /* I f at an unwrapped p i n , then wrapping i t w i l l cause a connection between i t and any other wrapped p i n . V AT(*IC2:*PIN2) & -WRAPPED(*IC2:*PIN2) & WRAPPED(*IC1:*PIN1) -> {SIGNAL(1,*IC1:*PIN1,*IC2:*PIN2)} WRAPPED(*IC2:*PIN2) & CONNECT(*IC1:*PIN1,*IC2:*PIN2). /* If at a wrapped p i n , d e p a r t i n g w i l l cause the t o o l to be above i t and not at i t . T h i s terminates a connection and thus the s t a r t token can be a s s e r t e d to s t a r t the next. V WRAPPED(*IC:*PIN) & AT(*IC:*PIN) -> {DEPARTS(*IC:*PIN)} ABOVE(*IC:*PIN) & -AT(*IC:*PIN) & START TOKEN. /* Order that the r u l e s should be n o n d e t e r m i n i s t i c a l l y chosen. 5 R e s u l t s and E v a l u a t i o n 6 3 */ -> {METAFACTS}CHOOSE(SET(*)). -> {METAFACTS}CHOOSE(SHIFT(*,*)). -> {METAFACTS}CHOOSE(APPRO(*,*)). -> {METAFACTS}CHOOSE(MOVES(*)). -> {METAFACTS}CHOOSE(SIGNAL(*,*,*)) . -> {METAFACTS}CHOOSE(DEPARTS(*)). N o t i c e that s i n c e a r u l e does not e x i s t f o r c u t t i n g the wire, only a s i n g l e chained connection can be accomplished with these r u l e s . A c o n t r o l s t r a t e g y must always be s p e c i f i e d f o r RCPS r u l e s . S i n c e , i n t h i s case, we simply want the r u l e s to be chosen n o n d e t e r m i n i s t i c a l l y , we s t a t e the order that they should be attempted v i a the CHOOSE metafact. Contrary to the t h e s i s advocated here, a c o n t r o l token has been introduced i n the l o g i c r u l e s i n order to e f f e c t some sequencing. In a d d i t i o n to s e r v i n g as an example of how t h i s s t r a t e g y i s used, some form of c o n t r o l i s needed ( f o r t h i s example only) i n order to make the problem at a l l t r a c t a b l e . [Rychener, 77] d i s c u s s e s how sequencing between r u l e s i s accomplished v i a working memory. With such a forward search s t r a t e g y , the d e r i v a t i o n i s not focussed toward the g o a l . Most planners have a backward search s t r a t e g y and are thus goal d i r e c t e d simply because they are goal d r i v e n . Without a goal d i r e c t e d s t r a t e g y , t h i s set of r u l e s i s a p p l i e d e x h a u s t i v e l y i n order to form a l l combinations of 5 R e s u l t s and E v a l u a t i o n 64 c o n n e c t i o n s . Some of these w i l l s o l v e the intended g o a l . A simple problem, which w i l l be r e c o n s i d e r e d i n subsequent s e c t i o n s , i s shown i n f i g u r e 4 a l o n g with the de d u c t i o n t r e e produced. In t h i s diagram, the p r e v i o u s p i n i s used as the argument to SIGNAL. ser * SH = SH I FT A = /WROflCH M z Moves s • D ' DEPARTS STAftTJCC F i g u r e 4. E x h a u s t i v e Deduction and R e s u l t i n g S o l u t i o n 5 R e s u l t s and E v a l u a t i o n 65 The p e n e t r a n c e f o r t h i s p r o b l e m , a s d e f i n e d i n c h a p t e r 2, i s : P = L / T = 1 7 / 133. 5.3 A d d i n g a G o a l D i r e c t e d S t r a t e g y v i a M e t a R u l e s A l t h o u g h t h e u n c o n t r o l l e d s e t o f r u l e s s o l v e s t h e p r o b l e m s p e c i f i e d i n s e c t i o n 5.2, i t d o e s s o i n a v e r y i n e f f i c i e n t a n d u n i n f o r m e d manner a s c a n be seen f r o m t h e d e r i v a t i o n t r e e a n d p e n e t r a n c e f a c t o r . U s i n g t h i s s e t o f r u l e s , a c o n t r o l s t r a t e g y , i n t h e f o r m o f RCPS m e t a r u l e s , w i l l be a d d e d i n o r d e r t o s o l v e t h e d e f i c i e n c i e s c i t e d i n t h e p r e v i o u s s e c t i o n . The c o n t r o l s t r a t e g y h a s t h e f o l l o w i n g c h a r a c t e r i s t i c s . 1) The d e r i v a t i o n i s g o a l d i r e c t e d . 2) A l l r u l e s e q u e n c i n g , w h e t h e r p r e v i o u s l y a c c o m p l i s h e d by e x p l i c i t c o n t r o l t o k e n s o r i m p l i c i t l y by g o a l s , i s e x p l i c i t l y s t a t e d . B e f o r e f u r t h e r e x p l a n a t i o n , t h e s e c o n t r o l r u l e s a r e p r e s e n t e d a n d t h e i r i n c o r p o r a t i o n i n t o t h e l o g i c r u l e s d i s c u s s e d . /* T h i s s e t o f r u l e s , c a l l e d 'metawrap', i s a c o n t r o l s t r a t e g y f o r t h e s e t o f l o g i c r u l e s i n 'wrap'. The s t r a t e g y i s t o s o l v e t h e g o a l s e x a c t l y a s s p e c i f i e d . */ /* I f r e a s o n i n g a b o u t o b j e c t l e v e l w h i c h h a s no p l a n , t h e n s t a r t a c o n n e c t i o n . */ LEVEL(0) & DEPTH(0) -> {START_CONNECTION} N E X T _ R U L E ( S E T ( * ) ) . /* I f j u s t t e r m i n a t e d a c o n n e c t i o n , t h e n s t a r t t h e n e x t o ne. . 5 R e s u l t s a n d E v a l u a t i o n 6 6 */ P L A N ( * ; D E P A R T S ( * ) ) -> {CHAIN} N E X T _ R U L E ( S E T ( * ) ) . /* I f j u s t s t a r t i n g a c o n n e c t i o n , t h e n p i c k a g o a l w h i c h r e q u i r e s t h e c u r r e n t p i n t o be c o n n e c t e d t o a n o t h e r and c a l c u l a t e i t s s h i f t e d l o c a t i o n . V P L A N ( * P ; S E T ( * ) ) & G O A L ( C O N N E C T ( * I C 1 : * P I N 1 , * I C 2 : * P I N 2 ) ) & ! T R U E ( { * P } A B O V E ( * I C 1 : * P I N 1 ) & WRAPPED(*IC1:*PIN1)) -> {SEQUENCE 1 ( * I C 2 : * P I N 2 ) } N E X T _ R U L E ( S H I F T ( * I C 2 : * P I N 2 , * ) ) . /* A f t e r s h i f t i n g t h e v a r i a b l e t o t h e l o c a t i o n o f t h e p i n , i t c a n be a p p r o a c h e d . V P L A N ( * ; S H I F T ( * I C : * P I N , * ) ) -> { S E Q U E N C E 2 ( * I C : * P I N ) } N E X T _ R U L E ( A P P R O ( * I C : * P I N , * ) ) . /* A f t e r a p p r o a c h i n g a p i n , t h e t o o l c a n be moved t o i t . V P L A N ( * ; A P P R O ( * I C : * P I N , * ) ) -> { S E Q U E N C E 3 ( * I C : * P I N ) } N E X T _ R U L E ( M O V E S ( * I C : * P I N ) ) . /* A f t e r m o v i n g t o a p i n , w r a p p i n g i t w i l l c a u s e a c o n n e c t i o n b e t w e e n i t and t h e p r e v i o u s p i n . */ P L A N ( * ; M O V E S ( * I C 2 : * P I N 2 ) ) & G O A L ( C O N N E C T ( * I C 1 : * P I N 1 , * I C 2 : * P I N 2 ) ) -> { S E Q U E N C E 4 ( * I C 1 : * P I N 1 , * I C 2 : * P I N 2 ) } N E X T _ R U L E ( S I G N A L ( 1 , * I C 1 : * P I N 1 , * I C 2 : * P I N 2 ) ) . /* A f t e r w r a p p i n g a p i n t h e t o o l c a n d e p a r t . V P L A N ( * ; S I G N A L ( 1 , * , * I C : * P I N ) ) -> { S E Q U E N C E 5 ( * I C : * P I N ) } NEXT R U L E ( D E P A R T S ( * I C : * P I N ) ) . S i n c e t h i s c o n t r o l s t r a t e g y r e p l a c e s t h e p r e v i o u s n o n d e t e r m i n i s t i c s t r a t e g y , we r e p l a c e t h e CHOOSE m e t a f a c t s w i t h t h e s e r u l e s . S i n c e t h e s e c o n t r o l r u l e s must now h a v e t h e i r own c o n t r o l s t r a t e g y , we s p e c i f y t h e o r d e r o f c h o o s i n g them. 5 R e s u l t s a n d E v a l u a t i o n 67 A l t h o u g h we s t i l l h a ve some n o n d e t e r m i n i s m , t y p i c a l l y , f e w e r m e t a r u l e s a r e a p p l i c a b l e i n a g i v e n m e t a s t a t e t h a n t h e r u l e s b e i n g c o n t r o l l e d 9 . I n t h i s p a r t i c u l a r c a s e , o n l y one m e t a r u l e i s e v e r a p p l i c a b l e a n d t h u s e v e n t h o u g h t h e n o n d e t e r m i n i s t i c c o n t r o l s t r a t e g y ( o f t h e m e t a r u l e s ) r e q u i r e s t h e i n t e r p r e t e r t o l o o k f o r t h e one a p p l i c a b l e m e t a r u l e , o n l y t h e one m e t a r u l e i s e v e r a t t e m p t e d . We s a y t h a t s u c h a c o n t r o l s t r a t e g y i s d e t e r m i n i s t i c . N o t e t h a t t h e t o p l e v e l l o g i c d e r i v a t i o n i s n o t n e c e s s a r i l y d e t e r m i n i s t i c s i n c e one m e t a r u l e may h a v e more t h a n one i n s t a n t i a t i o n ; a l s o , t h e c o n t r o l s t r a t e g y o f t h e c o n t r o l s t r a t e g y i s n o n d e t e r m i n i s t i c . The s e q u e n c i n g o f t h e n e x t a p p l i c a b l e r u l e i s a c c o m p l i s h e d by e n s u r i n g t h a t t h e l a s t a c t i o n i n t h e PLAN m e t a f a c t i s i t s p r e d e c e s s o r . The f i v e s e q u e n c i n g m e t a r u l e s b u i l d , i n e f f e c t , a s u b r o u t i n e c o n t r o l s t r u c t u r e . T h i s r o u t i n e i s " c a l l e d " a t t h e b e g i n n i n g t o s t a r t a c o n n e c t i o n a n d a f t e r a c o n n e c t i o n h a s been a c c o m p l i s h e d t h u s e f f e c t i n g an i t e r a t i o n . The a r g u m e n t s t o t h e s u b r o u t i n e a r e o b t a i n e d d i r e c t l y f r o m t h e g o a l . . T h i s e n s u r e s t h a t o n l y t h e c o n n e c t i o n s s p e c i f i e d a s g o a l a r e a c c o m p l i s h e d by t h e s c h e d u l i n g o f t h e s u b r o u t i n e . N o t i c e t h e u s e o f t h e i n d i r e c t i o n o p e r a t o r t o d e t e r m i n e t h e t r u t h o f f a c t s i n t h e o b j e c t l e v e l p l a n ; t h a t i s , i n g e n e r a l , t o d e t e r m i n e t h e t r u t h o f f a c t s i n a s t a t e a b o u t w h i c h t h e r u l e s a r e r e a s o n i n g . T h i s i s t h e means u s e d t o c o m m u n i c a t e h i g h l e v e l f a c t s t o a l o w e r 9 T h i s i s a c t u a l l y a f u n d a m e n t a l a s s u m p t i o n b e h i n d t h e t h e o r y . 5 R e s u l t s a nd E v a l u a t i o n 68 m e t a l e v e l . Conversely, t h i s set of metarules does not yet have means f o r communicating lower l e v e l s t r a t e g i c i n f o r m a t i o n to the higher l e v e l s . N o t i c e , f o r t h i s reason, that the goal i s r e i n s t a n t i a t e d when i t i s again needed by another r u l e . That i s , the subroutine has l o s t , due to scope, i t s j u s t i f i c a t i o n and thus i t must be rededuced. Without l o s s of g e n e r a l i t y , j u s t i f i c a t i o n s can be h e l d i n s p e c i a l l y a l l o c a t e d s l o t s i n the a c t i o n s . If the j u s t i f i c a t i o n i s again needed, i t can be accessed at the metalevel simply by i n s p e c t i n g the o b j e c t l e v e l plan p r o v i d e d as metafact. T h i s technique i s used i n the next set of metarules. T h i s c o n t r o l s t r a t e g y allows the r u l e s to accomplish the p r e v i o u s problem r e s u l t i n g i n the same s o l u t i o n but with a penetrance of 17 / 34; that i s , f o r every r u l e on the path, one metarule had to be f i r e d to schedule i t and no other s t r a y r u l e i s f i r e d . A p a r t i a l RCPS t r a c e of t h i s deduction i s i n c l u d e d in appendix E. 5.4 Augmenting the Goal D i r e c t e d Strategy with H e u r i s t i c s Although the previous c o n t r o l s t r a t e g y has focussed a t t e n t i o n toward the goal, the s o l u t i o n i s not very i n t e l l i g e n t . In g e n e r a l , the previous s t r a t e g y s o l v e s the problem by accomplishing e x a c t l y the goals s p e c i f i e d and thus the user must i n t e l l i g e n t l y s p e c i f y the g o a l s . The i d e a l case would o p t i m a l l y solve the problem independent of the manner i n which the goal i s 5 R e s u l t s and E v a l u a t i o n 69 p o s e d . S u c h a s t r a t e g y i s p r e s e n t e d w i t h o u t p r o o f o f s o u n d n e s s o r c o m p l e t e n e s s and t h u s i s b e t t e r c a l l e d a h e u r i s t i c s t r a t e g y . T h i s s t r a t e g y i s i n c o r p o r a t e d i n t o t h e p r e v i o u s m e t a r u l e s by a u g m e n t i n g t h e p r e c o n d i t i o n o f t h e m e t a r u l e w h i c h d e t e r m i n e s t h e a r g u m e n t s t o t h e s u b r o u t i n e f o r a c c o m p l i s h i n g a c o n n e c t i o n . /* T h i s s e t o f r u l e s , c a l l e d ' e q u i v w r a p ' , i s a c o n t r o l s t r a t e g y f o r t h e s e t o f l o g i c r u l e s i n 'wrap'. The s t r a t e g y i s t o c o n n e c t t o t h e c l o s e s t e q u i v a l e n t p i n . E q u i v a l e n t p i n s a r e t h e o n e s w h i c h w i l l be c o n n e c t e d t o g e t h e r . V /* I f r e a s o n i n g a b o u t o b j e c t l e v e l w h i c h h a s no p l a n , t h e n s t a r t a c o n n e c t i o n . */ L E V E L ( 0 ) & DEPTH(0) -> {START_CONNECTION} N E X T _ R U L E ( S E T ( * ) ) . /* I f j u s t t e r m i n a t e d a c o n n e c t i o n , t h e n s t a r t t h e n e x t one. V P L A N ( * ; D E P A R T S ( * ) ) -> {CHAIN} N E X T _ R U L E ( S E T ( * ) ) . /* I f j u s t s t a r t i n g a c o n n e c t i o n , t h e n p i c k a g o a l w h i c h r e q u i r e s t h e c u r r e n t p i n t o be c o n n e c t e d t o a n o t h e r a nd c a l c u l a t e t h e s h i f t e d l o c a t i o n o f t h e c l o s e s t e q u i v a l e n t p i n . */ P L A N ( * P ; S E T ( * ) ) & ! T R U E ( { * P } A B O V E ( * I C 1 : * P I N 1 ) & WRAPPED(*IC1:*PIN1)) & EQUIV P I N ( * I C 1 : * P I N 1 , * I C 3 : * P I N 3 ) & ! T R U E l { * P } W R A P P E D ( * I C 3 : * P I N 3 ) ) & ( ( G O A L ( C O N N E C T ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) & ! E Q U A L ( * J U S T I F I C A T I O N , S O L V I N G _ G O A L ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) ) | ( G O A L ( C O N N E C T ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) & ! E Q U A L ( * J U S T I F I C A T I O N , S O L V I N G _ G O A L ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) ) ) & EQUIV P I N ( * I C 2 : * P I N 2 , * I C 4 : * P I N 4 ) & !TRUET{*P}-WRAPPED(*IC4:*PIN4)) & - ( EQUIV P I N ( * I C 2 : * P I N 2 , * I C 5 : * P I N 5 ) & ! T R U E T { * P } - W R A P P E D ( * I C 5 : * P I N 5 ) ) & ! C L O S E R ( * P , * I C 3 : * P I N 3 , * I C 5 : * P I N 5 , * I C 4 : * P I N 4 ) ) -> {SEQUENCE 1 ( * I C 4 : * P I N 4 , * J U S T I F I C A T I O N ) } NEXT_RULE(SHI F T ( * I C 4 : * P I N 4 , * , * J U S T I F I C A T I O N ) ) . /* A f t e r s h i f t i n g t h e v a r i a b l e t o t h e l o c a t i o n o f t h e p i n , 5 R e s u l t s a nd E v a l u a t i o n 70 i t c a n be a p p r o a c h e d . V PLAN(*;SHI F T ( * I C : * P I N , * , * J U S T I F I C A T I O N ) ) -> ( S E Q U E N C E 2 ( * I C : * P I N , J U S T I F I C A T I O N ) } NEXT_RULE(APPRO(* I C : * P I N , * : * , * J U S T I F I C A T I O N ) ) . /* A f t e r a p p r o a c h i n g a p i n , t h e t o o l c a n be moved t o i t . */ P L A N ( * ; A P P R O ( * I C : * P I N , * : * , * J U S T I F I C A T I O N ) ) -> ( S E Q U E N C E 3 ( * I C : * P I N , * J U S T I F I C A T I O N ) } N E X T _ R U L E ( M O V E S ( * I C : * P I N , * J U S T I F I C A T I O N ) ) . /* A f t e r m o v i n g t o a p i n , w r a p p i n g i t w i l l c a u s e a c o n n e c t i o n b e t w e e n i t and t h e p r e v i o u s p i n . */ P L A N ( * ; M O V E S ( * I C : * P I N , * J U S T I F I C A T I O N ) ) -> { S E Q U E N C E 4 ( * I C : * P I N , J U S T I F I C A T I O N ) } N E X T _ R U L E ( S I G N A L ( 1 , * I C : * P I N , * J U S T I F I C A T I O N ) ) . /* A f t e r w r a p p i n g a p i n t h e t o o l c a n d e p a r t . V P L A N ( * ; S I G N A L ( 1 , * I C : * P I N , * J U S T I F I C A T I O N ) ) -> { S E Q U E N C E 5 ( * I C : * P I N ) } NEXT R U L E ( D E P A R T S ( * I C : * P I N ) ) . N o t i c e t h a t t h e r u l e s may c a u s e t h e w r a p p i n g o f a p i n " e q u i v a l e n t " ( b u t c l o s e r ) t o a n o t h e r s p e c i f i e d i n a g o a l . T h i s g o a l now becomes i m p o r t a n t a s a j u s t i f i c a t i o n ; t h a t i s , a s a r e a s o n f o r c o n n e c t i n g t h a t p a r t i c u l a r p i n n o t n e c e s s a r i l y e v e n m e n t i o n e d i n t h e g o a l . The m e t a f a c t s w h i c h a s s e r t a l l t h e c o n n e c t e d p i n s t o be e q u i v a l e n t must be s p e c i f i e d a s a p r o b l e m s p e c i f i c a t i o n . T h e s e m e t a f a c t s c a n be e a s i l y a s s e r t e d a u t o m a t i c a l l y by t h e p r e p r o c e s s o r . N o t e t h a t t h e a d d i t i o n o f an e x t r a s l o t i n t h e o b j e c t l e v e l a c t i o n s d o e s n o t p r e c l u d e t h e u s e o f t h e r u l e s w i t h o u t t h i s p a r t i c u l a r s t r a t e g y ; t h a t i s , t h e e x t r a s l o t s w o u l d s i m p l y r e m a i n u n i n s t a n t i a t e d i f n o t u s e d ( o r j u s t i f i e d some o t h e r w a y ) . A l s o , t h e t r u t h o f f a c t s i s n o t 5 R e s u l t s a nd E v a l u a t i o n 71 d e p e n d e n t on t h e s e j u s t i f i c a t i o n s . The u s e o f s l o t s t o c o n t r o l t h e p a r s i n g o f n a t u r a l l a n g u a g e i s p r e s e n t e d by [ M c C o r d , 8 2 ] , I f we a g a i n p o s e t h e p r o b l e m c o n s i d e r e d i n t h e p r e v i o u s s e c t i o n s , t h e s o l u t i o n i s now more a p p r o p r i a t e l y a s shown i n f i g u r e 5. *c*.i rc.2. ic:3 F i g u r e 5. I n t e l l i g e n t S o l u t i o n 5.5 R u l e s f o r C o n n e c t i n g Many C h a i n s We h a v e s o f a r c o n s i d e r e d r u l e s w h i c h s i m p l y c h a i n p i n s t o g e t h e r . The r u l e s f o r a c c o m p l i s h i n g many c h a i n s a r e a s t r a i g h t f o r w a r d e x t e n s i o n o f t h e p r e v i o u s . Two more o b j e c t l e v e l r u l e s a r e n e e d e d : 1) a r u l e f o r c u t t i n g t h e w i r e 2) a r u l e f o r w r a p p i n g a p i n w i t h o u t a c c o m p l i s h i n g a c o n n e c t i o n ( i . e . t h e f i r s t p i n i n a new c h a i n ) . The s t r a t e g y f o r d e a l i n g w i t h t h e s e new r u l e s i s a s f o l l o w s . 5 R e s u l t s a n d E v a l u a t i o n 72 1) C u t t h e w i r e i f t h e c u r r e n t c h a i n c a n n o t be c o n t i n u e d ( i . e . i s c o m p l e t e d ) . 2) I f a c h a i n h a s j u s t t e r m i n a t e d , s t a r t t h e n e x t c h a i n a t t h e n e x t c l o s e s t p i n . /* T h i s s e t o f r u l e s , c a l l e d ' m u l t i w r a p * , i s a c o n t r o l s t r a t e g y f o r t h e s e t o f l o g i c r u l e s i n 'wrap'. The s t r a t e g y i s t o c o n n e c t t o t h e c l o s e s t e q u i v a l e n t p i n and c u t t h e w i r e when t h e c h a i n i n g i s c o m p l e t e . The n e x t c h a i n i s s t a r t e d a t t h e c l o s e s t p i n . */ /* I f r e a s o n i n g a b o u t o b j e c t l e v e l w h i c h h a s no p l a n , t h e n s t a r t a c o n n e c t i o n . V L E V E L ( 0 ) & DEPTH(0) -> {START_CONNECTION} N E X T _ R U L E ( S E T ( * ) ) . /* I f j u s t t e r m i n a t e d a c o n n e c t i o n , t h e n s t a r t t h e n e x t o ne. */ P L A N ( * ; D E P A R T S ( * ) ) -> {CHAIN} N E X T _ R U L E ( S E T ( * ) ) . /* A f t e r c o m p l e t i n g a c o n n e c t i o n , s h i f t t o t h e c l o s e s t p i n t h a t n e e d s t o be w r a p p e d . */ P L A N ( * P ; S I G N A L ( 2 , * I C 1 : * P I N 1 ) ) & ( G O A L ( C O N N E C T ( * I C : * P I N , * ) ) | G O A L ( C O N N E C T ( * , * I C : * P I N ) ) ) & -•( (GOAL (CONNECT ( * IC2 : * P I N2 , * ) ) | GOAL (CONNECT (*,* IC2 : * P I N2 )) ) & ! C L O S E R ( * P , * I C 1 : * P I N 1 , * I C 2 : * P I N 2 , * I C : * P I N ) ) & - ! T R U E ( { L E V E L ( 1 ) } P L A N ( * ; S T A R T _ N E X T _ C H A I N ( * ) , 1 ) ) -> ( S T A R T _ N E X T _ C H A I N ( * I C : * P I N ) } N E X T _ R U L E ( S H I F T ( * I C : * P I N , * , MOVING_TO_START_CHAIN(*IC:*PIN))). /* I f j u s t s t a r t i n g a c o n n e c t i o n , t h e n p i c k a g o a l w h i c h r e q u i r e s t h e c u r r e n t p i n t o be c o n n e c t e d t o a n o t h e r and c a l c u l a t e t h e s h i f t e d l o c a t i o n o f t h e c l o s e s t e q u i v a l e n t p i n . */ P L A N ( * P ; S E T ( * ) ) & ! T R U E ( { * P } A B O V E ( * I C 1 : * P I N 1 ) & WRAPPED(*IC1:*PIN1)) & E Q U I V _ P I N ( * I C 1 : * P I N 1 , * ' I C 3 :*PIN3) & !TRUE({*P}WRAPPED(*IC3:*PIN3)) & ( ( G O A L ( C O N N E C T ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) & !EQUAL(*JUSTIFICATION,SOLVING G O A L ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) ) 5 R e s u l t s a n d E v a l u a t i o n 73 | ( G O A L ( C O N N E C T ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) & ! E Q U A L ( * J U S T I F I C A T I O N , S O L V I N G _ G O A L ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) ) ) & EQUIV P I N ( * I C 2 : * P I N 2 , * I C 4 : * P I N 4 ) & ! T R U E l { * P } - - W R A P P E D ( * I C 4 : * P I N 4 ) ) & -•(EQUIV P I N ( * I C 2 : * P I N 2 , * I C 5 : * P I N 5 ) & ! T R U E T { * P J - W R A P P E D ( * I C 5 : * P I N 5 ) ) & ! C L O S E R ( * P , * I C 3 : * P I N 3 , * I C 5 : * P I N 5 , * I C 4 : * P I N 4 ) ) - > { S E Q U E N C E 1 ( * I C 4 : * P I N 4 , J U S T I F I C A T I O N ) } N E X T _ R U L E ( S H I F T ( * I C 4 : * P I N 4 , * , * J U S T I F I C A T I O N ) ) . /* I f r e a d y t o s t a r t a c o n n e c t i o n a n d t h e r e i s no p i n t o c h a i n t o , t h e n c u t t h e w i r e . V P L A N ( * P ; S E T ( * ) ) & ! T R U E ( { * P } A B 0 V E ( * I C 1 : * P I N 1 ) & WRAPPED(*IC1:*PIN1)) & - ( E Q U I V _ P I N ( * I C 1 : * P I N 1 , * I C 3 : * P I N 3 ) & G 0 A L ( C 0 N N E C T ( * I C 3 : * P I N 3 , * ) ) ) - > { E N D _ C H A I N ( * I C 1 : * P I N 1 ) } N E X T _ R U L E ( S I G N A L ( 2 , * I C 1 : * P I N 1 ) ) . /* A f t e r s h i f t i n g t h e v a r i a b l e t o t h e l o c a t i o n o f t h e p i n , i t c a n be a p p r o a c h e d . V P L A N ( * ; S H I F T ( * I C : * P I N , * , * J U S T I F I C A T I O N ) ) -> { S E Q U E N C E 2 ( * I C : * P I N , * J U S T I F I C A T I O N ) } N E X T _ R U L E ( A P P R O ( * I C : * P I N , * : * , * J U S T I F I C A T I O N ) ) . /* A f t e r a p p r o a c h i n g a p i n , t h e t o o l c a n be moved t o i t . V P L A N ( * ; A P P R O ( * I C : * P I N , * : * , * J U S T I F I C A T I O N ) ) -> { S E Q U E N C E 3 ( * I C : * P I N , J U S T I F I C A T I O N ) } N E X T _ R U L E ( M O V E S ( * I C : * P I N , J U S T I F I C A T I O N ) ) . /* A f t e r m o v i n g t o a p i n , w r a p p i n g i t w i l l c a u s e a c o n n e c t i o n b e t w e e n i t a n d t h e p r e v i o u s p i n . V P L A N ( * ; M O V E S ( * I C : * P I N , * J U S T I F I C A T I O N ) ) -> { S E Q U E N C E 4 ( * I C : * P I N , * J U S T I F I C A T I 0 N ) } N E X T _ R U L E ( S I G N A L ( 1 , * I C : * P I N , * J U S T I F I C A T I O N ) ) . /* A f t e r w r a p p i n g a p i n t h e t o o l c a n d e p a r t . */ P L A N ( * ; S I G N A L ( 1 , * I C : * P I N , * J U S T I F I C A T I O N ) ) -> { SEQUENCE5(*IC:*PIN)} T h i s s e t o f r u l e s was u s e d t o s o l v e t h e i n t r o d u c t o r y p r o b l e m i n s e c t i o n 5.1 a n d i t s s k e l e t o n l o g i c a n d c o n t r o l w i l l be u s e d i n t h e n e x t s e c t i o n t o s o l v e a l a r g e r p r a c t i c a l p r o b l e m . N o t i c e i n 5 R e s u l t s a n d E v a l u a t i o n 74 f i g u r e 3 t h a t , g i v e n t h e t o o l had j u s t t e r m i n a t e d w r a p p i n g STARTIC, i t p r o c e e d s t o t h e c l o s e s t p i n t o s t a r t t h e n e x t c h a i n . 5.6 P r a g m a t i c C o n s i d e r a t i o n s f o r S o l v i n g a R e a l P r o b l e m The p l a n n i n g o f a c o n t r o l s t r a t e g y i s r e l a t i v e l y c o s t l y a s c o m p a r e d t o d e c l a r i n g a f i x e d s t r a t e g y a s i n c o n v e n t i o n a l p r o g r a m m i n g l a n g u a g e s . T h u s , t h e p l a n n i n g a n d r e p l a n n i n g o f t h e f i x e d s e q u e n c e o f r u l e s t h a t f o r m t h e w r ap s u b r o u t i n e i s o v e r l y c o s t l y . The n o t i o n o f a wrap macro i s i n t r o d u c e d w h i c h s t a n d s f o r t h e p a r t i c u l a r w r a p s e q u e n c e . The r e s u l t i n g p l a n i s t h u s a s e q u e n c e o f wrap a c t i o n s w h i c h a r e t h e n m a c ro e x p a n d e d by t h e p o s t p r o c e s s o r i n t o t h e VAL i n s t r u c t i o n s . The r u l e s a r e b a s e d on t h e o nes f r o m t h e p r e v i o u s s e c t i o n . The s t r a t e g y f o r c h o o s i n g t h e n e x t p i n i n a c h a i n h a s been m o d i f i e d t o t r a d e o f f a s l i g h t i n c r e a s e i n r o b o t arm t h r a s h i n g f o r c o n s i d e r a b l y f a s t e r p l a n n i n g 1 0 . /* T h i s s e t of r u l e s , c a l l e d ' l a r g e w r a p ' , i s u s e d f o r s o l v i n g l a r g e w i r e - w r a p p i n g p r o b l e m s . */ /* I f a c h a i n c a n n o t be c o n t i n u e d ( i . e . i s c o m p l e t e d ) , t h e n p i c k a p i n on t h e c u r r e n t component i f p o s s i b l e . */ P L A N ( * P ) & ! T R U E ( { * P } A B O V E ( * I C 1 : * P I N 1 ) & W R APPED(*IC1:*PIN1)) & - ( E Q U I V _ P I N ( * I C 1 : * P I N 1 , * I C 3 : * P I N 3 ) & G O A L ( C O N N E C T ( * I C 3 : * P I N 3 , * ) ) ) & 1 0 T h e s t r a t e g y f o r c h o o s i n g t h e c l o s e s t p i n , w h i c h r e q u i r e s c o m p u t i n g t h e d i s t a n c e t o e v e r y o t h e r p i n , c a n be s u b s t i t u t e d s i m p l y by r e p l a c i n g t h e one m e t a r u l e . O t h e r s t r a t e g i e s i n c l u d e t h e c o m b i n a t i o n o f c h o o s i n g t h e c u r r e n t component e l s e t h e c l o s e s t p i n o r a n o t h e r i s c h o o s i n g t h e c l o s e s t c omponent. 5 R e s u l t s and E v a l u a t i o n 75 ( ( ! E Q U A L ( * I C , * I C 1 ) & ( G O A L ( C O N N E C T ( * I C : * P I N , * ) ) | G O A L ( C O N N E C T ( * , * I C : * P I N ) ) ) ) | G O A L ( C O N N E C T ( * I C : * P I N , * ) ) ) & - ! T R U E ( { L E V E L ( 1 ) } P L A N ( * ; S T A R T _ N E X T _ C H A I N ( * , * ) , 1 ) ) -> { S T A R T _ N E X T _ C H A I N ( * I C : * P I N , * I C 1 : * P I N 1 ) } N E X T _ R U L E ( W R A P ( * I C : * P I N , * I C 1 : * P I N 1 , * , M O V I N G _ T O _ S T A R T _ C H A I N ( * I C : * P I N ) ) ) . /* I f j u s t s t a r t i n g a c o n n e c t i o n , t h e n p i c k a g o a l w h i c h r e q u i r e s t h e c u r r e n t p i n t o be c o n n e c t e d t o a n o t h e r a n d c a l c u l a t e t h e s h i f t e d l o c a t i o n o f t h e c l o s e s t e q u i v a l e n t p i n . V P L A N ( * P ) & ! T R U E ( { * P } A B O V E ( * I C 1 : * P I N 1 ) & W R A P P E D ( * I C 1 : * P I N 1 ) ) & EQUIV P I N ( * I C 1 : * P I N 1 , * I C 3 : * P I N 3 ) & ! T R U E l { * P } W R A P P E D ( * I C 3 : * P I N 3 ) ) & ( ' ( G O A L ( C O N N E C T ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) & ! E Q U A L ( * J U S T I F I C A T I O N , S O L V I N G _ G O A L ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) ) | ( G O A L ( C O N N E C T ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) & ! E Q U A L ( * J U S T I F I C A T I O N , S O L V I N G _ G O A L ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) ) ) & E Q U I V P I N ( * I C 2 : * P I N 2 , * I C 4 : * P I N 4 ) & ! T R U E " C { * P } - W R A P P E D ( * I C 4 : * P I N 4 ) ) & - ( E Q U I V P I N ( * I C 2 : * P I N 2 , * I C 5 : * P I N 5 ) & ! T R U E T { * P } - W R A P P E D ( * I C 5 : * P I N 5 ) ) & ! C L O S E R ( * P , * I C 3 : * P I N 3 , * I C 5 : * P I N 5 , * I C 4 : * P I N 4 ) ) - > { M A K E _ C O N N E C T I O N ( * I C 4 : * P I N 4 , * I C 1 : * P I N 1 , * J U S T I F I C A T I O N ) } N E X T _ R U L E ( W R A P ( * I C 4 : * P I N 4 , * I C 1 : * P I N 1 , * , * J U S T I F I C A T I O N ) ) . /* O r d e r t h a t t h e r u l e s s h o u l d be n o n d e t e r m i n i s t i c a l l y c h o s e n . V -> {METAFACTS}CHOOSE(START_NEXT_CHAIN(*,*)). -> {METAFACTS}CHOOSE(MAKE_CONNECTION(*,*,*)). /* M a c r o r u l e t o w r a p t h e b e g i n n i n g p i n i n a c h a i n . V LOCATION(*IC,*ICLOC) & NO_PI N S ( * I C , * N ) & !BETWEEN(*PIN,1,*N) & -WRAPPED(*IC:*PIN) & !REFERENCE_PIN_SHIFT(*PIN,*N,*DISP) & !RELOCATE(*ICLOC,*DISP,*PINLOC) & ABOVE(*OLDIC:*OLDPIN) -> {WRAP(*IC:*PIN,*OLDIC:*OLDPIN,*PINLOC, S O L V I N G _ G O A L ( * I C 1 : * P I N 1 , * I C 2 : * P I N 2 ) ) } -ABOVE(*OLDIC:*OLDPIN) & A B O V E ( * I C : * P I N ) & WRAPPED(*IC:*PIN) & 5 R e s u l t s a n d E v a l u a t i o n 76 C O N N E C T ( * I C 1 : * P I N 1 , * I C 2 : * P I N 2 ) . /* M a c r o r u l e t o wrap a p i n i n t h e c u r r e n t c h a i n . V LOCATION(*IC,*ICLOC) & NO_PINS(*IC,*N) & !BETWEEN(*PIN,1,*N) & -WRAPPED(*IC:*PIN) & !REFERENCE_PIN_SHIFT(*PIN,*N,*DISP) & !RELOCATE(*ICLOC,*DISP,*PINLOC) & ABOVE(*OLDIC:*OLDPIN) -> {WRAP(*IC:*PIN,*OLDIC:*OLDPIN,*PINLOC, MOVING_TO_START_CHAIN(*))} -ABOVE(*OLDIC:*OLDPIN) & A B O V E ( * I C : * P I N ) & W R A P P E D ( * I C : * P I N ) . The s m a l l b u t r e a l i s t i c c i r c u i t c h o s e n a s a p r o b l e m i s an e x t e n d e d r a n g e p o s i t i o n s e n s o r t h a t w o r k s i n h i g h a m b i e n t n o i s e a r e a s [ P e t e r s o n , 7 8 ] . The p r o b l e m s p e c i f i c a t i o n o b t a i n e d f r o m t h e g i v e n s c h e m a t i c d i a g r a m i s i n c l u d e d i n a p p e n d i x B. I n summary, t h e p r o b l e m c o n s i s t s o f t h r e e c o m p o n e n t s , one o f s i x t e e n p i n s a n d two o f f o u r t e e n , w h i c h a r e l a i d o u t one a b o v e a n o t h e r on a b o a r d m e a s u r i n g 50mm x 100mm. T h e r e a r e n i n e t e e n c o n n e c t i o n s t o be made i n c l u d i n g t h r e e c h a i n s o f t h r e e p i n s . A l l t h e c o n n e c t i o n s a r e s p e c i f i e d a t random a nd t h e y a r e n o t shown on t h e d i a g r a m . The s o l u t i o n o f f e r e d i s shown i n f i g u r e 6. 5 R e s u l t s a n d E v a l u a t i o n 77 F i g u r e 6 . R e a l i s t i c P r o b l e m S o l u t i o n 5 R e s u l t s a n d E v a l u a t i o n 78 CHAPTER 6 Conclusion This thes is has proposed a par t i cu la r language for representing and using metaknowledge in PSs. In e f f e c t , RCPS can reason about i t s own reasoning. This chapter ph i losoph i ca l l y j u s t i f i e s these means. 6.1 Recapi tu lat ion of the Results The main claims of the previous chapter and of th i s thesis are the fo l lowing. 1) Metaknowledge increases the penetrance towards the goal even when consider ing the e f fo r t required to do the metareasoning. 2) Metaknowledge increases the in te l l igence of the deduction by requir ing e f fec t i ve j u s t i f i c a t i o n s for the inference steps. These resu l ts are i n t u i t i v e l y sa t i s f y ing since we are providing a f a c i l i t y for speci fy ing and using more knowledge; however, they are very strong claims that need further and more general j u s t i f i c a t i o n s . The f i r s t c laim is made under the assumption that the cont ro l problem is less complex than the object problem. Indeed, i t is assumed that the complexity decreases monotonical ly. This is the case for some c lass of problems. 6 Conclusion 79 The recursive technique advocated provides a paradigm for th i s c l ass of problems. In the authors op in ion , the second c la im does not depend on the f i r s t . Someone who solves a problem by brute force cannot be considered more i n t e l l i g en t than someone who solves the same problem with va l i d j u s t i f i c a t i o n s for the inference even though the l a t t e r required more e f f o r t . The resu l ts perta in ing to the RCPS implementation and the descr ip t i ve adequacy of the RCPS language is considered next; in pa r t i cu l a r , we are not concerned, at th is po int , with the domain which has been chosen to e luc idate these r e su l t s . The RCPS implementation is a robust, general purpose planner. Not only is the spec i f i c a t i on of the logic rules addi t ive and modular, but the contro l and the amount of contro l is a l so . The e f fec t of such modularity is f l e x i b i l i t y and ease of modi f i ca t ion . Thus, RCPS is very useful for experimenting with various log ic and contro l components. The RCPS implementation has also proven i t s e l f e f f i c i e n t in space and time even though the host PROLOG used is i n te rp re t i ve . The RCPS run-time system provides the usual f a c i l i t i e s offered by standard programming languages. Rating the power of expression in RCPS is subject ive ; however, some c r i t e r i a are given. One can judge e x p r e s s i b i l i t y in terms of : 1) the conciseness of the code 2) the readab i l i t y of the code 6 Conclusion 80 3) t h e i n h e r e n t p r i n c i p l e b e h i n d t h e l a n g u a g e . T y p i c a l l y , l a n g u a g e s t r a d e o f f c o n c i s e n e s s f o r r e a d a b i l i t y a nd v i c e v e r s a . F o r e x a m p l e , i n t h e o p i n i o n o f t h e a u t h o r , a l a n g u a g e l i k e APL i s c o n c i s e b u t i s n o t e a s i l y r e a d a b l e . COBOL, on t h e o t h e r h a n d , i s r e a d a b l e b u t f a r f r o m c o n c i s e . We c l a i m t h a t RCPS i s b o t h c o n c i s e and r e a d a b l e . The w i r e - w r a p p i n g s t r a t e g y , f o r e x a m p l e , h a s o n l y one l e v e l o f c o n t r o l a nd o n l y one l e v e l o f i n f e r e n c e ; t h a t i s , no m e t a p l a n i s l o n g e r t h a n one a c t i o n ( e x c l u d i n g t h e g i v e n ) . The i n t r o d u c t o r y c o n t e n t - r e f e r e n c e e x a m p l e i n s e c t i o n 4 . 6 , h o w e v e r , shows t h a t t h i s i s n o t a l i m i t a t i o n o f RCPS. The r u l e s a r e r e a d a b l e s i n c e t h e y h a v e been e a s i l y p a r a p h r a s e d i n p r o s e . A l t h o u g h t h e p r i n c i p a l b e h i n d t h e l a n g u a g e h a s w e l l - f o u n d e d s u p p o r t and i s i n t u i t i v e , t h e a u t h o r h a s f o u n d , a t l e a s t a t t h e b e g i n n i n g , t h a t i t i s d i f f i c u l t t o t h i n k i n s e p a r a t e l o g i c a nd c o n t r o l c o m p o n e n t s . The s e q u e n c i n g o f s t a t e m e n t s i n most l a n g u a g e s i s s i m p l y done by i m p l i c i t l y o r d e r i n g t h e s t a t e m e n t s i n t h e s e q u e n c e d e s i r e d . I n RCPS, a s e p a r a t e s e q u e n c e s t a t e m e n t i s r e q u i r e d . T h i s c h a r a c t e r i s t i c c a n be r e g a r d e d a s a f a u l t w i t h r e s p e c t t o t h e c o n c i s e n e s s o f t h e l a n g u a g e [ D a v i s , 8 0 a ] . 6.2 R e l a t e d I s s u e s a n d D i r e c t i o n f o r F u r t h e r R e s e a r c h M e t a r e a s o n i n g h a s been a n d s t i l l i s an a c t i v e r e s e a r c h a r e a i n A l ; h o w e v e r , s l o w p r o g r e s s i s b e i n g made i n t h e a r e a . The p r i m a r y s t u m b l i n g b l o c k i s t h e l a c k o f a t h e o r y a b o u t t h e 6 C o n c l u s i o n 8 1 p r o c e s s of r e a s o n i n g . I n d e e d , a m e t a l a n g u a g e i s n e e d e d t o t a l k a b o u t t h e l a n g u a g e o f r e a s o n i n g b e f o r e t h e o r e t i c a r g u m e n t s c a n be p o s e d a n d s o l v e d . The p l a n s p r e s e n t e d i n t h i s p a p e r h a v e n o t been e x e c u t e d on t h e PUMA r o b o t arm. S i n c e t h e arm, a s p r e s e n t e d , d o e s n o t have s e n s i n g a n d s e r v o c a p a b i l i t i e s , i m p r e c i s i o n i n t h e arm a n d / o r t h e l o c a t i o n o f t h e p i n t o be w r a p p e d may c a u s e p o s i t i o n i n g e r r o r s . A t r u l y a d a p t i v e s y s t e m w o u l d i n c l u d e s e n s o r s , p e r h a p s a s s i m p l e a s t o u c h s e n s o r s , and a c o n d i t i o n a l p l a n n i n g s y s t e m . S u c h a p l a n n e r w o u l d g e n e r a t e p r o g r a m s w i t h c o n d i t i o n a l s s u c h t h a t t h e r o b o t c o u l d a d a p t i t s e l f t o t h e e n v i r o n m e n t b e i n g s e n s e d . 6 C o n c l u s i o n 82 BIBLIOGRAPHY Abe, R., S. Ueno, S. T s u j i k a d o , a n d H. T a k a g i , "The P r o g r a m m i n g L a n g u a g e f o r W e l d i n g R o b o t s " , Symposium on I n d u s t r i a l R o b o t s , J a p a n I n d u s t r i a l R o b o t A s s o c i a t i o n , 1981. B i s o n , P., G. L o r e n z i n , a n d E. P a g e l l o , "The F o r m a l D e f i n i t i o n of VML a n d a P r o p o s e d P o r t a b l e I m p l e m e n t a t i o n " , Symposium on I n d u s t r i a l R o b o t s , J a p a n I n d u s t r i a l R o b o t A s s o c i a t i o n , 1981. B y r d , L., " U n d e r s t a n d i n g t h e C o n t r o l F l o w o f PROLOG P r o g r a m s " , D e p a r t m e n t o f A r t i f i c i a l I n t e l l i g e n c e , U n i v e r s i t y o f E d i n b u r g h , S c o t l a n d , 1980. C l a r k , K. S., " N e g a t i o n a s F a i l u r e " , L o g i c a n d D a t a b a s e s , G a l a i r e a n d M i n k e r ( e d s . ) , P l e n u m , New Y o r k , 1978. C l o c k s i n , W. F. and C. S. M e l l i s h , P r o g r a m m i n g i n PROLOG, S p r i n g e r - V e r l a g B e r l i n H e i d e l b e r g , New YorV, 1981 C58-78). C o l m e r a u e r , A., " L e s S y s t e m e s - q ou un F o r m a l i s m e p o u r A n a l y s e r e t S y n t h e t i s e r d e s P h r a s e s s u r O r d i n a t e u r s " , I n t e r n a l p u b l i c a t i o n number 4 3 , D e p a r t e m e n t d ' I n f o r m a t i q u e , U n i v e r s i t e de M o n t r e a l , S e p t e m b e r , 1970. Condec U n i m a t i o n R o b o t i c s , "Puma R o b o t M a n u a l 398H", U n i m a t i o n I n c o r p o r a t e d , S h e l t e r Rock L a n e , D a n b u r y CT. 06810. C u t l a n d , N. J . , C o m p u t a b i 1 i t y : An I n t r o d u c t i o n t o R e c u r s i v e  F u n c t i o n T h e o r y . C a m b r i d g e U n i v e r s i t y P r e s s , 1980 "(C h a p t e r 3) . D a v i s , R. and J . K i n g , "An O v e r v i e w o f P r o d u c t i o n S y s t e m s " M a c h i n e I n t e l l i g e n c e , E l c o c k , E. W. a n d M i c h i e , D. ( e d . ) , W i l e y , New Y o r k , 1976 ( 3 0 0 - 3 3 2 ) . D a v i s , R., and B. G. B u c h a n a n , "Meta L e v e l K n o w l e d g e : O v e r v i e w and A p p l i c a t i o n s " , P r o c e e d i n g s o f t h e 5 t h I J C A I - 7 7 , C a m b r i d g e , MA, 1977 ( 9 2 0 - 9 2 7 ) . D a v i s , R. , " I n t e r a c t i v e T r a n s f e r o f E x p e r t i s e : A c q u i s i t i o n o f New I n f e r e n c e R u l e s " , A r t i f i c i a l I n t e l l i g e n c e , 1 2 ( 2 ) , N o r t h H o l l a n d P u b l i s h i n g Company, 1979 ( 1 2 1 - 1 5 7 ) . D a v i s , R. , "Meta R u l e s : R e a s o n i n g a b o u t C o n t r o l " , A l memo #576, M a r c h 1980a. D a v i s , R., " C o n t e n t R e f e r e n c e : R e a s o n i n g a b o u t R u l e s " , A r t i f i c i a l I n t e l l i g e n c e , 1 5 ( 3 ) , N o r t h H o l l a n d P u b l i s h i n g Company, 1980b. B i b l i o g r a p h y 83 De K l e e r , J . , J . D o y l e , G. L. S t e e l e J r . , and G. J . Sussman, "AMORD: E x p l i c i t C o n t r o l o f R e a s o n i n g " , SIGPLAN/SIGART 1 2 ( 8 ) , A u g u s t 1977 ( 1 1 6 - 1 2 5 ) . D e s c o t t e , Y. and J . - C . L a t o m b e , "GARI: A P r o b l e m S o l v e r t h a t P l a n s how t o M a c h i n e M e c h a n i c a l P a r t s " , P r o c e e d i n g s o f t h e 7 t h I J C A I - 8 1 , V a n c o u v e r , B.C., 1981 ( 7 6 6 - 7 7 2 ) . D o y l e J . , "A T r u t h M a i n t e n a n c e S y s t e m " , A r t i f i c i a l I n t e l l i g e n c e , 1 2 ( 3 ) , N o r t h H o l l a n d P u b l i s h i n g Company, 1979 ( 2 3 1 - 2 7 2 ) . Erman, L., F. H a y e s - R o t h , V. L e s s e r , a n d D. Reddy, "The H e a r s a y I I S p e e c h U n d e r s t n a d i n g S y s t e m : I n t e g r a t i n g K n o w l e d g e t o R e s o l v e U n c e r t a i n t y " , C o m p u t i n g S u r v e y s , ACM 1 2 ( 2 ) , 1980. E r n s t , G. W. and A. N e w e l l , GPS: A C a s e S t u d y i n G e n e r a l i t y  a nd P r o b l e m S o l v i n g , A c a d e m i c P r e s s I n c o r p o r a t e d , 1969. F i k e s , R. E. a n d N. J . N i l s s o n , " S T R I P S: A New A p p r o a c h t o t h e A p p l i c a t i o n o f Theorem P r o v i n g t o P r o b l e m S o l v i n g " , A r t i f i c i a l I n t e l l i g e n c e , 2, N o r t h H o l l a n d P u b l i s h i n g Company, 1 971 . F i k e s , R. E., P. E. H a r t , a n d N. J . N i l s s o n , "Some New D i r e c t i o n s i n Robot P r o b l e m S o l v i n g " M a c h i n e I n t e l l i g e n c e 1_, M e l t z e r a n d M i c h i e ( e d . ) , J o h n W i l e y a n d S o n s , 1972 ( 4 0 5 - 4 3 0 ) . F r e i t a s J r . , R. A., T. J . H e a l y , a n d J . E. L o n g , " A d v a n c e d A u t o m a t o n f o r Space M i s s i o n " , P r o c e e d i n g s o f t h e 7 t h I J C A I - 8 1 , V a n c o u v e r , B.C., 1981 ( 8 0 3 - 8 0 7 ) . F u t a m i , S., N. K i j u r a , a n d I . M a t s u m o t o , "A C o n t r o l A l g o r i t h m f o r T r a c i n g a n d V i s u a l S e r v o i n g by I n d u s t r i a l R o b o t s " , Symposium on I n d u s t r i a l R o b o t s , J a p a n I n d u s t r i a l R o b o t A s s o c i a t i o n , 1981. G a l e r , B. A. and A. J . P e r l i s , A V i e w o f P r o g r a m m i n g  L a n g u a g e s , A d d i s o n - W e s l e y P u b l i s h i n g Company, 1970. G e o r g e f f , M. P., "A Framework f o r C o n t r o l i n P r o d u c t i o n S y s t e m s " , P r o c e e d i n g s o f t h e 6 t h I J C A I - 7 9 , T o k y o , J a p a n , 1979 ( 3 2 8 - 3 3 4 ) . G e o r g e f f , M. P., " P r o c e d u r a l C o n t r o l i n P r o d u c t i o n S y s t e m s " , A r t i f i c i a l I n t e l l i g e n c e , 1 8 ( 2 ) , N o r t h H o l l a n d P u b l i s h i n g Company, M a r c h 1982 ( 1 7 5 - 2 0 1 ) . H a y e s , P., "The Frame P r o b l e m a n d R e l a t e d P r o b l e m s i n A l " , A r t i f i c i a l and Human T h i n k i n g , E l i t h a n A., and J o n e s D., ( e d . ) J o s s e y - B a s s 1973. H a y e s , P., " I n D e f e n s e o f L o g i c " , P r o c e e d i n g s o f t h e 5 t h B i b l i o g r a p h y 84 I J C A I - 7 7 , C a m b r i d g e , MA, 1977 ( 5 5 9 - 5 6 5 ) . H a y e s , P., "The L o g i c o f F r a m e s " , Frame C o n c e p t i o n s a n d T e x t  U n d e r s t a n d i n g , M e l z i n g D., ( e d . ) , de G r u y t e r , 1979. H e w i t t , C , " D e s c r i p t i o n a nd T h e o r e t i c a l A n a l y s i s ( U s i n g S c h e m a t a ) o f P l a n n e r : A L a n g u a g e f o r P r o v i n g Theorems a n d M a n i p u l a t i n g M o d e l s i n a R o b o t " , M a s s a c h u s e t t s I n s t i t u t e o f T e c h n o l o g y , C a m b r i d g e M a s s a c h u s e t t s , A p r i l 1972. K o w a l s k i , R., " A l g o r i t h m = L o g i c + C o n t r o l " , C o m m u n i c a t i o n s o f t h e ACM, 2 2 ( 7 ) , 1979a ( 4 2 4 - 4 3 6 ) . K o w a l s k i , R., L o g i c f o r P r o b l e m S o l v i n g , E l s e v i e r N o r t h H o l l a n d I n c . , 1979b. M a c k w o r t h , A., " R e c o v e r i n g t h e M e a n i n g o f D i a g r a m s and S k e t c h e s " , G r a p h i c s I n t e r f a c e '83, E d m o n t o n , A l b e r t a , May 1983. Manna, Z. a n d R. W a l d i n g e r , "A D e d u c t i v e A p p r o a c h t o P r o g r a m S y n t h e s i s " , ACM T r a n s a c t i o n s on P r o g r a m m i n g L a n g u a g e s and S y s t e m s , 2 ( 1 ) , 1980. M a s a k i , I . , R. Gorman, a n d B. S h u l m a n , " A r c W e l d i n g R o b o t w i t h V i s i o n " Symposium on I n d u s t r i a l R o b o t s , J a p a n I n d u s t r i a l R o bot A s s o c i a t i o n , 1981. M c C o r d , M., " U s i n g S l o t s a nd M o d i f i e r s i n L o g i c Grammar f o r N a t u r a l L a n g u a g e " , A r t i f i c i a l I n t e l l i g e n c e , 1 8 ( 3 ) , N o r t h H o l l a n d P u b l i s h i n g Company, May 1982 ( 3 2 7 - 3 6 7 ) . M c D e r m o t t , J . , and C. F o r g y , " P r o d u c t i o n S y s t e m C o n f l i c t R e s o l u t i o n S t r a t e g i e s " , P a t t e r n P i r e c t e d I n f e r e n c e S y s t e m s , Watermann a n d H a y e s - R o t h ( e d . ) , A c a d e m i c P r e s s , L o n d o n , 1978 ( 1 7 7 - 1 9 9 ) . M i n s k y , M. , Computat i o n : F i n i t e a n d I n f i n i t e M a c h i n e s , E n g l e w o o d C l i f f s , N. J . , P r e n t i c e H a l l , 1967 ( C h a p t e r 1 2 ) . M o o r e , R. C. , " R e a s o n i n g a b o u t K n o w l e d g e a n d A c t i o n " , P r o c e e d i n g s o f t h e 5 t h I J C A I - 7 7 , C a m b r i d g e , MA, 1977 ( 2 2 3 - 2 2 7 ) . N i l s s o n , N. J . , P r i n c i p l e s o f A r t i f i c i a l I n t e l l i g e n c e , T i o g a , P a l o A l t o , 1980 ( 2 1 , 9 1 - 9 4 ) . 0 Duda, R., and J . G. G a s c h n i g , " K n o w l e d g e - B a s e d E x p e r t S y s t e m s come o f Age", BYTE, 6 ( 9 ) , Mc Graw H i l l , 1981. P e t e r s o n , D., " C i r c u i t I d e a s " , F a i r c h i l d J o u r n a l o f S e m i c o n d u c t o r P r o g r e s s , 6 ( 4 ) , 1 9 7 8 ( 1 2 ) . B i b l i o g r a p h y 85 R e i t e r , R., "On C l o s e d W o r l d D a t a B a s e s " , L o g i c a n d D a t a B a s e s , G a l a i r e and M i n k e r ( e d . ) , P l e n u m P r e s s , 1978. R o u s s e l , P h . , "PROLOG, M a n u e l d ' U t i 1 i s a t i o n " , I n t e r n a l R e p o r t , G r o u p e d ' I n t e l l i g e n c e A r t i f i c i e l l e , UER de L u m i n y , U n i v e r s i t e d ' A i x - M a r s e i l l e , S e p t e m b e r 1975. R o s e n s c h e i n , S. J . , " P l a n S y n t h e s i s : A L o g i c a l P e r s p e c t i v e " , P r o c e e d i n g s o f t h e 7 t h I J C A I - 8 1 , V a n c o u v e r , B.C., 1981 ( 3 3 1 - 3 3 7 ) . R y c h e n e r , M. D., " C o n t r o l R e q u i r e m e n t s f o r t h e D e s i g n o f P r o d u c t i o n S y s t e m A r c h i t e c t u r e s " , SIGPLAN/SIGART N e w s l e t t e r , 1977 ( 3 7 - 4 4 ) . S a c e r d o t i , E. D., A S t r u c t u r e f o r P l a n s a n d B e h a v i o u r , E l s e v i e r , New Y o r k , 1977. S a l o m a a , A., F o r m a l L a n g u a g e s , A c a d e m i c P r e s s , New Y o r k , 1977. S h o r t l i f f e , E. H., A. C. S c o t t , M. B. B i s h o p , A. B. C a m p b e l l , W. Van M e l l e , a n d D. J a c o b s , "ONCOCIN: An e x p e r t S y s t e m f o r O n c o l o g y P r o t o c o l Management", P r o c e e d i n g s o f t h e 7 t h I J C A I - 8 1 , V a n c o u v e r , B.C., 1981 ( 8 7 6 - 8 8 1 ) . S t e f i k , M., " P l a n n i n g w i t h C o n s t r a i n t s " , S t a n f o r d T e c h n i c a l R e p o r t STAN-CS-80-784, J a n u a r y 1980. S t e f i k , M., " P l a n n i n g a n d M e t a - P l a n n i n g " , A r t i f i c i a l I n t e l l i g e n c e , 1 6 ( 2 ) , N o r t h H o l l a n d P u b l i s h i n g Company, 1981. S t e f i k , M., R. B a l z e r , J . B e n o i t , L. B i r n h a u m , F. H a y e s - R o t h , a n d E S a c e r d o t i , "The O r g a n i z a t i o n o f E x p e r t S y s t e m s , A T u t o r i a l " , A r t i f i c i a l I n t e l l i g e n c e , 1 8 ( 2 ) , N o r t h H o l l a n d P u b l i s h i n g Company, M a r c h 1982, ( 1 3 5 - 1 7 3 ) . T r e m b l a y , J . P. And P. G. S o r e n s o n , An I n t r o d u c t i o n t o D a t a  S t r u c t u r e s w i t h A p p l i c a t i o n s , McGraw H i l l , 1976 (60) . T a t e , A., " I n t e r a c t i n g G o a l s and T h e r e U s e " , P r o c e e d i n g s o f t h e 5 t h I J C A I - 7 5 , T b i l i s i , G e o r g i a , U.S.S.R., 1975. W a l d i n g e r , R., " A c h i e v i n g S e v e r a l G o a l s S i m u l t a n e o u s l y " , M a c h i n e  I n t e l l i g e n c e 8, E l c o c k a n d M i c h i e ( e d . ) , E l l i s H orwood, 1977 ( 9 4 - 1 3 6 ) . W a r r e n , D. H. D., "WARPLAN: A S y s t e m f o r G e n e r a t i n g P l a n s " , memo no. 76, D e p t . Of Comp. L o g i c , U n i v e r s i t y o f E d i n b u r g h , J u n e 1974. W a r r e n , D. H. D., "WARPLAN", U n i v e r s i t y o f B r i t i s h C o l u m b i a B i b l i o g r a p h y 86 i m p l e m e n t a t i o n . Waterman, D. A., and F., H a y e s - R o t h , ( e d . ) P a t t e r n D i r e c t e d  I n f e r e n c e S y s t e m s , A c a d e m i c P r e s s , L o n d o n , 1978. Week, M., W. E v e r s h e i m , a n d D. Z u e h l k e , "Robex - An O f f - l i n e P r o g r a m m i n g S y s t e m f o r I n d u s t r i a l R o b o t s " , Symposium on I n d u s t r i a l R o b o t s , J a p a n I n d u s t r i a l R o b o t A s s o c i a t i o n , 1981. W i l e n s k y , R., " M e t a - P l a n n i n g : R e p r e s e n t i n g a n d U s i n g K n o w l e d g e A b o u t P l a n n i n g i n P r o b l e m S o l v i n g and N a t u r a l L a n g u a g e U n d e r s t a n d i n g " , C o g n i t i v e S c i e n c e , 5 ( 3 ) , A b l e x P u b l i s h i n g C o r p o r a t i o n , J u l y - S e p t e m b e r , 1981, ( 1 9 7 - 2 3 4 ) . Z i s m a n , M. D., "Use o f P r o d u c t i o n S y s t e m s f o r M o d e l l i n g A s y n c h r o n o u s C o n c u r r e n t P r o c e s s e s " , P a t t e r n D i r e c t e d I n f e r e n c e  S y s t e m s , Waterman a n d H a y e s - R o t h ( e d . ) , A c a d e m i c P r e s s , L o n d o n , 1978 ( 5 3 - 6 8 ) . B i b l i o g r a p h y 87 APPENDIX A T r a c e o f t h e C o n t e n t R e f e r e n c e E x a m p l e PROLOG/MTS 0 . 0 END OF F I L E READ FROM c o n t e n t G i v e n F a c t s t r u e G o a l t o be S o l v e d c M e t a P l a n CHOOSE(STRATEGY(* 1) ) S u g g e s t s E x p a n s i o n L E V E L ( 3 ) ; STRATEGY(* 1 ) P r e c o n d i t i o n o f STRATEGY(STRATEGY(*1)) h o l d s L E V E L ( 2 ) & !LE ( 2 , 2 ) & GOAL(NEXT_RULE(* 1 )) & ! ( ( { ( S T R A T E G Y ( * 1)}NEXT_RULE(* 1 ) ) ) ?) P l a n E x p a n d e d M e t a P l a n L E V E L ( 3 ) ; STRATEGY(STRATEGY(* 1) ) S u g g e s t s E x p a n s i o n L E V E L ( 2 ) ; STRATEGY(* 1) P r e c o n d i t i o n o f STRATEGY(STRATEGY(*1)) h o l d s L E V E L ( 1 ) & ! L E ( 1 , 2 ) & GOAL(NEXT_RULE(* 1)) & ! ( ( { ( S T R A T E G Y ( * 1 ) } N E X T _ R U L E ( * 1 ) ) ) ?) A T r a c e o f t h e C o n t e n t R e f e r e n c e E x a m p l e 88 P l a n E x p a n d e d M e t a P l a n L E V E L ( 2 ) ; STRATEGY(STRATEGY(* 1 ) ) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; STRATEGY(* 1) P r e c o n d i t i o n o f STRATEGY(C) h o l d s L E V E L ( 0 ) & ! L E ( 0 , 2 ) & GOAL(c) & ! ( ( { ( C } c ) ) ?) P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; STRATEGY(C) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; C P r e c o n d i t i o n o f C h o l d s t r u e P l a n E x p a n d e d S o l u t i o n t o P r o b l e m t r u e -> { L E V E L ( 0 ) ; C } c . E X I T PROLOG/MTS 0.0 A T r a c e o f t h e C o n t e n t R e f e r e n c e E x a m p l e 89 APPENDIX B C i r c u i t Design The schematic diagram of the p r o x i m i t y sensor, designed by [ P e t e r s o n , 78], i s shown below along w i t h the component placement on the DIPs and the RCPS problem statement. The c i r c u i t l a y o u t i s d e p i c t e d i n f i g u r e 6 which i s drawn two times a c t u a l s i z e . v/ c c — NO o e r e c T V 0& = O BJECT DETECTED RI - IO K C|= o.OI^F f *5 k H * B C i r c u i t Design DIP I DJPZ 90 6p. yyyNjBk-o ' ° 3o I ^ L Q I Z * 0 1 o -vW 2^ *4 4-C5 SYMB0LIC_0RIGIN(or1g1n) & L0CATI0N(STARTIC,O:O) & NO_PINS(STARTIC,0) & WRAPPED(STARTIC:0) & ABOVE(STARTIC:0) & L0CATI0N(SIGNAL,250:980) & L0CATI0N(GND1,325:940) & L0CATI0N(UA758,150:820) & L0CATI0N(VCC1.175:700) & LOCATI0N(GND2,325:62O) & L0CATI0N(DIP1,150:500) & L0CATI0N(VCC2,175:380) & L0CATI0N(GND3,325:3OO) & L0CATI0N(DIP2,150:180) & L0CATI0N(VCC3,175:60) & N0_PINS(DIP1,14) & N0_PINS(DIP2,14) & N0_PINS(UA758,16) & N0_PINS(VCC1,0) & N0_PINS(VCC2.0) & N0_PINS(VCC3,0) & N0_PINS(GND1,0) & N0_PINS(GND2,0) & N0_PINS(GND3,O) & NO_PINS(SIGNAL,0) -> {*> C0NNECT(DIP1:1,UA758:1) & C0NNECT(DIP1:2,UA758:12) & C0NNECT(DIP1:3,UA758:10) & C0NNECT(DIP1:4,UA758:14) & C0NNECT(DIP1:5,UA758:7) & C0NNECT(DIP1:7,GND2:0) & C0NNECT(DIP1:8,UA758:15) & C0NNECT(DIP1:10,VCC2:0) & C0NNECT(DIP1:11,UA758:13) & C0NNECT(DIP1:12,UA758:9) & C0NNECT(DIP1:13,UA758:2) & C0NNECT(DIP1:14,GND2:0) & C0NNECT(UA758:8,GND1:0) & CONNECT(UA758:16,VCC1:0) & C0NNECT(UA758:11,DIP2:4) & C0NNECT(DIP2:1.UA758:1) & C0NNECT(DIP2:7,GND3:O) & C0NNECT(0IP2:14,VCC3:0) & C0NNECT(SIGNAL:0,UA758:7). B C i r c u i t D e s i g n 91 APPENDIX C C o m p l e t e S e t o f M u l t i w r a p R u l e s /* T h i s s e t o f r u l e s , c a l l e d ' m u l t i w r a p ' , i s a c o n t r o l s t r a t e g y f o r t h e s e t o f l o g i c r u l e s i n 'wrap'. The s t r a t e g y i s t o c o n n e c t t o t h e c l o s e s t e q u i v a l e n t p i n a n d c u t t h e w i r e when t h e c h a i n i n g i s c o m p l e t e . The n e x t c h a i n i s s t a r t e d a t t h e c l o s e s t p i n . */ /* I f r e a s o n i n g a b o u t o b j e c t l e v e l w h i c h h a s no p l a n , t h e n s t a r t a c o n n e c t i o n . V L E V E L ( 0 ) & DEPTH(0) -> {START_CONNECTION} N E X T _ R U L E ( S E T ( * ) ) . /* I f j u s t t e r m i n a t e d a c o n n e c t i o n , t h e n s t a r t t h e n e x t one. */ P L A N ( * ; D E P A R T S ( * ) ) -> {CHAIN} N E X T _ R U L E ( S E T ( * ) ) . /* A f t e r c o m p l e t i n g a c o n n e c t i o n , s h i f t t o t h e c l o s e s t p i n t h a t needs t o be w r a p p e d . V P L A N ( * P ; S I G N A L ( 2 , * I C 1 : * P I N 1 ) ) & ( G O A L ( C O N N E C T ( * I C : * P I N , * ) ) | G O A L ( C O N N E C T ( * , * I C : * P I N ) ) ) & - ( ( G 0 A L ( C 0 N N E C T ( * I C 2 : * P I N 2 , * ) ) | G O A L ( C O N N E C T ( * , * I C 2 : * P I N 2 ) ) ) & ! C L O S E R ( * P , * I C 1 : * P I N 1 , * I C 2 : * P I N 2 , * I C : * P I N ) ) & -•! TRUE ( {LEVEL ( 1 ) } PLAN ( * ; START_NEXT_CHAI N ( * ) , 1 ) ) -> {START_NEXT_CHAIN(*IC:*PIN)} NEXT_RULE(SHI F T ( * I C : * P I N , * , M O V I N G _ T O _ S T A R T _ C H A I N ( * I C : * P I N ) ) ) . /* . I f j u s t s t a r t i n g a c o n n e c t i o n , t h e n p i c k a g o a l w h i c h r e q u i r e s t h e c u r r e n t p i n t o be c o n n e c t e d t o a n o t h e r a nd c a l c u l a t e t h e s h i f t e d l o c a t i o n o f t h e c l o s e s t e q u i v a l e n t p i n . */ P L A N ( * P ; S E T ( * ) ) & ! T R U E ( { * P } A B 0 V E ( * I C 1 : * P I N 1 ) & WRAPPED(*IC1:*PIN1)) & C C o m p l e t e S e t o f M u l t i w r a p R u l e s 92 E Q U I V _ P I N ( * I C 1 : * P I N 1 , * I C 3 : * P I N 3 ) & ! T R U E ( { * P } W R A P P E D ( * I C 3 : * P I N 3 ) ) & ( ( G O A L ( C O N N E C T ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) & ! E Q U A L ( J U S T I F I C A T I O N , S O L V I N G _ G O A L ( * I C 3 : * P I N 3 , * I C 2 : * P I N 2 ) ) ) | ( G O A L ( C O N N E C T ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) & ! E Q U A L ( * J U S T I F I C A T I O N , S O L V I N G _ G O A L ( * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) ) ) ) & E Q U I V P I N ( * I C 2 : * P I N 2 , * I C 4 : * P I N 4 ) & ^ P u s - e l * ? } - W R A P P E D ( * I C 4 : * P I N 4 ) ) & - ( E Q U I V P I N ( * I C 2 : * P I N 2 , * I C 5 : * P I N 5 ) & ! T R U E T { * P } - W R A P P E D ( * I C 5 : * P I N 5 ) ) & ! C L O S E R ( * P , * I C 3 : * P I N 3 , * I C 5 : * P I N 5 , * I C 4 : * P I N 4 ) ) - > { S E Q U E N C E 1 ( * I C 4 : * P I N 4 , * J U S T I F I C A T I O N ) } N E X T _ R U L E ( S H I F T ( * I C 4 : * P I N 4 , * , * J U S T I F I C A T I O N ) ) . /* I f r e a d y t o s t a r t a c o n n e c t i o n a n d t h e r e i s no p i n t o c h a i n t o , t h e n c u t t h e w i r e . V P L A N ( * P ; S E T ( * ) ) & ! T R U E ( { * P } A B O V E ( * I C 1 : * P I N 1 ) & W R A P P E D ( * I C 1 : * P I N 1 ) ) & - ( E Q U I V _ P I N ( * I C 1 : * P I N 1 , * I C 3 : * P I N 3 ) & G O A L ( C O N N E C T ( * I C 3 : * P I N 3 , * ) ) ) -> { E N D _ C H A I N ( * I C 1 : * P I N 1 ) } N E X T _ R U L E ( S I G N A L ( 2 , * I C 1 : * P I N 1 ) ) . /* A f t e r s h i f t i n g t h e v a r i a b l e t o t h e l o c a t i o n o f t h e p i n , i t c a n be a p p r o a c h e d . V P L A N ( * ; S H I F T ( * I C : * P I N , * , J U S T I F I C A T I O N ) ) - > { S E Q U E N C E 2 ( * I C : * P I N , J U S T I F I C A T I O N ) } N E X T _ R U L E ( A P P R O ( * I C : * P I N , * : * , J U S T I F I C A T I O N ) ) . /* A f t e r a p p r o a c h i n g a p i n , t h e t o o l c a n be moved t o i t . V P L A N ( * ; A P P R O ( * I C : * P I N , * : * , J U S T I F I C A T I O N ) ) - > { S E Q U E N C E 3 ( * I C : * P I N , J U S T I F I C A T I O N ) } N E X T _ R U L E ( M O V E S ( * I C : * P I N , J U S T I F I C A T I O N ) ) . /* A f t e r m o v i n g t o a p i n , w r a p p i n g i t w i l l c a u s e a c o n n e c t i o n b e t w e e n i t a n d t h e p r e v i o u s p i n . V P L A N ( * ; M O V E S ( * I C : * P I N , J U S T I F I C A T I O N ) ) - > { S E Q U E N C E 4 ( * I C : * P I N , J U S T I F I C A T I O N ) } N E X T _ R U L E ( S I G N A L ( 1 ,* I C : * P I N , J U S T I F I C A T I O N ) ) . /* A f t e r w r a p p i n g a p i n t h e t o o l c a n d e p a r t . V P L A N ( * ; S I G N A L ( 1 , * I C : * P I N , J U S T I F I C A T I O N ) ) - > ( S E Q U E N C E 5 ( * I C : * P I N ) } N E X T R U L E ( D E P A R T S ( * I C : * P I N ) ) . C C o m p l e t e S e t o f M u l t i w r a p R u l e s 93 /* O r d e r t h a t t h e r u l e s s h o u l d be n o n d e t e r m i n i s t i c a l l y c h o s e n . */ -> {METAFACTS}CHOOSE(START_CONNECTION). -> {METAFACTS}CHOOSE(CHAIN). -> {METAFACTS}CHOOSE(SEQUENCE 1 ( * , * ) ) . -> {METAFACTS}CHOOSE(SEQUENCE2(*,*)). -> {METAFACTS}CHOOSE(SEQUENCE3(*,*)). -> {METAFACTS}CHOOSE(SEQUENCE4(*,*)) . -> {METAFACTS}CHOOSE(SEQUENCE5(*)). -> {METAFACTS}CHOOSE(END_CHAIN(*)). -> {METAFACTS}CHOOSE(START NEXT C H A I N ( * ) ) . /* The p r o g r a m v a r i a b l e i s s e t t o t h e o r i g i n w henever t h e r u l e i s f i r e d . */ SYMBOLIC_ORIGIN(*NAME) -> {SET(*NAME)} VAR_SET_TO_ORIGIN & -VAR_SET_TO_PI N_LOCATI ON ( * ) . /* I f t h e p r o g r a m v a r i a b l e i s s e t t o t h e o r i g i n , c h o o s e a component and an u n w r a p p e d p i n and s h i f t t h e o r i g i n a c c o r d i n g t o t h e l o c a t i o n o f t h e component and t h e p i n number. The p r o g r a m v a r i a b l e i s now s e t t o t h e un w r a p p e d p i n l o c a t i o n . */ VAR_SET_TO_ORIGIN & LOCATION(*IC,*ICLOC) & NO_PINS(*IC,*N) & !BETWEEN(*PIN,1,*N) & -WRAPPED(*IC:*PIN) & !REFERENCE_PIN_SHIFT(*PIN,*N,*DISP) & !RELOCATE(*ICLOC,*DISP,*PINLOC) -> {SHI F T ( * I C : * P I N , * P I N L O C , * J U S T I F I C A T I O N ) } VAR_SET_TO_PIN_LOCATION(*IC:*PIN) & -VAR_SET_TO_ORIGIN. /* I f t h e p r o g r a m v a r i a b l e i s s e t t o t h e n e x t u n w r a p p e d p i n l o c a t i o n and t h e t o o l i s n e i t h e r a t o r a b o v e i t , t h e n i t ca n be a p p r o a c h e d l e a v i n g t h e p r e v i o u s p i n b e h i n d . */ VAR_SET_TO_PIN_LOCATION(*IC:*PIN) & C C o m p l e t e S e t o f M u l t i w r a p R u l e s 94 -AT(*IC:*PIN) & -ABOVE(*IC:*PIN) & -WRAPPED(*IC:*PIN) & ABOVE(*OLDIC:*OLDPIN) -> {APPRO(*IC:*PIN,*OLDIC:*OLDPIN,*JUSTIFICATION)} ABOVE(*IC:*PIN) & -ABOVE(*OLDIC:*OLDPIN). /* I f above an unwrapped p i n , then moving to i t w i l l cause the t o o l to be at i t . V ABOVE(*IC:*PIN) & -WRAPPED(*IC:*PIN) -> {MOVES(*IC:*PIN,JUSTIFICATION)} AT(*IC:*PIN) & -ABOVE(*IC:*PIN). /* I f at an unwrapped p i n , then wrapping i t w i l l cause a connect i o n between i t and any other wrapped p i n . V AT(*IC:*PIN) -> {SIGNAL(1,*IC:*PIN,SOLVING_GOAL (* IC1:*PIN1,*IC2:*PIN2)) } WRAPPED(*IC:*PIN) & CONNECT ( * I C 1 : * P I N 1 , * I C 2 : * P I N 2 ) . /* If at a p i n , wrapping i t w i l l cause i t to be wrapped. */ AT(*IC:*PIN) -> {SIGNAL(1,*IC:*PIN,MOVING_TO_START_CHAIN(*IC:*PIN))} WRAPPED(*IC:*PIN). /* The wire may be cut whenever the t o o l i s above a p i n . */ ABOVE(*IC:*PIN) -> {SIGNAL(2,*IC:*PIN)} END_CHAIN(*IC:*PIN). /* I f at a wrapped p i n , d e p a r t i n g w i l l cause the t o o l to be above i t and not at i t . T h i s terminates a connec t i o n and thus the s t a r t token can be a s s e r t e d to s t a r t the next. */ WRAPPED(*IC:*PIN) & AT(*IC:*PIN) -> {DEPARTS(*IC:*PIN)} ABOVE(*IC:*PIN) & -AT(*IC:*PIN). C Complete Set of Multiwrap Rules 95 APPENDIX D A u x i l i a r y P r e d i c a t e s f o r W i r e - W r a p p i n g P r o b l e m s 0 P ( : , R L f 8 0 ) . BETWEEN(0,*,0) <"/. BETWEEN(*I,*LOW,*HIGH) <-INTEGER(*I) & LE(*LOW,*I) & G E ( * H I G H , * I ) . INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER 1 ) . 2) . 3) . 4) . 5) . 6) . 7 ) . 8) . 9) . 10) 1 1 ) 12) 13) 14) 15) 16) REFERENCE_PIN_SHIFT(*PIN,*N,*DX:38) <-QUOT(*N,2,*HALF) & L E ( * P I N , * H A L F ) & / & PROD(*PIN,25,*DX). REFERENCE_PIN_SHIFT(*PIN,*N,*DX:'-38') <-DIFF(*N,*PIN,*T1) & ADD 1 (*T1 ,*T2) D A u x i l i a r y P r e d i c a t e s f o r W i r e - W r a p p i n g P r o b l e m s 96 & PR 0 D ( * T 2 , 2 5 , * D X ) . RELOCATE(*OLDX:*OLDY,*DX:*DY,*NEWX:*NEWY) <-ADD(*OLDX,*DX,*NEWX) & ADD(*OLDY,*DY,*NEWY). C L O S E R ( * P L A N , * I C 1 : * P I N 1 , * I C 2 : * P I N 2 , * I C 3 : * P I N 3 ) <-LOCATE(*PLAN,*IC1:*PIN1,*PINLOC1) & LOC A T E ( * P L A N , * I C 2 : * P I N 2 , * P I N L O C 2 ) & LOCATE(*PLAN,*IC3:*PIN3,*PINLOC3) & DISTANCE_SQUARED(*PINLOC1,*PINLOC2,*DIST1) & DISTANCE_SQUARED(*PINLOC1,*PINLOC3,*DIST2) & L T ( * D I S T 1 , * D I S T 2 ) . L OCATE(*PLAN,*IC:*PIN,*PINLOC) <-TRUE((*PLAN}LOCATION(*IC,*ICLOC) & N O _ P I N S ( * I C , * N ) ) & RE F E R E N C E _ P I N _ S H I F T ( * P I N , * N , * D I S P ) & R E L O C A T E ( * I C L O C , * D I S P , * P I N L O C ) . DlSTANCE SQUARED(*X1:*Y1,*X2:*Y2,*DIST) < - D I F F l * X 1 , * X 2 , * X ) & D I F F ( * Y 1 , * Y 2 , * Y ) & PROD(*X,*X,*XX) & PROD(*Y,*Y,*YY) & AD D ( * X X , * Y Y , * D I S T ) . D A u x i l i a r y P r e d i c a t e s f o r W i r e - W r a p p i n g P r o b l e m s 97 APPENDIX E T r a c e o f M e t a w r a p P r o b l e m PROLOG/MTS 0 . 2 END OF F I L E READ FROM m e t a w r a p G i v e n F a c t s SYMBOLIC O R I G I N ( o r i g i n ) & L O C A T I O N l S T A R T I C , 0 : 0 ) & L O C A T I O N ( I C , 1 0 0 0 : 1 0 0 0 ) & N O _ P I N S ( S T A R T I C , 0 ) & N O _ P I N S ( l C ,1 4 ) & WRAPPED(STARTIC : 0 ) & A B O V E ( S T A R T I C : 0 ) G o a l t o be S o l v e d C O N N E C T ( S T A R T I C : 0 , I C : 2 ) & C O N N E C T ( I C :2 , I C :1 ) & CONNECT(IC:1,IC : 3 ) M e t a P l a n CHOOSE(START_CONNECTION) S u g g e s t s E x p a n s i o n L E V E L (1 ) ; START_CONNECTION P r e c o n d i t i o n o f START_CONNECTION h o l d s L E V E L ( 0 ) & D E P T H ( 0 ) P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; START_CONNECTION S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; SET ( *1 ) E T r a c e o f M e t a w r a p P r o b l e m 98 P r e c o n d i t i o n o f S E T ( o r i g i n ) h o l d s S Y M B O L I C _ O R I G I N ( o r i g i n ) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE 1 (* 1)) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE 1 (* 1 ) P r e c o n d i t i o n o f SEQUENCE 1 ( I C : 2 ) h o l d s P L A N ( L E V E L ( 0 ) ; S E T ( o r i g i n ) ) & GOAL(CONNECT(STARTIC:0,IC:2)) & ! T R U E ( { ( L E V E L ( 0 ) } A B O V E ( S T A R T I C : 0 ) & W R A P P E D ( S T A R T I C : 0 ) ) ) P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE 1 ( I C : 2 ) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , * 1 ) P r e c o n d i t i o n o f S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) h o l d s VAR_SET_TO_ORIGIN & L 0 C A T I 0 N ( I C , 1 0 0 0 : 1 0 0 0 ) & N O _ P I N S ( l C , 1 4 ) & !BETWEEN(2,1,14) & -WRAPPED(IC:2) & : !REFERENCE_PIN_SHIFT(2,14,50:38) & !RELOCATE(1000:1000,50:38,1050:1038) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE2(* 1 )) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE2 ( * 1 ) P r e c o n d i t i o n o f SEQUENCE2(IC:2) h o l d s E T r a c e o f M e t a w r a p P r o b l e m 99 P L A N ( L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ) P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE2(IC:2) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R 0 ( I C : 2 , * 1 ) P r e c o n d i t i o n o f APPRO(IC:2,STARTIC:0) h o l d s VAR S E T _ T 0 _ P I N _ L 0 C A T I 0 N ( I C : 2 ) & -•ATTlC:2) & - A B 0 V E ( I C : 2 ) & -•WRAPPED(IC:2) & ABOVE(STARTIC:0) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE3(*1)) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE3(*1) P r e c o n d i t i o n o f SEQUENCE3(IC:2) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE3(IC:2) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O ( I C : 2 , S T A R T I C : 0 ) ; MOVES(IC:2) P r e c o n d i t i o n o f MOVES(IC:2) h o l d s A B O V E ( I C : 2 ) & E T r a c e o f M e t a w r a p P r o b l e m 100 -WRAPPED(IC:2) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE4(*1 ,*2) ) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE4(*1,*2) P r e c o n d i t i o n o f SEQUENCE4(STARTIC:0,IC:2) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE4(STARTIC: 0 ,1C: 2 ) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; APP R O ( I C : 2 , S T A R T I C : 0 ) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , 1 C : 2 ) P r e c o n d i t i o n o f S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) h o l d s A T ( I C : 2 ) & "•WRAPPED ( I C : 2 ) & WRAPPED(STARTIC:0) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE5(* 1 )) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE5(*1) P r e c o n d i t i o n o f SEQUENCE5(IC:2) h o l d s P l a n E x p a n d e d M e t a P l a n E T r a c e o f M e t a w r a p P r o b l e m 101 LEVEL(1 ) ; SEQUENCE5(IC:2) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; APPRO(IC:2,STARTIC:0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; DEPARTS(IC:2) P r e c o n d i t i o n o f D E P A R T S ( I C : 2 ) h o l d s WRAPPED(IC:2) & A T ( I C : 2 ) P l a n E x p a n d e d M e t a P l a n CHOOSE(CHAIN) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; CHAIN P r e c o n d i t i o n o f CHAIN h o l d s P l a n E x p a n d e d Meta P l a n L E V E L ( 1 ) ; CHAIN S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; .. S H I F T ( I C : 2 , 1050: 1038) ; APPRO(IC:2,STARTIC:0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; DEPARTS(IC:2) ; SET(*1 ) P r e c o n d i t i o n o f S E T ( o r i g i n ) h o l d s S Y M B O L I C _ O R I G l N ( o r i g i n ) P l a n E x p a n d e d E T r a c e o f M e t a w r a p P r o b l e m 1 02 M e t a P l a n CHOOSE(SEQUENCE 1 (* 1)) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE 1 ( * 1 ) P r e c o n d i t i o n o f SEQUENCE 1 ( I C : 1 ) h o l d s • • • P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE 1 ( I C : 1 ) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; APPR O ( I C : 2 , S T A R T I C : 0 ) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; DEP A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T d C : 1 ,* 1 ) P r e c o n d i t i o n o f S H I F T d C : 1 , 1 025: 1 038) h o l d s VAR_SET_TO_ORIGIN & LO C A T I O N ( I C , 1 0 0 0 : 1 0 0 0 ) & N O _ P I N S ( l C , 1 4 ) & !BETWEEN(1,1,14) & -•WRAPPED ( I C : 1 ) & !REFERENCE_PIN_SHIFT(1,14,25:38) & !RELOCATE(1000:1000,25:38,1025:1038) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE2(* 1 )) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE2(* 1) P r e c o n d i t i o n o f SEQUENCE2(IC:1) h o l d s • • • E T r a c e o f M e t a w r a p P r o b l e m 1 03 P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE2(IC:1) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O ( I C : 2 , S T A R T I C : 0 ) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , 1 C : 2 ) ; D E P A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T d C : 1 , 1 025: 1 038) ; A P P R O d C : 1 ,*1 ) P r e c o n d i t i o n o f A P P R O ( I C : 1 , I C : 2 ) h o l d s VAR SET_TO_PIN_LOCATION ( l C :1) & -AT "ClC:l) & -ABOVE(IC:1) & -WRAPPED(IC:1) & A B O V E ( I C : 2 ) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE3(*1)) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE3(*1) P r e c o n d i t i o n o f SEQUENCE3(IC:1) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE3(IC:1) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2, STARTIC: 0) ; E T r a c e o f M e t a w r a p P r o b l e m 1 04 MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; D E P A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 1 , 1 0 2 5 : 1 0 3 8 ) ; A P P R O d C : 1 , IC:2) ; MOVES(IC: 1 ) P r e c o n d i t i o n o f M 0 V E S ( I C : 1 ) h o l d s A B 0 V E ( I C : 1 ) & -WRAPPED d C : 1 ) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE4(*1,*2)) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE4(*1, *2) P r e c o n d i t i o n o f SEQUENCE4(IC:2,IC:1) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE4(IC:2,IC:1) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2, STARTIC: 0) ; M 0 V E S ( I C : 2 ) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; D E P A R T S ( I C : 2 ) ; . . S E T ( o r i g i n ) ; S H I F T d C : 1 , 1 025: 1 038) ; A P P R O d C : 1 , I C : 2 ) ; MOVES(IC:1) ; SIGNAL ( 1 ,I*C:2,IC: 1 ) P r e c o n d i t i o n o f S I G N A L ( 1 , I C : 2 , I C : 1 ) h o l d s A T ( I C : 1 ) & -WRAPPED(IC:1) & WRAPPED(IC:2) E T r a c e o f M e t a w r a p P r o b l e m 105 P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE5(* 1 )) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE5(*1) P r e c o n d i t i o n o f SEQUENCE5(IC:1) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE5(IC:1) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2, STARTIC: 0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; D E P A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T d C : 1 , 1025: 1038) ; A P P R O ( I C : 1 , I C : 2 ) ; MOVES(IC:1) ; S I G N A L ( 1 , I C : 2 , I C : 1 ) ; D E P A R T S ( I C : 1 ) P r e c o n d i t i o n o f D E P A R T S ( I C : 1 ) h o l d s WRAPPED(IC:1) & A T ( I C : 1 ) P l a n E x p a n d e d M e t a P l a n CHOOSE(CHAIN) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; CHAIN P r e c o n d i t i o n o f CHAIN h o l d s E T r a c e of M e t a w r a p P r o b l e m 106 P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; CHAIN S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2, STARTIC: 0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; D E P A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T d C : 1 , 1 025: 1 038) ; A P P R O ( I C : 1 , I C : 2 ) ; M 0 V E S ( I C : 1 ) ; S I G N A L ( 1 , I C : 2 , I C : 1 ) ; D E P A R T S ( I C : 1 ) ; S E T ( * 1 ) P r e c o n d i t i o n o f S E T ( o r i g i n ) h o l d s S YMBOLIC_ORIGIN(or i g i n ) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE 1 ( * 1)) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE 1 (* 1 ) P r e c o n d i t i o n o f SEQUENCE 1 ( I C : 3 ) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE 1 ( I C : 3 ) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1038) ; E T r a c e o f M e t a w r a p P r o b l e m 1 07 A P P R O ( I C : 2 , S T A R T I C : 0 ) ; M 0 V E S ( I C : 2 ) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; D E P A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 1 , 1 0 2 5 : 1 0 3 8 ) ; A P P R O ( I C : 1 , I C : 2 ) ; MOVES(IC: 1 ) ; S I G N A L ( 1 , I C : 2 , I C : 1 ) ; DEPARTS(IC:1 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 3 , * 1 ) P r e c o n d i t i o n o f S H I F T ( I C : 3 , 1 0 7 5 : 1 0 3 8 ) h o l d s VAR_SET_TO_ORIGIN & L O C A T I O N ( l C , 1 0 0 0 : 1 0 0 0 ) & N O _ P I N S ( l C , 1 4 ) & !BETWEEN(3,1,14) & -WRAPPED(IC:3) & !REFERENCE_PIN_SHIFT(3,14,75:38) & !RELOCATE(1000:1000,75:38,1075:1038) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE2(*1)) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE2(*1) P r e c o n d i t i o n o f SEQUENCE2(IC:3) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE2(IC:3) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2,STARTIC:0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; D E P A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; E T r a c e o f M e t a w r a p P r o b l e m 108 S H I F T d C : 1 , 1 0 25: 1 038) ; A P P R O ( I C : 1 , I C : 2 ) ; MOVES(IC:1) ; S I G N A L ( 1 , I C : 2 , I C : 1 ) ; D E P A R T S ( I C : 1 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 3 , 1 0 7 5 : 1 0 3 8 ) ; APPRO(IC:3,*1 ) P r e c o n d i t i o n o f A P P R O d C : 3 , I C : 1 ) h o l d s VAR SET_TO_PIN_LOCATION(lC:3) & - A T " C I C:3) & - A B O V E ( l C : 3 ) & -WRAPPED( IC:3) & ABOVE ( IC:1) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE3(* 1 ) ) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE3(*1 ) P r e c o n d i t i o n o f SEQUENCE3( IC:3) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE3(IC:3) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2,STARTIC:0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; D E P A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T d C : 1 , 1 0 25: 1 038) ; A P P R O d C : 1 , I C : 2) ; MOVES(IC:1) ; S I G N A L ( 1 , I C : 2 , I C : 1 ) ; D E P A R T S ( I C : 1 ) ; S E T ( o r i g i n ) ; E T r a c e of M e t a w r a p P r o b l e m 109 S H I F T ( I C : 3 , 1 0 7 5 : 1 0 3 8 ) ; A P P R O ( I C : 3 , I C : 1 ) ; MOVES(IC:3) P r e c o n d i t i o n o f MOVES(IC:3) h o l d s A B 0 V E ( I C : 3 ) & -WRAPPED(IC:3) P l a n E x p a n d e d M e t a P l a n CHOOSE(SEQUENCE4(* 1,*2) ) S u g g e s t s E x p a n s i o n L E V E L ( 1 ) ; SEQUENCE4(*1,*2) P r e c o n d i t i o n o f SEQUENCE4(IC:1,IC:3) h o l d s P l a n E x p a n d e d M e t a P l a n L E V E L ( 1 ) ; SEQUENCE4(IC:1,IC:3) S u g g e s t s E x p a n s i o n L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2, STARTIC: 0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; DEPARTS(IC:2) ; S E T ( o r i g i n ) ; S H I F T d C : 1 , 1025: 1038) ; A P P R O d C : 1 , I C : 2) ; M 0 V E S ( I C : 1 ) ; S I G N A L ( 1 , I C : 2 , I C : 1 ) ; D E P A R T S ( I C : 1 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 3 , 1 0 7 5 : 1 0 3 8 ) ; A P P R O ( I C : 3 , I C : 1 ) ; MOVES(IC:3) ; S I G N A L ( 1 , I C : 1 , I C : 3 ) P r e c o n d i t i o n o f S I G N A L ( 1 , I C : 1 , I C : 3 ) h o l d s A T ( I C : 3 ) & E T r a c e o f M e t a w r a p P r o b l e m 1 1 0 -WRAPPED(IC:3) & WRAPPED(IC: 1 ) P l a n E x p a n d e d S o l u t i o n t o P r o b l e m SYMBOLIC O R I G I N ( o r i g i n ) & LOCATIONlSTARTIC,0:0) & L O C A T I O N ( I C , 1 0 0 0 : 1 0 0 0 ) & NO_PINS(STARTIC,0) & N O _ P I N S ( l C , 1 4 ) & WRAPPED(STARTIC:0) & ABOVE(STARTIC:0) -> { L E V E L ( 0 ) ; S E T ( o r i g i n ) ; S H I F T ( I C : 2 , 1 0 5 0 : 1 0 3 8 ) ; A P P R O d C : 2, STARTIC: 0) ; MOVES(IC:2) ; S I G N A L ( 1 , S T A R T I C : 0 , I C : 2 ) ; DEP A R T S ( I C : 2 ) ; S E T ( o r i g i n ) ; S H I F T d C : 1 , 1 025: 1 038) ; A P P R O d C : 1 , I C : 2) ; MOVES(IC:1) ; S I G N A L ( 1 , I C : 2 , I C : 1 ) ; DE P A R T S ( I C : 1 ) ; S E T ( o r i g i n ) ; S H I F T d C : 3, 1075: 1038) ; A P P R O ( I C : 3 , I C : 1 ) ; MOVES(IC:3) ; S I G N A L ( 1 , I C : 1 , I C : 3 ) } CONNECT(STARTIC:0,IC:2) & CONNECT(IC:2,IC:1) & C O N N E C T ( I C : 1 , I C : 3 ) . END OF F I L E READ FROM m e t a g o a l E X I T PROLOG/MTS 0.2 E T r a c e o f M e t a w r a p P r o b l e m 111 APPENDIX F U s i n g RCPS on MTS $SET ECHO $COMMENT $COMMENT $COMMENT $COMMENT $COMMENT $COMMENT $COMMENT $COMMENT $COMMENT $COMMENT $empty - t $RUN PLOG $CONTINUE $CONTINUE $CONTINUE <-RCPS. =OFF The f o l l o w i n g f i l e i s u s e d t o b o o t RCPS. T h e r e a r e a l w a y s t h r e e f i l e s t o l o a d : 1) RCPS i n t e r p r e t e r 2) u t i l i t y l i b r a r y 3) t r a c e p a c k a g e . The d e f a u l t t r a c e o p t i o n i s 3 a n d t h e t r a c e i s o u t p u t t o SERCOM w h i c h d e f a u l t s t o t h e t e m p o r a r y f i l e -TRACE. The n o r m a l i n t e r p r e t e r I/O i s t h r o u g h SCARDS a n d SPRINT. r a c e : p r o l o g s c a r d s = * s o u r c e * s e r c o m = - t r a c e t=3 par=ws=50 WITH J G I R : r c p s RETURN WITH J G I R : u t i l s . r c p s RETURN WITH J G I R : t r a c e . r c p s ( 1 0 3 ) RETURN F U s i n g RCPS on MTS 1 1 2 APPENDIX G RCPS I n t e r p r e t e r /* R e c u r s i v e l y C o n t r o l l e d P r o d u c t i o n S y s t e m V e r s i o n 1.1 T h i s p r o g r a m i s s u b j e c t t o c o p y r i g h t : The U n i v e r s i t y o f B r i t i s h C o l u m b i a ( c ) J e a n - L o u i s GIRARD J u l y , 1983. */ /* D e c l a r e PROLOG c o n t r o l */ CONTROL(ATTN, ON). /* A t t e n t i o n s a r e t r a p p e d . */ CONTROL(CC, ON). /* F i r s t c h a r a c t e r i s c a r r i a g e c o n t r o l . */ CONTROL(NOAX, O F F ) . /* Do n o t p r i n t w a r n i n g o f m i s s i n g a x i o m s . */ /* O p e r a t o r d e c l a r a t i o n s V /* The o p e r a t o r s a n d t h i s p a r s i n g p r e c e d e n c e d e f i n e s t h e RCPS l a n g u a g e s y n t a x . */ OP( ' ->', RL, 12) 0P( ' - >', P R E F I X , 20) O P ( { , P R E F I X , 15) OPO, RL, 15) OP(<, P R E F I X , 15) OP(>, RL, 15) OP( ; , LR, 80) 0 P ( ? , S U F F I X , 60) OP( ! , P R E F I X , 85) /* E r r o r t r a p a n d */ /* Look up g o a l t h a t f a i l e d a n d c a l l a s s o c i a t e d m e s s a g e . V ERROR <-ANCESTOR(*X,2) & M S G ( * X ) . G RCPS I n t e r p r e t e r 1 13 /* S y n t a x e r r o r i f r e a d i n g f r o m m a s t e r s o u r c e ; t h u s , r e t r y i n p u t . */ MSG(READ(*,'*MSOURCE* ' ) ) <-/ /* CR */ & P R I N T C « < S Y N T A X » > T r y a g a i n ' . S K I P ( 2 ) ) & RETRY(SOURCE('*MSOURCE*')). /* S y n t a x e r r o r f r o m a s o u r c e f i l e c a n n o t be r e t r i e d . */ M S G ( R E A D ( * , * I ) ) <-/ /* CR */ & P R I N T C « < S Y N T A X » > on ' . * I . ' ~ A b o r t i n g ' . SKI P ( 2 ) ) & RETRY(SOURCE('*MSOURCE*')). /* G e n e r a l e r r o r r e c o v e r y . */ MSG(*X) <-PRINT(' *** ERROR *** o c c u r e d w h i l e d e r i v i n g ' . * X . S K I P ( 2 ) ) & R E T R Y ( S O U R C E ( * ) ) . /* R e a d - E v a l - P r i n t l o o p V /* B o o t message V RCPS <-PRINT('0*** R e c u r s i v e l y C o n t r o l l e d P r o d u c t i o n S y s t e m . ' V e r s i o n 1.1 ***' . S K I P ( 2 ) ) & SOURCE. /* Read r e c o r d f r o m i n p u t u n i t , e v a l r e c o r d , p r e t t y p r i n t r e c o r d , a n d s e l f l o o p . V SOURCE <-SOURCE('*MSOURCE*'). SOURCE(*LOGUNIT) <-PRINT('&<-','*MSINK*') & READ ONCE(*GOAL,*LOGUNIT) & EVAL l * G O A L ) & ECHO(*GOAL) & PRINT('.','*MSINK*') & R E T R Y ( S O U R C E ( * ) ) . /* E v a l u a t e a r g u m e n t u s i n g PROLOG m e t a v a r i a b l e f a c i l i t y ( i . e . C A L L ) . V G RCPS I n t e r p r e t e r 1 1 4 E V A L ( * X ) <-*X & /. /* GT & CR */ /* S u c c e e d a t SOURCE EOF. */ E V A L ( S O U R C E ( * X ) ) <-/. /* CR */ /* P r i n t g o a l f a i l e d . V E V A L ( * X ) <-ECHO(*X) & P R I N T C F A I L E D ! ' . S K I P ( 2 ) * M S I N K * ' ) & R E T R Y ( S O U R C E ( * ) ) . /* P r e t t y p r i n t R o u t i n e s V /* T h e s e r o u t i n e s a r e u s e d by t h e t r a c e p a c k a g e . V ECHO(*X&*Y) <-/ /* CR */ & ECHO(*X) & P R I N T C &'.SKIP(O),'*MSINK*') & E C H O ( * Y ) . ECHO(*RULE) <-EQUAL(*RULE,*->{*}*) & / /* CR */ & P R I N T ( S K I P ( 1 ) , ' * M S I N K * ' ) & FLUSH(SYMBOL COUNTERC*',*)) & GROUND(*RULE! & PPRULE(*RULE,'*MSINK*' ) . ECHO(*X) < - P R I N T ( S K I P ( 1 ) . T A B ( 7 ) . * X . S K I P ( 0 ) , ' * M S I N K * ' ) . PPRULE(*X->{*REST;*FIRST}*Y,*OUTUNIT) <-/ /* CR */ & PPCONJUNCT(TAB( 7),*X,*OUTUNIT) & P R I N T ( S K I P ( 1 ) . T A B ( 9 ) . ' - > { '.SKIP(0),*OUTUNIT) & PPPLAN(TAB(14),*REST;*FIRST,*OUTUNIT) & P R I N T C }',*OUTUNIT) & PPCONJUNCT(TAB( 1 8 ),*Y,*OUTUNIT). PPRULE(*X->{*ONLY}*Y,*OUTUNIT) <-PPCONJUNCT(TAB(7),*X,*OUTUNIT) & P R I N T ( S K I P ( 1 ) . T A B ( 9 ) . ' - > { '.*ONLY.' }',*OUTUNIT) & PPCONJUNCT(TAB( 1 8),*Y,*OUTUNIT). G RCPS I n t e r p r e t e r 1 1 5 PPCONJUNCT(*INDENT,*FIRST & *REST,*OUTUNIT) <-/ /* CR */ & PRINT(*INDENT.*FIRST.' &',*OUTUNIT) Sc PPCONJUNCT(*INDENT,*REST,*OUTUNIT). PPCONJUNCT(*INDENT,*ONLY,*OUTUNIT) <-PRINT(*INDENT.*ONLY.SKIP(0),*OUTUNIT). PPPLAN(*INDENT,*REST ; *FIRST,*OUTUNIT) <-/ /* CR */ & PPPLAN(*INDENT,*REST,*OUTUNIT) & PPPLAN1(*INDENT,*FIRST,*OUTUNIT). PPPLAN(*INDENT,*ONLY,*OUTUNIT) <-PRINT(*ONLY.SKIP(0),*OUTUNIT). PPPLAN1(*INDENT,*REST ; *FIRST,*OUTUNIT) <-/ /* CR */ & PRINTC ;'.SKIP(1).*INDENT.SKIP(0),*OUTUNIT) & PPPLAN(*INDENT,*REST ; *FIRST,*OUTUNIT). PPPLAN1(*INDENT,*ONLY,*OUTUNIT) <-PRINT(' ;',SKIP(1).*INDENT.*ONLY.SKIP(0),*OUTUNIT). /* I n t e r p r e t o b j e c t l a n g u a g e V /* RCPS p r o b l e m s t a t e m e n t w i t h o u t p a r t i a l p l a n */ *GIVEN->{*PLAN}*GOAL <-VAR(*PLAN) Sc / /* CR */ & NEXT_LEVEL(*GIVEN,*LEVEL) & TRACE 1 (*LEVEL,*GIVEN,*GOAL) Sc ASSERT({LEVEL(*LEVEL)}*GIVEN&PLAN(LEVEL(*LEVEL),0)) & PLAN(*LEVEL,*GOAL,*PLAN) & TRACE2(*LEVEL,*GIVEN->{*PLAN}*GOAL). /* RCPS p r o b l e m s t a t e m e n t w i t h p a r t i a l p l a n - i n i t i a l c a l l */ *GIVEN->{*REST;*PLAN}*GOAL <-VAR(*PLAN) Sc USE_LEVEL(*REST,*LEVEL) St / /* CR */ & FLUSH(({LEVEL(*LEVEL)}PLAN(*,*))?) Sc TRACE 1 (*LEVEL,*GIVEN, *GOAL) Sc ASSERT ( {LEVEL ( *LEVEL ) } *GI VENScPLAN ( *REST , 0 ) ) G RCPS I n t e r p r e t e r 1 16 & PLAN(*LEVEL,*GOAL,*COMPLETE_PLAN) & EXTRACT_PARTIAL_PLAN(*COMPLETE_PLAN,*REST,*PLAN) Sc TRACE2 ( *LEVEL,*GIVEN->{*PLAN}*G0AL). /* RCPS p r o b l e m s t a t e m e n t w i t h p a r t i a l p l a n - r e c u r s i v e c a l l */ *GIVEN->{*REST;*PLAN}*GOAL <-VAR(*PLAN) Sc / / * CR * / Sc NEXT_LEVEL ( *GI VEN , *LEVEL ) Sc TRACE 1 (*LEVEL,*GIVEN, *GOAL) Sc ASSERT ( { LEVEL (* LEVEL) } *GI VENScPLAN ( *REST; LEVEL ( *LEVEL) , 0) ) Sc PLAN ( * LEVEL , *GOAL , *COMPLETE_PLAN) Sc EXTRACT_PARTI AL_PLAN ( *COMPLETE_PLAN , *REST, *PLAN) Sc TRACE2(*LEVEL,*GIVEN->{*PLAN}*GOAL) . / * RCPS r u l e s t a t e m e n t */ *ANT->{*ACT}*CON <-ASSERT({RULES}RULE(*ACT)) S< ASSERT (<*ACT>*ANT) Sc ASSERT( (*ACT}*CON) . / * RCPS m e t a f a c t s s t a t e m e n t */ ->{*ACT}*FACT <-ASSERT((*ACT}*FACT). /* I n c r e m e n t m e t a l e v e l number. V NEXT LEVEL (LEVEL (*CURRENT) Sc *,*LEVEL) <-7 /* CR */ Sc ADD 1 ( *CURRENT , *LEVEL ) Sc FLUSH (( {LEVEL (*LEVEL) } * ) ? ) . NE X T _ L E V E L ( * , 0 ) < - F L U S H ( ( { L E V E L ( 0 ) } * ) ? ) . /* R e t r i e v e l e v e l number f r o m p l a n . */ U S E _ L E V E L ( * ; L E V E L ( * L E V E L ) , * L E V E L ) <-/. /* CR */ U S E _ L E V E L ( L E V E L ( * L E V E L ) , * L E V E L ) <-/. /* CR */ U S E _ L E V E L ( * R E S T ; * F I R S T , * L E V E L ) < - U S E _ L E V E L ( * R E S T , * L E V E L ) . G RCPS I n t e r p r e t e r 1 1 7 /* E x t r a c t p a r t i a l p l a n f r o m t o t a l a n d r e m a i n d e r . */ EXTRACT PARTIAL_PLAN(CHOOSE(*ACT),*REST,CHOOSE(*ACT)) <-/. 7* CR */ EXTRACT_PARTIAL_PLAN(*COMPLETE_PLAN,*REST,*PLAN) <-EXTRACT_PARTIAL_PLAN 1 (*COMPLETE_PLAN,*REST,*PLAN). EXTRACT PARTIAL_PLAN1(*START;*LAST,*START,*LAST) <-/. 7* CR */ EXTRACT_PARTIAL_PLAN1(*COMPLETE;*LAST,*START,*REST;*LAST) <-/ /* CR */ & EXTRACT_PARTIAL_PLAN1(*COMPLETE,*START,*REST). EXTRACT_PARTIAL_PLAN1(*ONLY,*,*ONLY). /* V i r t u a l M a c h i n e V /* C o n d i t i o n f o r r e c u r s i v i t y V PLAN(*LEVEL,*GOAL,*PLAN) <-TRUE({RULES}RULE(*ACT)) /* I f t h e r e i s some r u l e & TRUE(<*ACT>*PRECONDITION) /* whose p r e c o n d i t i o n h a s & ANY_POS(*PRECONDITION) /* some p o s i t i v e a t o m i c & T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * G I V E N , 0 ) ) /* a n d i s c u r r e n t l y t r u e & TRUE({*GIVEN}*PRECONDITION) /* t h e n , s o l v e g o a l & / /* GT & CR */ & SOLVE(*GOAL,*LEVEL,*PLAN,0). /* r e c u r s i v e l y . P LAN(*LEVEL,NEXT_RULE(*ACT),CHOOSE(*ACT)) /* I f no k n o w l e d g e , <-TRUE({METAFACTS}CHOOSE(*ACT)). /* c h o o s e a c t i o n s i n /* o r d e r a s s e r t e d i n /* m e t a f a c t s . /* - S u c c e e d s i f f o r m u l a h a s some p o s i t i v e a t o m i c . V ANY_POS(*X) <-->NO POS(*X) . NO_POS(*FIRST & *REST) <-/ /* CR */ & NOT_POS(*FIRST) & NO_POS(*REST). NO POS(*ONLY) G RCPS I n t e r p r e t e r 1 18 <-NOT POS(*ONLY). NOT_POS(-*) <-/. /* CR */ NOT P O S ( ! * ) . /* M a i n p r o d u c t i o n s y s t e m l o g i c V SOLVE(*GOAL,*LEVEL,*PLAN,*DEPTH) /* I f t h e g o a l i s < - T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * P L A N , * D E P T H ) ) /* t r u e a t t h e & T R U E ( { * PLAN}*GOAL). /* c u r r e n t d e p t h /* a n d l e v e l , /* r e t u r n p l a n . SOLVE(*GOAL,*LEVEL,*PLAN;*ACT,*DEPTH) /* C r e a t e g i v e n o f <-ADD1(*DEPTH,*NEXT) /* c u r r e n t p l a n a n d & T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * P L A N , * D E P T H ) ) /* u n s o l v e d g o a l s a t & GOAL_ASSERTION(*GOAL,*PLAN,*G) /* c u r r e n t l e v e l f o r & ( L E V E L ( * L E V E L ) & PLAN(*PLAN) /* r e c u r s i v e c o n t r o l & *G & DEPTH(*DEPTH) /* c a l l . -> {METAFACTS;RULES;*MP} NEXT_RULE(*ACT) ) & TRACE3(*PLAN;*ACT,*MP,*DEPTH,*LEVEL) & TRUE(<*ACT>*PRECONDITION) /* Does c o n d i t i o n & (TRUE({*PLAN}*PRECONDITION) /* o f s u g g e s t e d r u l e | (TRACE6 ( *ACT , *LEVEL ) & F A I L ) ) /*. h o l d ? & TRACE4(*PRECONDITION,*ACT,*LEVEL) & CONFLICT_RESOLUTION(*ACT,*PLAN,*LEVEL) /* Does i t p a s s c o n -& TRACE5(*LEVEL) /* f l i c t r e s o l u t i o n ? & A S S E R T ( { L E V E L ( * L E V E L ) } P L A N ( * P L A N ; * A C T , * N E X T ) ) & F A I L . /* A p p l y i t by /* e x p a n d i n g p l a n . SOLVE(*GOAL,*LEVEL,*PLAN,*DEPTH) /* F L u s h p r e v i o u s < - F L U S H ( ( { L E V E L ( * L E V E L ) } P L A N ( * , * D E P T H ) ) ? ) /* l e v e l . & ADD 1(*DEPTH,*NEXT) /* C o n s i d e r n e x t l e v e l & T R U E ( { L E V E L ( * L E V E L ) } P L A N ( * , * N E X T ) ) /* I s t h e r e a p a t h t o & SOLVE(*GOAL,*LEVEL,*PLAN,*NEXT). /* c o n s i d e r ? I n c r e a s e /* d e p t h o f i n f e r e n c e /* R e t u r n a s s e r t i o n o f a l l u n t r u e g o a l s . */ GOAL_ASSERTI ON ( *G&*RESTGOAL , *PLAN , * RESULT) <--TRUE({*PLAN}*G) & / /* CR */ & GOAL ASSERTION 1 (*RESTGOAL,*PLAN,GOAL(*G),*RESULT). G RCPS I n t e r p r e t e r 1 1 9 GOAL ASSERTION(*G&*RESTGOAL,*PLAN,*RESULT) <-7 /* CR */ & GOAL_ASSERTION(*RESTGOAL,*PLAN,*RESULT). GOAL_ASSERTION(*G,*PLAN,GOAL(*G)) <--TRUE({*PLAN}*G). GOAL_ASSERTION 1 (*G&*RESTGOAL,*PLAN,*TMP,*RESULT) <--TRUE((*PLAN}*G) & / /* CR */ & GOAL_ASSERTI ON 1 ( *RESTGOAL , *PLAN , GOAL ( *G) 6t*TMP, *RESULT) . GOAL ASSERTION1(*G&*RESTGOAL,*PLAN,*TMP,*RESULT) <-7 /* CR */ & GOAL_ASSERTION1(*RESTGOAL,*PLAN,*TMP,*RESULT). GOAL_ASSERTION1(*G,*PLAN,*TMP,GOAL(*G)&*TMP) <--TRUE({*PLAN}*G) & /. /* CR */ GOAL ASSERTION 1 (*,*,*RESULT,*RESULT). CONFLICT_RESOLUTION(*ACT,*PLAN,*) < - ( ( * A C T } * F A C T ) ? & -"TRUE( { *PLAN } *FACT) & /. /* GT & CR */ CONFLICT_RESOLUTION(*ACT,*PLAN,*LEVEL) <-TRACE7(*ACT,*LEVEL) & F A I L . /* T r u t h M a i n t e n a n c e S y s t e m V TRUE({*ACTS}*FACT & *REST) /* <-/ /* CR */ & TRUE({*ACTS}*FACT) & T R U E ( { * A C T S } * R E S T ) . TRUE({*ACTS}*FACT | *REST) /* <- / /* CR */ & ( TRUE({*ACTS}*FACT) | T R U E ( { * A C T S } * R E S T ) ) . TRUE ( { *ACTS } _ ,*FACT) /* <-/ /* CR */ & - T R U E ( ( * A C T S } * F A C T ) . TRUE({*}!*FACT) /* G RCPS I n t e r p r e t e r C o n j u n c t i o n s */ D i s j u n c t i o n s */ N e g a t i o n */ I n d i r e c t i o n */ 1 20 <-/ /* CR */ & *FACT. TRUE({*REST;*ACT}*FACT) /* A t o m i c f a c t made t r u e by */ < - ( { * A C T } * F A C T ) ? . /* l a s t a c t i o n i n p l a n */ TRUE({*REST;*ACT}*FACT) /* A t o m i c f a c t made t r u e by */ <-/ /* CR */ /* some o t h e r a c t i o n i n p l a n */ & TRUE({*REST}*FACT) & N O T ( ( { * A C T } - * F A C T ) ? ) . TRUE((*ACT}*FACT) /* A t o m i c f a c t made t r u e by */ <-/ /* CR */ /* l a s t ( o n l y ) a c t i o n i n p l a n * / & ( { * A C T } * F A C T ) ? . TRUE(<*ACT>*FACT) /* U s e d t o r e t r i e v e p r e c o n d i t i o n */ <-(<*ACT>*FACT)?. ASSERT({*ACT}*FIRST&*REST) /* C o n j u n c t i o n */ <-/ /* CR */ & A S S E R T ( { * A C T } * F I R S T ) & A S S E R T ( ( * A C T } * R E S T ) . ASSERT(*FACT) /* A t o m i c f a c t */ <-NOTINDB((*FACT)?) & / /* CR */ & A D D A X ( ( * F A C T ) ? ) . A S S E R T ( * F A C T ) . N O T I N D B ( ( { * P R O B L E M } P L A N ( * P L A N , * L E V E L ) ) ? ) <-/ /* CR */ & - ( ( { * P R O B L E M } P L A N ( * P L A N , * L E V E L ) ) ? ) . /* NOTINDB(*FACT) <-AX(*FACT,*AX) & GROUND(*AX) . & EQUAL(*FACT,*AX) & /. */ /* GT & CR */ NOTINDB(*). G RCPS I n t e r p r e t e r 121 APPENDIX H U t i l i t i e s f o r RCPS I n t e r p r e t e r /* G r o u n d A r g u m e n t b e f o r e CWA */ NOT(*X) <-GROUND(*X) & *X & / /* NF */ & F A I L . N O T ( * X ) . /* W i l l r e t u r n i t ' s a r g u m e n t w i t h a l l v a r i a b l e s GENSYMed V GROUND(*X) <-VAR(*X) & / /* CR */ & G E N S Y M ( ' * ' , * X ) . GROUND(*X) <-CONS(*.*ARGS r*X) & GROUNDARGS(*ARGS). GROUNDARGS(NIL) <-/. /* CR */ GROUNDARGS(*FIRST.*REST) <-GROUND(*FIRST) & GROUNDARGS(*REST). /* G e n e r a t e a u n i q u e s y m b o l a nd r e t u r n bound t o a r g u m e n t */ GENSYM(*NAME,*UNIQUE) <-NEXT SYMBOL(*NAME,*NEW) Sc ADD 1 T*NEW, *NEXT) & UPDATE(SYMBOL_COUNTER(*NAME,*NEW), SYMBOL_COUNTER(*NAME,*NEXT)) & CONCATENATE(*NAME,*NEW,*UNIQUE). H U t i l i t i e s f o r RCPS I n t e r p r e t e r 1 22 NEXT_SYMBOL(*NAME,*NEW) <-SYMBOL_COUNTER(*NAME,*NEW) & /. /* CR */ NEXT_SYMBOL(*NAME,1) <-ADDAX(SYMBOL COUNTER(*NAME,1)). /* C o n c a t e n a t e two f i r s t s t r i n g s a n d r e t u r n i n t h i r d V CONCATENATE(*ID 1 , * I D 2 , * I D 1 I D 2 ) < - S T R I N G ( * I D 1 , * I D 1 L I S T ) & S T R I N G ( * I D 2 , * I D 2 L I S T ) & C O M B I N E ( * I D 1 L I S T , * I D 2 L I S T , * I D 1 I D 2 L I S T ) & S T R I N G ( * I D 1 I D 2 , * I D 1 I D 2 L I S T ) . C O M B I N E ( * F I R S T . N I L , * X , * F I R S T . * X ) <-/. /* CR */ COMBINE(*FIRST.*REST,*X,*Y) <-COMBINE(*REST,*X,* Z) & C O M B I N E ( * F I R S T . N I L , * Z , * Y ) . /* Adds 1 t o f i r s t a r g u m e n t a nd r e t u r n i n s e c o n d */ ADD1(*X,*Y) <-SUM(*X,1,*Y). /* S u b t r a c t s 1 f r o m f i r s t a r g u m e n t a nd r e t u r n i n s e c o n d */ SUB 1 (*X,*Y) < - D I F F ( * X , 1 , * Y ) . /* P r i n t l i s t o f s t r i n g s , s k i p p i n g l i n e s a s s p e c i f i e d V P R I N T ( * L ) < - P R I N T ( * L , ' * S I N K * ' ) . PRINT(*VAR,*OUTUNIT) <-VAR(*VAR) & / /* CR */ & WRITECH(*VAR,*OUTUNIT) & NEWLINE(*OUTUNIT). H U t i l i t i e s f o r RCPS I n t e r p r e t e r 123 PRINT(*VAR.*REST,*OUTUNIT) <-VAR(*VAR) & / /* CR */ & WRITECH(*VAR,*OUTUNIT) & PRINT(*REST,*OUTUNIT). PRINT(SKIP(*S).*REST,*OUTUNIT) <-/ /* CR */ & SKIP(*S,*OUTUNIT) & PRINT(*REST,*OUTUNIT). PRINT(TAB(*N).*REST,*OUTUNIT) <-/ /* CR */ & TAB(*N,*OUTUNIT) & PRINT(*REST,*OUTUNIT). PRINT(*FIRST.*REST,*OUTUNIT) <-/ /* CR */ & WRITECH(*FIRST,*OUTUNIT) & PRINT(*REST,*OUTUNIT). PRINT(SKIP(*S),*OUTUNIT) <-/ /* CR */ & SKIP(*S,*OUTUNIT). PRINT(TAB(*N),*OUTUNIT) <-/ /* CR */ & TAB(*N,*OUTUNIT) & NEWLINE(*OUTUNIT). PRINT(*ONLY,*OUTUNIT) <-WRITECH(*ONLY,*OUTUNIT) & NEWLINE(*OUTUNIT). SKIP(0,*) <-/. /* CR */ SKIP(*S,*OUTUNIT) <-NEWLINE(*OUTUNIT) & SUB 1 (*S,*T) & SKIP(*T,*OUTUNIT). TAB(0,*) <-/. /* CR */ TAB(*N,*OUTUNIT) <-WRITECH(' ',*OUTUNIT) & SUB 1 (*N,*T) & TAB(*T,*OUTUNIT). H U t i l i t i e s f o r RCPS I n t e r p r e t e r 1 2 4 /* C l e a r d a t a b a s e o f a l l a x i o m s t h a t m a t c h V FLUSH(*X) <-AX(*X,*X) & DEL A X ( * X ) & F A I L . F L U S H ( * ) . E Q U A L ( * X , * X ) . UPDATE(*X,*Y) <-DELAX(*X) & A D D A X ( * Y ) . REPEAT. REPEAT <-REPEAT. /* Rea d s t h a t d o n ' t l e a v e c h o i c e p o i n t s */ READCH_ONCE(*X,*0) <-READCH(*X,*0) & /. /* GT */ READ_ONCE(*X,*0) <-READ(*X,*0) & /. /* GT */ /* P r o m p t s a nd s u c c e e d s on an a f f i r m a t i v e a n s w e r V YESNO <-READ_ONCE( *R, '*MSOURCE* ' ) & A F F I R M A T I V E ( * R ) & /. /* GT */ A F F I R M A T I V E ( y e s ) . A F F I R M A T I V E ( Y E S ) . A F F I R M A T I V E ( Y e s ) . A F F I R M A T I V E ( Y ) . A F F I R M A T I V E ( y ) . H U t i l i t i e s f o r RCPS I n t e r p r e t e r 1 25 AFFIRMATIVE(OK). AFFIRMATIVE(ok). /* Circumvents a problem with MTS PROLOG */ A D D ( * X , * Y , * Z ) < - D I F F ( 0 , * Y , * Y 1 ) Sc D I F F ( * X , * Y 1 , * Z ) . SPY(*P) <-GEN_SPY_AX(*P,*A) Sc (AX(*P,*A) Sc PRINT(' There i s a l r e a d y a spy point on '.*P,SERCOM) | (ADDAX(*A,1) Sc PRINTC Spy point e s t a b l i s h e d on ' . *P, SERCOM))) & /• NOSPY(*P) <-GEN_SPY_AX( *P,*A) Sc (DELAX ( *A) Sc PRINT(' Spy po i n t removed from '.*P,SERCOM) | PRINT(' There i s no spy p o i n t on '.*P,SERCOM)) & /• GEN SPY AX(*P,*P<-"'ANCESTOR(BUG(*,*) , 4 ) Sc/ScBUG ( *P , * I ) ) . BUG(*P,*I ) <-INDENT(*l) Sc STRING(*S, *I ) Sc PRINT(*S.'Entering '.*P,SERCOM) S< (*P | (PRINT(*S.'Failed '.*P,SERCOM) S< FAIL) ) Sc (PRINT(*S.'Exiting '.*P,SERCOM) | (PRINT(*S.'Redo '.*P,SERCOM) S< FAIL) ) . INDENT(' ' .*I ) <-ANCESTOR(BUG(*,*I),*X) Sc GT(*X,2) & /. INDENT( ' ' .NIL). H U t i l i t i e s f o r RCPS I n t e r p r e t e r 126 M A P ( * P , * F . * R ) <-/ & C O N S ( * P . * - F . N I L , * X ) & * X & M A P ( * P , * R ) . M A P ( * P , * 0 ) < - C O N S ( * P . * O . N I L , * X ) & * X . s i g 

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            data-media="{[{embed.selectedMedia}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
https://iiif.library.ubc.ca/presentation/dsp.831.1-0051845/manifest

Comment

Related Items