Open Collections

UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

A procedural model of recognition for machine perception Havens, William S. 1978

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_1978_A1 H39.pdf [ 10.45MB ]
Metadata
JSON: 831-1.0051790.json
JSON-LD: 831-1.0051790-ld.json
RDF/XML (Pretty): 831-1.0051790-rdf.xml
RDF/JSON: 831-1.0051790-rdf.json
Turtle: 831-1.0051790-turtle.txt
N-Triples: 831-1.0051790-rdf-ntriples.txt
Original Record: 831-1.0051790-source.json
Full Text
831-1.0051790-fulltext.txt
Citation
831-1.0051790.ris

Full Text

A PROCEDUEAL MODEL OF RECOGNITION FOR MACHINE PERCEPTION by WILLIAM S. HAVENS M.Sc, V i r g i n i a P o l y t e c h n i c I n s t i t u t e , 1973 B.Sc., V i r g i n i a P o l y t e c h n i c I n s t i t u t e , 1969 A THESIS SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY i n 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 March, (c) W i l l i a m S. BRITISH COLUMBIA 1978 Havens, 197 8 In p r e s e n t i n g t h i s t h e s i s in p a r t i a l f u l f i l m e n t o f t h e r equ i rement s f o r an advanced degree at 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 , I a g r e e 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 s t u d y . 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 c o p y i n g 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 g r a n t e d by the Head o f my D e p a r t m e n t o r by h i s r e p r e s e n t a t i v e s . It i s u n d e r s t o o d that c o p y i n g 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 a l l o w e d w i thout my w r i t t e n p e r m i s s i o n . Department The U n i v e r s i t y o f B r i t i s h Co lumbia 2075 W e s b r o o k P l a c e V a n c o u v e r , C a n a d a V6T 1W5 i i A b s t r a c t T h i s t h e s i s i s concerned with aspects of a theory of machine p e r c e p t i o n . I t i s shown that a comprehensive theory i s emerging from r e s e a r c h i n computer v i s i o n , n a t u r a l language understanding, c o g n i t i v e psychology, and A r t i f i c i a l I n t e l l i g e n c e programming language technology. A number o f aspects c f machine p e r c e p t i o n are c h a r a c t e r i z e d . P e r c e p t i o n i s a r e c o g n i t i o n process which composes new d e s c r i p t i o n s of sensory experience i n terms of s t o r e d s t e r e o t y p i c a l knowledge c f the world. P e r c e p t i o n r e g u i r e s both a schema-based formalism f o r the r e p r e s e n t a t i o n of knowledge and a model of the processes necessary f o r performing s e a r c h and deduction on that r e p r e s e n t a t i o n . As an approach towards the development of a theory of machine p e r c e p t i o n , a computational model of r e c o g n i t i o n i s presented. The s i m i l a r i t y of the model t o formal mechanisms i n p a r s i n g theory i s d i s c u s s e d . The r e c o g n i t i o n model i n t e g r a t e s top-down, h y p o t h e s i s - d r i v e n search with bottcm-up, d a t a - d r i v e n search i n h i e r a r c h i c a l schemata r e p r e s e n t a t i o n s . H e u r i s t i c procedural methods are a s s o c i a t e d with p a r t i c u l a r schemata as models t o guide t h e i r r e c o g n i t i o n . M u l t i p l e methods may be a p p l i e d c o n c u r r e n t l y i n both top-down and bottom-up search modes. The implementation of the r e c o g n i t i o n model as an A r t i f i c i a l I n t e l l i g e n c e programming language c a l l e d MAYA i s d e s c r i b e d . MAYA i s a m u l t i p r o c e s s i n g i i i d i a l e c t of LISP t h a t p r o v i d e s data s t r u c t u r e s f o r r e p r e s e n t i n g schemata networks and c o n t r o l s t r u c t u r e s f o r i n t e g r a t i n g top-down and bottom-up p r o c e s s i n g . A c h a r a c t e r i s t i c example from scene a n a l y s i s , w r i t t e n i n MAYA, i s presented t o i l l u s t r a t e the o p e r a t i o n of the model and the u t i l i t y of the p r o g r a m i n g language. A programming r e f e r e n c e manual f o r MAYA i s i n c l u d e d . F i n a l l y , a p p l i c a t i o n s f o r both the r e c o g n i t i o n model and MAYA are d i s c u s s e d and some premising d i r e c t i o n s f o r f u t u r e research proposed. i v TABLE OF CONTENTS 1: I n t r o d u c t i o n 1 2: Mechanisms f o r Machine P e r c e p t i o n 5 2.1 I n t r o d u c t i o n 5 2.2 A r t i f i c i a l I n t e l l i g e n c e and Psychology 6 2.3 Programming Languages 8 2.4 Representation o f Knowledge 11 2.4.1 L o g i c a l R e p r e s e n t a t i o n s 11 2.4.2 The P r o c e d u r a l Reformation 13 2.4.3 Schemata 14 2. 4. 4 Search .. . ... 17 2.5 Machine V i s i o n 23 2.5.1 Roberts' Paradigm 23 2.5.2 Guzman's SEE 26 2.5.3 Huffman and Clowes 28 2.5.4 Waltz's Algorithm ...29 2.5.5 Mackworth's MAPSEE 32 2.5.6 Freuder's SEER 35 3: A Procedural Model 39 3.1 I n t r o d u c t i o n 39 3.2 Model Overview 39 3.2.1 Schemata . .. 40 3.2.2 Schema H i e r a r c h i e s ................................ 42 3.2.3 Recognizers 49 3.2.4 Non-Determinism 51 3.2. 5 Recursion 55 3.3 E a r l e y ' s Algorithm 56 3.4 Three Phases of R e c o g n i t i o n ........................... 61 3.4.1 E x p e c t a t i o n 61 3.4.2 Matching 63 3.4.3 Completion 64 3.5 Sc h e d u l i n g , f 68 3.6 Method H i e r a r c h i e s 71 3.7 C o o r d i n a t i o n and Communication 74 3.8 I n t e g r a t i o n 75 4: An Example from Machine V i s i o n 78 4.1 P e r s p e c t i v e 78 4.2 The Problem 79 4.3 Annotated P r o t o c o l 88 4.4 Co n c l u s i o n 114 5: Maya 115 5.1 I n t r o d u c t i o n ......................................... 115 5.2 Language Overview 116 5.2.1 Data Types ... 116 5.2.2 E v a l u a t i o n 120 5.3 Repre s e n t a t i o n 122 5.3. 1 Schemata 122 5.3.2 Messages 126 V 5.4 P a t t e r n Hatching ..................................... 130 5.5 Top-down Methods 132 5.6 Bottom-up Methods 137 5.7 C o n c l u s i o n ........................................... 141 6: Recognition R e v i s i t e d ................................... 142 6.1 P e r s p e c t i v e 142 6.2 Rec o g n i t i o n R e v i s i t e d 142 6.3 A p p l i c a t i o n s and Future Research ..................... 151 B i b l i o g r a p h y 153 Appendix-A: E a r l e y ' s P a r s i n g Algorithm 160 Appendix-B: MAYA Language Reference Manual ................. 164 B.1 R e l a t i n g t o MAYA 164 B.2 The Database 166 B.3 E v a l u a t i o n 171 B.4 E r r o r C o n d i t i o n s and the DEBUG System 173 B.5 Input/Output ......................................... 177 B.6 P a t t e r n Matching 178 B.7 Generators 183 B.8 Processes and Recognizers 186 Appendix C: Example Program L i s t i n g 188 v i LIST OF FIGURES 3.1: A B i c y c l e Schema ..... 41 3.2: E i c y c l e Composition Hierarchy .. 44 3.3: Indexed Instance H i e r a r c h y 48 3.4: Rec o g n i t i o n C y c l e s 66 4.1: Scene Composition Hierarchy 80 4.2: Input Scene 83 4.3: Vertex Instance Hierarchy 84 4.4a: Vertex Schemata 85 4.4b: L i n e Schemata . .85 4.5: Vertex L a b e l l i n g Conventions 87 4.6: Rec o g n i t i o n of a fledge 89 6.1: P e r c e p t u a l C y c l e s 148 A.1: The P r e d i c t o r Function 162 A.2: The Scanner F u n c t i o n 162 A.3: The Completer Function 162 Acknowle dcements "When a pickpocket meets a holy man. A l l he sees i s h i s pockets." Anonymous I would l i k e to thank my d o c t o r a l cemmittee f o r t h e i r i n v a l u a b l e guidance and p e r s p e c t i v e , Rachel G e l b a r t , Gordon McCalla, Michael Kuttner, P e t e r Rowat, Jan Mulder, and Boger Browse f o r many h e l p f u l d i s c u s s i o n s and c r i t i c i s m s , Marian fiackworth f o r p r o o f r e a d i n g t h i s t h e s i s , my housemates f o r t h e i r comraderie, t o l e r a n c e , and understanding, e s p e c i a l l y Richard Rosenberg and S h e r y l Adam f o r p r o v i d i n g accomodation and t r a n s p o r t a t i o n , my dear f r i e n d L. B. Fl o y d f o r many i n s i g h t s and h i s f a i t h f u l companionship, and above a l l , Alan Mackworth f o r s u p e r v i s i n g my r e s e a r c h , s h a r i n g my enthusiasm, and p r o v i d i n g the c o n s t a n t support and f a i t h of a f r i e n d . T h i s r e s e a r c h was supported by a Postgraduate S c h o l a r s h i p from the U n i v e r s i t y of B r i t i s h Columbia and a Research A s s i s t a n t s h i p from the Department of Computer Science. 1 CHAPTER 1: INTRODUCTION The c r e a t i o n o f i n t e l l i g e n t automata has been a compelling dream of mankind f o r m i l l e n n i a . Each advancement i n the s o p h i s t i c a t i o n of our technology has been seen as a new t o o l f o r the understanding of o u r s e l v e s . H y d r a u l i c s , clockworks, the steam engine, and the telephone switchboard have each, i n t h e i r time, been metaphors, taken as t h e o r i e s of the f u n c t i o n i n g of the mind (Rapoport, 1963). Only i n the l a s t few y e a r s , however, with the i n v e n t i o n o f the von Neumann d i g i t a l computer has the r e a l i z a t i o n of i n t e l l i g e n t machines been a s e r i o u s p o s s i b i l i t y . Such a p o s s i b i l i t y , encouraged by the e a r l y successes of Samuel (1963), G e l e r n t e r (1963), Newell and Simon (1963), and o t h e r s , c r e a t e d high e x p e c t a t i o n s . U n f o r t u n a t e l y , these e x p e c t a t i o n s have been maddeningly d i f f i c u l t to r e a l i z e . In p a r t i c u l a r , we do not yet have an adequate theory of p e r c e p t i o n as p a r t cf an o v e r a l l theory of machine i n t e l l i g e n c e . However, as Mackworth (1977c) p o i n t s out, elements o f such a theory are emerging. T h i s t h e s i s i s concerned with aspects of t h i s developing theory of machine p e r c e p t i o n . T h i s work i s motivated by the b e l i e f t h a t p e r c e p t i o n can be c h a r a c t e r i z e d as a r e c o g n i t i o n process guided by plans and e x p e c t a t i o n s and d r i v e n by o b s e r v a t i o n and experience. A theory of machine p e r c e p t i o n i s seen as having two major p a r t s - a formalism f o r the r e p r e s e n t a t i o n of knowledge and a model of the processes and 1: I n t r o d u c t i o n 2 c o n t r o l s t r u c t u r e s r e q u i r e d to perform search and deduction on t h a t r e p r e s e n t a t i o n . The d i s t i n c t i o n between r e p r e s e n t a t i o n and process i s emphasized i n order t o p o i n t out an aspect of machine p e r c e p t i o n t h a t has not been s u f f i c i e n t l y developed. Presented i n t h i s t h e s i s i s a p r o c e d u r a l model of r e c o g n i t i o n f o r p e r c e p t i o n . The model i s intended as a computational paradigm f o r p e r c e p t i o n r e s e a r c h and i s based on the f c l l c w i n q c h a r a c t e r i z a t i o n of p e r c e p t i o n . P e r c e p t i o n i s a r e c o q n i t i o n process t h a t composes new d e s c r i p t i o n s of observed experience i n terms of s t o r e d s t e r e o t y p i c a l d e s c r i p t i o n s o f the world. The new knowledqe c r e a t e d i n t h i s process i s a b s t r a c t and r e l a t i o n a l , the formation of the d e s c r i p t i o n o f a p e r c e i v e d concept. P e r c e p t i o n i s seen t o e x p l o i t the s e q u e n t i a l nature of everyday experience by assuminq c a u s a l r e l a t i o n s h i p s among events and o b s e r v a t i o n s . P e r c e p t i o n i s a n o n - d e t e r m i n i s t i c process. Our sensory experience of the world can be ambiguous and o f t e n i l l u s o r y . L i k e w i s e , the knowledge by which we i n t e r p r e t sensory experience i s incomplete and o f t e n erroneous. Yet p e r c e p t i o n operates i n t h i s u n c e r t a i n environment. The p e r c e p t u a l process must t o l e r a t e non-determinacy by e x p l o i t i n q context and a l l o w i n q m u l t i p l e p a r t i a l i n t e r p r e t a t i o n s to be hypothesized and t h e i r c o n f i r m a t i o n attempted c o n c u r r e n t l y . P e r c e p t i o n i s both an a c t i v e process quided by hypothesis and e x p e c t a t i o n and a passive process d r i v e n by events and sensory o b s e r v a t i o n . Observations act as cues which s t i m u l a t e 1: I n t r o d u c t i o n 3 both the formation of hypotheses and the a c t i v a t i o n of h e u r i s t i c knowledge a s s o c i a t e d with s p e c i f i c hypotheses. Such h y p o t h e s i s - s p e c i f i c knowledge i s used to d i r e c t the r e c o g n i t i o n process by making o b s e r v a t i o n s , c r e a t i n g new e x p e c t a t i o n s , and attempting to s a t i s f y those e x p e c t a t i o n s . P e r c e p t i o n i s a l s o a r e c u r s i v e process. Cues are not s o l e l y p r i m i t i v e o b s e r v a t i o n s but may be, in f a c t , the r e s u l t of p e r c e p t i o n . The p e r c e p t u a l process uses the d e s c r i p t i o n of some s u c c e s s f u l l y p e r c e i v e d concept as an a b s t r a c t cue i n the pe r c e p t i o n of hig h e r concepts. As an approach towards a theory o f machine p e r c e p t i o n , a p r o c e d u r a l model i s presented based on these c h a r a c t e r i z a t i o n s . The model p r o v i d e s an i n t e g r a t i o n of top-down, h y p o t h e s i s - d r i v e n search with bottom-up, d a t a - d r i v e n search i n h i e r a r c h i c a l , schema-based knowledge r e p r e s e n t a t i o n s . The model d e f i n e s e x p l i c i t mechanisms f o r employing r e c u r s i v e cue/model h i e r a r c h i e s i n p e r c e p t i o n . H e u r i s t i c procedures, c a l l e d methods, are used to guide the r e c o g n i t i o n process. Methods are a s s o c i a t e d with s p e c i f i c s t e r e o t y p i a l schemata to d r i v e the r e c o g n i t i o n of i n s t a n c e s o f those schemata. Methods may be a p p l i e d i n both top-down and bottorn-up search modes and a number of methods may be a c t i v e s i m u l t a n e o u s l y . The model d e f i n e s mechanisms of communication and c o o r d i n a t i o n between concurrent methods and a l s o d e f i n e s a deductive method-scheduling technique based on the n o t i o n of computing a method's a p p l i c a b i l i t y to the p e r c e p t i o n process. 1: I n t r o d u c t i o n 4 As an implementation of the p e r c e p t i o n model, a programming language c a l l e d Maya has been developed. T h i s programming language i s designed as a m u l t i p r o c e s s i n g d i a l e c t of LISP and provides data s t r u c t u r e s f o r c o n s t r u c t i n g , manipulating, and a c c e s s i n g schemata-based knowledge r e p r e s e n t a t i o n s . As w e l l , Maya d e f i n e s c o n t r o l p r i m i t i v e s f o r i n t e g r a t i n g top-down and bottom-up p r o c e s s i n g . The language a l s o p r o v i d e s mechanisms f o r c r e a t i n g and s c h e d u l i n g processes d e d u c t i v e l y and f o r c o o r d i n a t i n g the i n t e r a c t i o n o f processes. In p r e s e n t i n g the model of r e c o g n i t i o n and i t s implementation, the t h e s i s takes the f o l l o w i n g form: Chapter 2 reviews the c o n t r i b u t i o n s of r e c e n t r e s e a r c h to the e v o l u t i o n of a computational theory of p e r c e p t i o n . Examined are s p e c i f i c r e p r e s e n t a t i o n a l t h e o r i e s , programming languages, and p e r c e p t i o n programmes. Chapter 3 p r e s e n t s the p r o c e d u r a l r e c o g n i t i o n model i n d e t a i l . Chapter 4 presents a sma l l but c h a r a c t e r i s t i c example from computer v i s i o n to i l l u s t r a t e the b e n e f i t s of the model and to demonstrate the u t i l i t y of Maya as a programming language. Chapter 5 p r o v i d e s an overview of the design of Maya, a d e s c r i p t i o n of i t s f e a t u r e s , and a small t u t o r i a l on Maya programming s t y l e . Chapter 6 re-examines other r e l e v a n t 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 from the p e r s p e c t i v e of the p r o c e d u r a l model presented here. The rele v a n c e of t h i s work to the study of machine p e r c e p t i o n i s i n v e s t i g a t e d and suggestions are given as to the p o s s i b l e d i r e c t i o n s of f u t u r e r e s e a r c h . 1: I n t r o d u c t i o n 5 £111111 2: MECHANISMS FOR MACHINE PERCEPTION 2.1 I n t r o d u c t i o n I f the dream of i n t e l l i g e n t automata i s to be r e a l i z e d , there must e x i s t a body of und e r l y i n g p r i n c i p l e s from which these machines w i l l be b u i l t . The disc o v e r y of t h i s body of knowledge w i l l have a profound e f f e c t on mankind. I t s p r i n c i p l e s w i l l be manifest i n mathematics, psychology, computer s c i e n c e , l i n g u i s t i c s , philosophy, and a l l other branches of s c i e n c e concerned with human reasoning. I t s u l t i m a t e i m p l i c a t i o n s f o r our s o c i e t y w i l l be f e l t i n now unimaginable ways. An apparent convergence of ideas about the o r g a n i z a t i o n of memory, the understanding of language, the r e p r e s e n t a t i o n of knowledge, and the machine p e r c e p t i o n of v i s u a l images suggests t h a t there must e x i s t computational mechanisms governing p e r c e p t i o n . The f a c t t h a t s i m i l a r mechanisms are being i n v e s t i g a t e d i n the f i e l d s of c o g n i t i v e psychology, a r t i f i c i a l i n t e l l i g e n c e , and l i n g u i s t i c s i n d i c a t e s t h a t these u n d e r l y i n g p r i n c i p l e s may r e s i d e not too f a r from the s u r f a c e of our present knowledge. In t h i s chapter, a review of some evidence from r e c e n t r e s e a r c h s u p p o r t i n g t h i s view i s presented, 2: Mechanisms f o r Machine Pe r c e p t i o n 6 2.2 A r t i f i c i a l I n t e l l i g e n c e and Psychology Both c o g n i t i v e psychology and a r t i f i c i a l i n t e l l i g e n c e are concerned with understanding the mechanisms of p e r c e p t i o n . The computer has given p s y c h o l o g i s t s both an i n f o r m a t i o n processing metaphor f o r v i s u a l i z i n g c o g n i t i v e mechanisms and a l a b o r a t o r y i n which t o experiment with these mechanisms. In exchange, t h e i r experiments have given a r t i f i c i a l i n t e l l i g e n c e a t e s t of the v a l i d i t y of our computational mechanisms as a theory of human p e r c e p t i o n . The approach of many r e s e a r c h e r s (Bumelhart 8 Norman, 1973} ( C o l l i n s 5 Q u i l l i a n , 1972) (Newell & Simon, 1972) has been t o propose an i n f o r m a t i o n - p r o c e s s i n g model of some p a r t i c u l a r aspect o f p e r c e p t i o n , memory, or l e a r n i n g ; then to compare the b e h a v i o u r a l adequacy of the computer s i m u l a t i o n to the behaviour of human s u b j e c t s given the same task. A s i g n i f i c a n t e a r l y example of t h i s approach i s the GPS model of human problem s o l v i n g (Newell,1963). The model uses a simple "baclc-chaining" scheme of breaking a problem down i n t o s m a l l e r and s m a l l e r sub-problems u n t i l progress on some sub-problem can be made. Another example i s the EPAM model of v e r b a l l e a r n i n g developed by Feigenbaum (1963). The model uses a d i s c r i m i n a t i o n t r e e as an a s s o c i a t i v e memory f o r nonsense s y l l a b l e s . At each node i n the t r e e , o n l y s u f f i c i e n t i n f o r m a t i o n i s r e t a i n e d to perform a bin a r y d i s c r i m i n a t i o n t e s t a t the time the node i s c o n s t r u c t e d . As more nonsense s y l l a b l e s are added to the 2: Mechanisms f o r Machine P e r c e p t i o n 7 network, the t e s t becomes i n s u f f i c i e n t f o r proper d i s c r i m i n a t i o n . T h i s l e a d s t o such r e t r i e v a l e r r o r s as a f a i l u r e t o respond to a s t i m u l u s , c o n f u s i o n between s i m i l a r s t i m u l i , and o s c i l l a t i o n between c o r r e c t and i n c o r r e c t responses. An important c o n t r i b u t i o n to the development of machine r e p r e s e n t a t i o n s of knowledge i s Q u i l l i a n ' s (1968) p r o p o s a l of semantic networks as a model of human memory. H i s work models memory as an a r c - l a b e l l e d d i r e c t e d graph s t r u c t u r e i n which nodes r e p r e s e n t a r b i t r a r y concepts and a r c s r e p r e s e n t typed b i n a r y r e l a t i o n s h i p s between concepts. The meaning of a concept i n the network i s c o n s i d e r e d to be the e n t i r e network as viewed from the concept node. As a r e p r e s e n t a t i o n scheme f o r machine p e r c e p t i o n , semantic nets have an appealing property. The meaning of a concept i s not represented as a s e t of i s o l a t e d f a c t s , but as an en c y c l o p e d i c network of r e l a t i o n s h i p s with other concepts. Although t h i s r e p r e s e n t a t i o n i s extremely r i c h i n i t s s t r u c t u r e , Hoods (1975) has analyzed t h e s e r e l a t i o n s h i p s and p o i n t s cut a number of problems and misconceptions. R e c e n t l y , Schubert (1975) has extended the r e p r e s e n t a t i o n a l power of semantic networks t o i n c o r p o r a t e l o g i c a l q u a n t i f i e r s and c o n n e c t i v e s . Hendrix (1975) a l s o has augmented the r e p r e s e n t a t i o n with a p a r t i t i o n i n g mechanism t o i n c o r p o r a t e g u a n t i f i c a t i o n and h y p o t h e t i c a l s i t u a t i o n s . Q u i l l i a n ' s o r i g i n a l r e s e a r c h and the mere rec e n t work of 2: Mechanisms f o r Machine P e r c e p t i o n 8 C o l l i n s and L o f t u s (1975) have modelled human memory search as a p a r a l l e l spreading a c t i v a t i o n process i n a semantic network. From two concept nodes, the search proceeds i n a b r e a d t h - f i r s t manner to each of t h e i r neighbours u n t i l a path i n t e r s e c t i o n occurs. The types o f arcs t r a v e r s e d during the search are supposed t o rep r e s e n t the semantic r e l a t i o n s h i p between the two concepts. 2.3 Programming Languages A number of a r t i f i c i a l i n t e l l i g e n c e programming languages suggest aspects of a computational theory. These languages i n c l u d e both a scheme f o r r e p r e s e n t i n g knowledge and a c o n t r o l s t r u c t u r e scheme f o r o p e r a t i n g on that r e p r e s e n t a t i o n . The most popular such language has been the p a r t i a l implementation of Hewitt*s (1972) Planner language, c a l l e d M icro-Planner (Sussman, 1973). Hewitt's language p r o v i d e s a p r o c e d u r a l r e a l i z a t i o n of an incomplete h i g h e r - o r d e r l o g i c system. In Planner, f a c t s are represented d e c l a r a t i v e l y as n-tuple p a t t e r n s i n a g l o b a l a s s o c i a t i v e database and as procedures, c a l l e d theorems, a s s o c i a t e d with p a t t e r n s . The language r e l i e s on three mechanisms: a s s o c i a t i v e database r e t r i e v a l , p a t t e r n - d i r e c t e d procedure i n v o c a t i o n , and an automatic b a c k t r a c k i n g c o n t r o l s t r u c t u r e . The best implementation of the o r i g i n a l Planner proposal i s the Pop l e r language w r i t t e n i n Pop-2 by Davies (1973) at Edinburgh. 2: Mechanisms f o r Machine P e r c e p t i o n 9 The u t i l i t y of the Planner paradigm was demonstrated by Hinograd (1973a). However, as has been pointed out (Sussman S McDermott, 1972) (Hayes, 1973), there are s e r i o u s problems, most n o t a b l y the l a c k of a p r e c i s e r e p r e s e n t a t i o n a l semantics and the dependence on automatic b a c k t r a c k i n g f o r g e n e r a t i n g a l t e r n a t i v e s o l u t i o n paths i n a uniform and exhaustive d e p t h - f i r s t manner. Backtracking r e v e r s e s the s i d e - e f f e c t s of any r e j e c t e d a l t e r n a t i v e s . The f a c t t h a t each a l t e r n a t i v e at a d e c i s i o n p o i n t i s t r e a t e d independently i s the source o f the d i f f i c u l t y . No communication between competing a l t e r n a t i v e s o l u t i o n s i s p o s s i b l e . Consequently, nothing i s le a r n e d from f a i l u r e s . The problem i s f u r t h e r aggravated by the intended modularity of the p a t t e r n - i n v o k e d Planner theorems. The language attempts t c use a l l theorems matching a given p a t t e r n t o achieve some go a l or subgoal u n t i l one succeeds. However, each theorem i s considered to be a modular method alone capable of a c h i e v i n g the goal. Each theorem i s independent of a l l others and, as a r e s u l t , each theorem i s e f f e c t i v e l y i g n o r a n t of the e f f o r t s and methods of every other. HcDermott and Sussman (1973), i n an attempt to s o l v e these problems, designed and implemented a s u c c e s s o r programming language, Conniver. The language supports m u l t i p r o c e s s i n g by u s i n g the c o n t r o l s t r u c t u r e model suggested by Bobrow and Wegbreit (1973). Conniver provides n e i t h e r automatic b a c k t r a c k i n g nor automatic r e s t o r a t i o n of v a r i a b l e s . Changes made to the database normally remain changed u n l e s s s p e c i f i c a l l y 2: Mechanisms f o r Machine P e r c e p t i o n 10 r e s t o r e d by the programmer. T h i s m o d i f i c a t i o n permits communication among " s i s t e r " processes e x p l o r i n g a l t e r n a t i v e s o l u t i o n s to a problem. Each process may c o n s u l t the database to d i s c o v e r the r e s u l t s of her s i b l i n g s . In order t o permit processes to use h y p o t h e t i c a l s i t u a t i o n s , Conniver provides a l a y e r e d context mechanism. Any process may request a separate, experimental copy of the database. Any changes made to t h i s new copy are not v i s i b l e e x t e r n a l to the c o n t e x t . As p r e v i o u s l y mentioned, Conniver does not depend on automatic b a c k t r a c k i n q to qenerate a l t e r n a t i v e s . I n s t e a d , i t d e f i n e s a c o - r o u t i n e mechanism c a l l e d generators which are procedures t h a t can maintain an i n t e r n a l s t a t e between i n v o c a t i o n s . Generators may r e t u r n m u l t i p l e values i n a communication port c a l l e d a p o s s i b i l i t i e s l i s t . Instead of being embedded w i t h i n an automatic b a c k t r a c k i n g c o n t r o l s t r u c t u r e , a l t e r n a t i v e s are e x p l i c i t l y r e p r e s e n t e d as data items i n the p o s s i b i l i t i e s l i s t . Conniver a l s o provides p r i m i t i v e s f o r manipulating the p o s s i b l i t i e s l i s t and r e c a l l i n g generators. Conniver's authors intended to improve AI programming language technology by r e p a i r i n g some of the problems encountered i n the use o f Micro-Planner. Conniver has a l s o provided some r e p r e s e n t a t i o n a l mechanisms d e c i d e d l y more powerful and f l e x i b l e than those r e a l i z e d i n Micro-Planner. Conniver permits the r e p r e s e n t a t i o n of h y p o t h e t i c a l worlds and a l l o w s a r b i t r a r y p r o p e r t i e s t o be a s s o c i a t e d with p a t t e r n s . In the next chapter, the u t i l i t y of t h i s l a s t mechanism w i l l be 2: Mechanisms f o r Machine Percep t i o n 11 i n v e s t i g a t e d . Conniver does not propose a model of computation i n i t s d e s i g n . In f a c t , i t d e f e a t s the p r i m i t i v e model of Micro-Planner. However, the language does support the c r e a t i o n and manipulation o f m u l t i p l e processes thus p r o v i d i n g a c a p a b i l i t y , i f not the f a c i l i t y , f o r using bottom-up search mechanisms. A second c o n t r i b u t i o n of Conniver i s i t s use c f the p o s s i b i l i t i e s l i s t t o r e p r e s e n t processes as data s t r u c t u r e s to be manipulated by other processes. A very r e c e n t programming language, KRL-0, has been proposed by Bobrow and Winograd (1977). They e x p l i c i t l y propose a model of r e c o g n i t i o n f o r machine p e r c e p t i o n based on a schematic r e p r e s e n t a t i o n and a n o t i o n of schema matching. KRL w i l l be d i s c u s s e d i n more d e t a i l i n the next s e c t i o n . 2.4 Representation o f Knowledge S u i t a b l e mechanisms f o r the computer r e p r e s e n t a t i o n of knowledge are a trajor aspect of a theory of machine p e r c e p t i o n . The search f o r r e p r e s e n t a t i o n s e x h i b i t i n g d e s i r a b l e p r o p e r t i e s f o r p e r c e p t i o n has been ah important r e s e a r c h e f f o r t . 2.4.1 L o g i c a l Representations F i r s t - o r d e r p r e d i c a t e c a l c u l u s has been advocated by many as a computational paradigm f o r A r t i f i c i a l I n t e l l i g e n c e 2: Mechanisms f o r Machine P e r c e p t i o n 1 2 (HcCarthy S Hayes, 1969) (Green, 1969) . P r e d i c a t e c a l c u l u s o f f e r s the advantages of both a completely modular r e p r e s e n t a t i o n and a p r e c i s e and formal semantics. , A l l knowledge i s represented f a c t u a l l y and i s s p e c i f i c a l l y d i v o r c e d from the proof procedures used t o perform search on that r e p r e s e n t a t i o n . A number of proof procedures have been advocated, most notably the r e s o l u t i o n p r i n c i p l e of Robinson (1965). For the most p a r t , t h e s e proof procedures are s y n t a c t i c mechanisms u t i l i z i n g a uniform i n t e r p r e t e r . There i s no g e n e r a l concept of process and c o n t r o l i n h e r e n t i n the l o g i c system i t s e l f . A number of s t r a t e g i e s have been proposed f o r c o n t r c l l i n g the search process i n p r e d i c a t e c a l c u l u s systems, i n c l u d i n g dynamic pruning of the search space and a t t a c h i n g d o m a i n - s p e c i f i c h e u r i s t i c procedures t o axioms cf the system. R e i t e r (1973) has advocated the use of a model t o r e s t r i c t the search space and to g i v e a d v i c e t o the proof procedure. A number of r e s e a r c h e r s have advocated p r e d i c a t e c a l c u l u s as a programming language (Kowalski, 1974) (VanEmden, 1977). In most implementations, a uniform proof procedure i s used as the c o n t r o l s t r u c t u r e model f o r the programming language. In an attempt to i n t r o d u c e l o g i c a l semantics i n t o the c o n t r o l mechanism, Hayes (1973) i s d e f i n i n g a language of c o n t r o l s t r u c t u r e o p e r a t o r s d e d u c i b l e by the l o g i c system during e x e c u t i o n . These e f f o r t s p o i n t to the need to have the deductive 2: Mechanisms f o r Machine P e r c e p t i o n 13 process guided by semantic knowledge i n s t e a d of r e l y i n g on a uniform s y n t a c t i c procedure. What i s r e q u i r e d i s an i n t e g r a t i o n of the r e p r e s e n t a t i o n with a model of c o n t r o l and process. 2.4.2 The P r o c e d u r a l Reformation The problems observed i n the purely l o g i c a l formalism have giv e n impetus to t h e development of a p r o c e d u r a l formalism f o r r e p r e s e n t i n g knowledge. as i n any s e r i o u s r e f o r m a t i o n , two competing s c h o o l s , the p r o c e d u r a l i s t s and the d e c l a r a t i v i s t s , q u i c k l y d e l i n e a t e d t h e i r r e s p e c t i v e p o i n t s of view thereby r a d i c a l i z i n g those p o s i t i o n s . , a d e t a i l e d d i s c u s s i o n of these p o s i t i o n s i s o u t l i n e d by Winograd (1975). The p r o c e d u r a l i s t s contend that knowledge i s best represented i n procedures. T h e i r argument i s that a l a r g e p a r t of man's knowledge of the world i s knowledge of process -knowing "how" i n s t e a d o f a f a c t u a l knowing "what". The Actor formalism of Hewitt (1973) d e f i n e s the extreme of t h i s p o i n t of view. Hewitt s t a t e s t h a t h i s resea r c h i s d i r e c t e d a t p u t t i n g semantics on a f i r m p r o c e d u r a l b a s i s . The knowledge of some e n t i t y i s the behavior e x h i b i t e d by the procedure r e p r e s e n t i n g t h a t e n t i t y . Access to i n f o r m a t i o n i n an a c t o r i s permitted o n l y by sending the a c t o r a message which i t i n t e r p r e t s by i t s own means. The formalism can a l t e r n a t i v e l y be viewed as the d e c e n t r a l i z a t i o n of the system i n t e r p r e t e r among the data o b j e c t s of the system. A c t o r s are a g e n e r a l i z a t i o n c f the 2: Mechanisms f o r Machine P e r c e p t i o n 14 formal notion of c l a s s e s and o b j e c t s introduced i n the Simula programming language (Dahl, 1966). I t seems c l e a r t h a t method and process i n g e n e r a l are best expressed p r o c e d u r a l l y because temporal r e l a t i o n s h i p s are handled a u t o m a t i c a l l y by the s e q u e n t i a l nature of the r e p r e s e n t a t i o n . Procedures provide a n a t u r a l way to s p e c i f y i n t e r a c t i o n s as o p e r a t i o n s and they are convenient f o r r e p r e s e n t i n g higher order knowledge. Winograd (1975) p o i n t s out a d u a l i t y between the modularity of d e c l a r a t i v e r e p r e s e n t a t i o n s and the i n t e r a c t i o n i n h e r e n t i n p r o c e d u r a l r e p r e s e n t a t i o n s . From the d e c l a r e d g o a l c f developing a computational theory of p e r c e p t i o n , t h a t same d u a l i t y can be seen as the d i s t i n c t i o n between a theory of r e p r e s e n t a t i o n - the d e c l a r a t i v e a s p e c t , and a theory of r e c o g n i t i o n - the p r o c e d u r a l aspect. what i s needed i s an i n t e g r a t i o n of the modularity of a d e c l a r a t i v e r e p r e s e n t a t i o n with the i n t e r a c t i o n s that are s p e c i f i a b l e i n a p r o c e d u r a l r e p r e s e n t a t i o n . That i n t e g r a t i o n cannot be a simple c o n c a t e n a t i o n of technigues. I n s t e a d , there must be a s y n t h e s i s t h a t r e s p e c t s the i n h e r e n t d u a l i t y between r e p r e s e n t a t i o n and r e c o g n i t i o n , between form and process. 2.4.3 Schemata Within the l a s t few years, r e s e a r c h i n t o s u i t a b l e r e p r e s e n t a t i o n s of knowledge i n such d i v e r s e f i e l d s as human memory re s e a r c h (Bobrow & Norman, 1975) (Pylyshyn, 1976), 2: Mechanisms f o r fiachine P e r c e p t i o n 15 l i n g u i s t i c s ( F i l l m o r e , 1968), and a r t i f i c i a l i n t e l l i g e n c e (Minsky, 1975) (Bobrow 6 Winograd, 1977) has l e d towards the convergent notio n o f schemata. The term i s a t t r i b u t a b l e to the work of B a r t l e t t (1932), although the concept has now been r e d i s c o v e r e d under v a r i o u s names with many i n c a r n a t i o n s . A g e n e r a l c h a r a c t e r i z a t i o n of schemata i n c l u d e s the f o l l o w i n g aspects. Schemata are data s t r u c t u r e s f o r r e p r e s e n t i n g s t e r e o t y p i c a l concepts i n c l u d i n g o b j e c t s , events, a c t i o n s , s i t u a t i o n s , and sequences of events, a c t i o n s , and s i t u a t i o n s . Schemata form network s t r u c t u r e s l i k e the semantic networks of Q u i l l i a n (1968) e x h i b i t i n g the same r i c h e n c y c l o p e d i c o r g a n i z a t i o n . Each schema r e p r e s e n t s a g e n e r i c concept. Concepts may be simple or complex, c o n c r e t e or a b s t r a c t . Complex concepts are represented as a composition of sim p l e r schemata. Because knowledge i s organized i n t o c o n c e p t u a l modules, the i n t e r p r e t a t i o n of process can d e a l with l a r g e r e l a t e d amounts of i n f o r m a t i o n as s i n g l e concepts, as u n i t s a t a s i n g l e l e v e l o f d e t a i l , or, a l t e r n a t i v e l y , the h i e r a r c h i c a l data s t r u c t u r e can be examined at a deeper l e v e l of d e t a i l when r e q u i r e d . Each schema i s composed of a s e t of named r e l a t i o n s with other schemata and p r i m i t i v e values. The r e p r e s e n t a t i o n a l s o i n c l u d e s the notion o f s t e r e o t y p e and i n s t a n c e . Stereotype schemata may be copied t o y i e l d m u l t i p l e schema i n s t a n c e s . Each schema s t e r e o t y p e i n i t i a l l y may c o n t a i n d e f a u l t values f o r some of i t s named r e l a t i o n s . When t h e schema i s copied to r e p r e s e n t 2: Mechanisms f o r Machine Percep t i o n 16 an i n s t a n c e of i t s s t e r e o t y p e , the d e f a u l t assignments serve two f u n c t i o n s . F i r s t , they provide g e n e r i c knowledge about the i n s t a n c e t h a t must be g e n e r a l l y t r u e of most occurrences o f the represented concept. Second, the d e f a u l t assignments are i n t e r p r e t e d as e x p e c t a t i o n s of what type of i n f o r m a t i o n may be used to r e p l a c e the d e f a u l t values i n the i n s t a n c e . The process of i n s t a n t i a t i n g a schema i n s t a n c e becomes a search f o r p a r t i c u l a r data or embedded sub-schema i n s t a n c e s s a t i s f y i n g the schema*s e x p e c t a t i o n s . Schemata may c o n t a i n both a c t i v e and passive knowledge. In a s t e r e o t y p e , p a s s i v e knowledge i n c l u d e s the e x p e c t a t i o n s and d e f a u l t v a l u e s . In a f u l l y s p e c i f i e d i n s t a n c e , p a s s i v e knowledge c o n s i s t s of the values of the named r e l a t i o n a l v a r i a b l e s comprising the d e s c r i p t i o n of the i n s t a n c e . Minsky (1975) has proposed a schema-based r e p r e s e n t a t i o n which he c a l l s frajje systems. His work i s p r i m a r i l y concerned with the development of schemata f o r computer v i s i o n knowledge r e p r e s e n t a t i o n s , although he extends i t s a p p l i c a b i l i t y to other domains. Recently, Winograd (1975) has f u r t h e r s p e c i f i e d the frames paradigm f o r use i n n a t u r a l language r e s e a r c h . Schank and Abelson (1975) have developed a schema-based system f c r n a r r a t i v e s t o r y understanding c a l l e d s c r i p t s which uses a small number of p r i m i t i v e a c t i o n s to represent cause and e f f e c t r e l a t i o n s h i p s i n simple n a r r a t i v e s . Using a case p a r s i n g method (Fillmore,1968) to c o n s t r u c t the schematic r e p r e s e n t a t i o n of a s t o r y , Schank's (1975) system can i n f e r a paraphrase of the 2: Mechanisms f o r Machine Percept i o n 17 s t o r y i n c l u d i n g i n f o r m a t i o n not e x p l i c i t l y present i n the o r i g i n a l n a r r a t i v e . S i m i l a r l y , Charniak (1975) has proposed a schema-based s t o r y understanding system. In n e i t h e r of these systems i s the process of t r a n s l a t i o n from the n a r r a t i v e to the schematic r e p r e s e n t a t i o n of primary concern. T h e i r e f f o r t s are d e c i d e d l y r e p r e s e n t a t i o n a l and assume the e x i s t e n c e of s u i t a b l e r e c o g n i t i o n mechanisms, McCalla (1977) has r e c e n t l y modelled n a t u r a l language dialogue using schemata. His system i n t e g r a t e s both s y n t a c t i c p a r s i n g using a case grammar and semantic a n a l y s i s as message passing and i n t e r p r e t a t i o n among coope r a t i n g schemata. Eobrow and Norman (1975) and Rumelhart and Ortony (1976) have presented a c h a r a c t e r i z a t i o n of schemata f o r modelling human memory. As w e l l , Norman, Rumelhart, et a l . (1975) have proposed a c t i v e s t r u c t u r a l networks as schemata f o r modelling memory processes i n l i n g u i s t i c comprehension. 2.4.4 Search A popular p e r s p e c t i v e i n a r t i f i c i a l i n t e l l i g e n c e has been to view machine i n t e l l i g e n c e as a complex search task guided by h e u r i s t i c techniques ( S l a g l e , 1971). From t h i s p e r s p e c t i v e , r e c o g n i t i o n methods f o r machine p e r c e p t i o n can be c h a r a c t e r i z e d as having two major aspects - the development of powerful search mechanisms f o r p a r t i c u l a r r e p r e s e n t a t i o n s and the d i s c o v e r y of 2: Mechanisms f o r Machine P e r c e p t i o n 18 powerful h e u r i s t i c s f o r p a r t i c u l a r knowledge domains to order and reduce the s i z e of the search space. A number of search mechanisms have been advanced f o r schema-based r e p r e s e n t a t i o n s . Fahlman (1975) has advocated the use of p a r a l l e l hardware. Bieger (1974) has proposed the use of u n r e s t r i c t e d fcrward deduction. In the author's o p i n i o n , both of these proposals are attempts to s o l v e the p e r c e p t i o n problem with a " b i g g e r haamer". Although advances i n the s t a t e of the hardware a r t may ease our programming p l i g h t , they s h o u l d not be the b a s i s of a theory of p e r c e p t i o n . Kuipers (1975) has advocated a top-down, hypothesis d r i v e n r e c o g n i t i o n model f o r schema systems. In t h i s model, schema s t e r e o t y p e s c o n t a i n h e u r i s t i c knowledge to guide the search process. As w e l l , the s t e r e o t y p e ' s d e f a u l t e x p e c t a t i o n s c o n s t i t u t e hypotheses about what to look f o r to f i l l the s l o t s o f the i n s t a n c e . Schemata r e c o g n i z e i n s t a n c e s by making e x t e r n a l o b s e r v a t i o n s and by r e c u r s i v e l y c a l l i n g on the e f f o r t s of other sub-schemata as subgoals. u n f o r t u n a t e l y , t h i s r e c o g n i t i o n scheme f o r c e s the use of p u r e l y g o a l driven search mechanisms thereby s u f f e r i n g from a number o f s e r i o u s drawbacks. Described below are three such d e f i c i e n c i e s : 1. A schema must be e x p l i c i t l y hypothesized as a subgoal i n order to r e c o g n i z e i n s t a n c e s of i t s s t e r e o t y p e . A schema may c o n t a i n h e u r i s t i c knowledge to guide the 2: Mechanisms f o r Machine P e r c e p t i o n 19 r e c o g n i t i o n process. In order f o r t h i s knowledge to tecome a v a i l a b l e , the schema must be hypothesized e x p l i c i t l y as a subgoal by some higher schema. T h i s f o r c e s a r e l i a n c e on top-down, goal d i r e c t e d search s t r a t e g i e s . 2. An o r d e r i n g must be assigned t o a l t e r n a t i v e hypotheses. The top-down r e c o g n i t i o n model f o r c e s the choice o f one subgoal at a time. Furthermore, the mechanism f o r a c t i v a t i n g each a l t e r n a t i v e subgoal i s completely f a i l u r e d r i v e n . Consider a schema c o n t a i n i n g a number of a l t e r n a t i v e subgoals. Which should be h y p o t h e s i z e d f i r s t ? One p a r t i c u l a r subgoal must be chosen as the most l i k e l y hypothesis and c a l l e d . T h i s choice must be made on " b l i n d " e x p e c t a t i o n before the h e u r i s t i c e x p e r t i s e o f the subgoal schema i s a v a i l a b l e to help make the d e c i s i o n . Each subgoal schema may c o n t a i n h e u r i s t i c knowledge to d r i v e the r e c o g n i t i o n o f i t s s t e r e o t y p e , yet t h a t guidance i s a v a i l a b l e only a f t e r a committment has been made t o the schema as a subgoal. 3. I d e n t i c a l subgoals must be c a r r i e d out independently. A schema may be s u c c e s s f u l a t a c h i e v i n g a number o f i t s subgoals. I f , however, another necessary subgoal should subsequently f a i l , the schema must i t s e l f r e t u r n a f a i l u r e to i t s c a l l e r . L a t e r , the system may re-compute those i d e n t i c a l 2: Mechanisms f o r Machine P e r c e p t i o n 20 s u b g c a l s . T h i s behavior has been c a l l e d t h r a s h i n g (Bobrow S Raphael, 1974). Minsky (1975), a n t i c i p a t i n g t h i s t h i r d o b j e c t i o n , has proposed a mechanism, f i r s t used by Winston (1975), that attempts t o a v o i d d u p l i c a t i o n of e f f o r t f o r i d e n t i c a l subgcals. When a schema d i s c o v e r s from o b s e r v a t i o n t h a t i t i s not a p p l i c a b l e t o a given s i t u a t i o n , i t c o n s u l t s a s i m i l a r i t y network which recommends a replacement c a n d i d a t e . The schema then attempts t o map i t s c o r r e c t l y completed subgoals i n t o the e x p e c t a t i o n s of the new candidate schema and then passes c c n t r o l to i t . T h i s mechanism assumes both t h a t a mapping e x i s t s between each f a i l i n g schema and each next candidate and t h a t the s i m i l a r i t y network i s s u f f i c i e n t l y complete t h a t r e l a t i v e l y few i n e x p l i c a b l e f a i l u r e s occur. Such s u r p r i s e s f o r c e the system to r e l y e n t i r e l y on automatic b a c k t r a c k i n g t o continue the search. The above comments are a p p l i c a b l e not o n l y to schemata, but h i e r a r c h i c a l h y p othesis driven systems i n general. Mackworth (1977b) has l a b e l l e d the same phenomenon i n v i s i o n r e s e a r c h "the chicken and egg problem". Top-down, hypothesis d r i v e n search h e u r i s t i c a l l y o r d e r s the search space by attempting more l i k e l y i n t e r p r e t a t i o n s before t r y i n g l e s s l i k e l y ones. However, h e u r i s t i c o r d e r i n g i s not i n i t s e l f s u f f i c i e n t to s o l v e the r e c o g n i t i o n problem. At the other extreme, bottom-up search i s d r i v e n s o l e l y by evidence d i s c o v e r e d from o b s e r v a t i o n . Such evidence can be compared a g a i n s t domain s p e c i f i c knowledge to c o n s t r a i n the 2: Mechanisms f o r Machine P e r c e p t i o n 21 i n t e r p r e t a t i o n . Since no hypotheses need be formed, b a c k t r a c k i n g i s not r e q u i r e d . U n f o r t u n a t e l y , bottom-up search mechanisms provide no quidance e i t h e r s i n c e there i s no e x p e c t a t i o n of f u t u r e experience. For p e r c e p t i o n , techniques are needed which allow hypothesis d i r e c t e d search t o g i v e o v e r a l l quidance to the r e c o q n i t i o n process, yet permit bottom-up, d a t a - d r i v e n techniques t o circumvent the i n e f f i c i e n c i e s of the p u r e l y top-down scheme. One such approach i s the use of m u l t i p r o c e s s i n g to i n t e g r a t e top-down and bottom-up search. Kaplan (1973) has developed a n a t u r a l language p a r s i n q system, GSP, based on a m u l t i p r o c e s s i n g scheme. The system c r e a t e s independent processes to look f o r each qrammatical c o n s t i t u e n t i n a sentence., GSP employs a p r i o r i t y queue s c h e d u l i n q mechanism and uses a grammatical c h a r t as a communication mechanism between processes. The system i s very f l e x i b l e i n that i t can emulate, at one extreme, top-down r e c o q n i t i o n such as Woods* (1970) Auqmented T r a n s i t i o n Network parse r and, at the other extreme, bottom-up r e c o q n i t i o n . Recently, Bobrow and Winoqrad (1977), as mentioned e a r l i e r , have r e p o r t e d on the development of a schema-based proqramminq lanquaqe supportinq m u l t i p r o c e s s i n q c a l l e d KRL. The lanquaqe i s designed as an i n t e g r a t i o n o f p r o c e d u r a l and d e c l a r a t i v e forms of knowledqe with a r e c o q n i t i o n model based on schema matchinq. In KRL, schemata are composed of modular e n t i t i e s c a l l e d <1§ s c r i p t i o n s which may have a s s o c i a t e d procedures and 2: Mechanisms f o r Machine P e r c e p t i o n 22 a t t r i b u t e s , A d e s c r i p t i o n i s made up of m u l t i p l e d e s c r i p t o r s , each d e s c r i b i n g the schema's concept from a d i f f e r e n t viewpoint. As i n Minsky's frames model, th e concept o f s t e r e o t y p e and i n s t a n c e are fundamental to the r e p r e s e n t a t i o n . D e s c r i p t i o n s are b a s i c a l l y i n t e n s i o n a l r e p r e s e n t a t i o n s and may be composed i n t o higher schemata c a l l e d u n i t s . O n i t s are intended as a mechanism f o r a c h i e v i n g procedural attachment by a s s o c i a t i n g a s e t of d e s c r i p t i o n s with a s e t of procedures. As w e l l , u n i t s possess a category type which i n d i c a t e s to the matcher how o p e r a t i o n s are to be performed on t h e d e s c r i p t i o n s contained i n the u n i t . T h i s semantic marker scheme pr o v i d e s a f u r t h e r l e v e l of s p e c i a l i z a t i o n f o r the matching process. Bobrow and Hinograd propose a model of r e c o g n i t i o n based on an extended concept of d e s c r i p t i o n matching. The KRL matcher i s designed to compare two forms s y n t a c t i c a l l y , or at the other extreme, to d r i v e the o v e r a l l o p e r a t i o n of the r e c o g n i t i o n process. The matcher uses both the syntax of the d e s c r i p t o r s and domain s p e c i f i c knowledge encoded as semantic markers and p r o c e d u r a l knowledge at t a c h e d t o u n i t s and d e s c r i p t i o n s . The model as d e s c r i b e d i s e s s e n t i a l l y hypothesis d r i v e n . To avoid the problems noted with the top-down r e c o g n i t i o n model, the authors propose a m u l t i p r o c e s s i n g scheme t h a t provides a process p r i o r i t y gueue with u s e r - s u p p l i e d s t r a t e g i e s f o r s c h e d u l i n g and r e source a l l o c a t i o n . 2: Mechanisms f o r Machine Pe r c e p t i o n 23 2.5 Machine V i s i o n Recent r e s e a r c h i n machine v i s i o n has made a p a r t i c u l a r l y s i g n i f i c a n t c o n t r i b u t i o n to the development of a theory of machine p e r c e p t i o n . The i n h e r e n t complexity of v i s i o n has f o r c e d the c o n f r o n t a t i o n of the problem from two maior d i r e c t i o n s . F i r s t , machine v i s i o n r e s e a r c h has expanded our understanding of the r o l e of d o m a i n - s p e c i f i c knowledge i n v i s u a l p e r c e p t i o n . The use o f t h i s h e u r i s t i c knowledge i s recognized as being e s s e n t i a l t o the p e r c e p t u a l process. Second, machine v i s i o n has, by n e c e s s i t y , been concerned with developing computational methods s u f f i c i e n t l y powerful f o r t h i s r e s e a r c h domain. T h i s second aspect o f machine v i s i o n i s p a r t i c u l a r l y germane t o t h i s t h e s i s and w i l l be examined i n t h i s s e c t i o n . A more comprehensive review of machine v i s i o n can be fouisd i n Mackworth(1977b). 2.5.1 Roberts* Paradigm The e a r l y r e s e a r c h e f f o r t s of Roberts(1965) e s t a b l i s h e d a paradigm f o r machine v i s i o n which has provided a s i g n i f i c a n t c o n t r i b u t i o n towards a theory of machine p e r c e p t i o n . Roberts used a two-pass procedure to r e c o g n i z e scenes of simple p o l y h e d r a l o b j e c t s . The f i r s t pass reduced g r a y - l e v e l p i c t u r e data to p e r f e c t l i n e drawings from which the second procedure c o u l d perform o b j e c t r e c o g n i t i o n . The a b i l i t y o f the f i r s t 2: Mechanisms f o r Machine Pe r c e p t i o n 24 procedure to produce p e r f e c t l i n e drawings from r e a l i s t i c data without performing h i g h e r - l e v e l i n t e r p r e t a t i o n has been doubted (Mackworth, 1977b). From a p e r f e c t l i n e drawing, Roberts* second procedure attempts to compute a scene i n t e r p r e t a t i o n using g e o m e t r i c a l models of three p r o t o t y p i c a l polyhedra, s p e c i f i c a l l y cubes, wedges, and prisms. Roberts used the p r e d i c t i v e power of these geometric models t o s i g n i f i c a n t l y c o n s t r a i n the search f o r a scene i n t e r p r e t a t i o n . He noted that the complexity of the search space c o u l d be reduced because the view o f a p a r t i c u l a r p r o t o t y p i c a l o b j e c t i n some given p i c t u r e i s t o p o l o g i c a l l y i n v a r i a n t over a r e l a t i v e l y wide range o f viewpoints. Instead of s e a r c h i n g i n the p i c t u r e domain f o r l i n e s t h a t belong to some polyhedron, a model can p r e d i c t where i n the p i c t u r e t o l o c k f o r those p a r t i c u l a r l i n e s . In other words, Roberts e x p l o i t e d the p r e d i c t i v e a b i l i t y of models to guide the r e c o g n i t i o n process. A second c o n t r i b u t i o n o f h i s work i s the use of p i c t u r e cues to hypothesize p a r t i c u l a r models. The program's models are invoked by the d i s c o v e r y o f s p e c i f i c cues that suggest the app r o p r i a t e n e s s of a p a r t i c u l a r model. Once a model i s s e l e c t e d , t h a t model d i r e c t s the remainder of the r e c o g n i t i o n process by c a l c u l a t i n g , based on i t s p a r t i a l i n s t a n t i a t i o n , where i n the p i c t u r e t o look f o r the remaining l i n e s of the model prototype. I f a model i s found to be i n a p p r o p r i a t e , then the cue d i s c o v e r y process i s continued t o s e l e c t another model. When a model i s s u c c e s s f u l i n r e c o g n i z i n g a simple polyhedron, 2 : Mechanisms f o r Machine P e r c e p t i o n 25 t h a t o b j e c t i s " e d i t e d out" of the p i c t u r e and the search f o r new cues resumed. T h i s technique provides a crude mechanism f o r r e c c q n i z i n q complex polyhedra as the composition of the three simpler polyhedra modelled by the proqram. The r e c o q n i t i o n model embodied i n Roberts' proqram has been c h a r a c t e r i z e d as a c y c l i c process of d i s c o v e r i n q cues, a c t i v a t i n q a most l i k e l y h y p o t h e s i s , attemptinq to v e r i f y t h a t h ypothesis, and f c l l o w i n q the consequences of a s u c c e s s f u l hypothesis (Mackworth, 1S77b). On success, the r e c o q n i z e d simple polyhedron i s d e l e t e d from the p i c t u r e and the process i t e r a t e s . k t h i r d c o n t r i b u t i o n of Roberts' work i s that the cue d i s c o v e r y process i s r e a l i z e d as an ordered h e u r i s t i c procedure. T h i s procedure depends on the n o t i o n of an approved polygon which i s d e f i n e d as a view of a polygon face of any cube, wedqe, or prism. The procedure f i r s t attempts to f i n d a p i c t u r e vertex surrounded by three approved polyqons. I f u n s u c c e s s f u l , i t attempts to f i n d a l i n e j o i n i n q two approved pclyqons. I f t h i s f a i l s , the procedure attempts to f i n d a polygon c o n t a i n i n g a t h r e e - l i n e v e r t e x . Otherwise, as a l a s t r e s o r t , i t l o c k s f o r a t h r e e - l i n e v e r t e x as a cue. The very e a r l y work of Roberts can now be seen to have made s i g n i f i c a n t steps towards a theory of machine p e r c e p t i o n . F i r s t , he used qeometric models o f simple p o l y h e d r a l o b j e c t s to quide the r e c o q n i t i o n process. Second, he used p i c t u r e cues as a mechanism f o r s e l e c t i n g a r e l e v a n t model. T h i s bottcm-up se a r c h mechanism f u r t h e r c o n s t r a i n e d the search space by 2: Mechanisms f o r Kachine P e r c e p t i o n 26 u t i l i z i n g evidence d i s c o v e r e d i n the p i c t u r e to s e l e c t a v i a b l e hypothesis. And t h i r d , the process of cue d i s c o v e r y was i t s e l f a r e c o g n i t i o n task d r i v e n by a h e u r i s t i c procedure. In l i g h t of the present s t a t e of the a r t , Roberts• r e s e a r c h can be c r i t i c i z e d f o r a number of shortcomings. Host no t a b l y , the program uses on l y a s i n g l e l e v e l of cue d i s c o v e r y . There i s no notion of a h i e r a r c h y of cues and models. Cues are completely c o n t e x t - f r e e d i s c o v e r i e s t h a t cannot themselves be the r e s u l t of r e c o g n i t i o n . As w e l l , the process of r e c o g n i z i n g complex scenes i s handled v i a a p r i m i t i v e composition mechanism which operates, not i n the i n t e r p r e t e d scene, but d i r e c t l y i n the p i c t u r e domain. And l a s t l y , the r e c o g n i t i o n process i s d r i v e n by a s i n g l e g l o b a l method, the i t e r a t i v e c y c l e of cue d i s c o v e r y , model i n v o c a t i o n , and model s a t i s f a c t i o n . There i s no p o s s i b i l i t y of u s i n g s p e c i f i c h e u r i s t i c methods f o r the r e c o g n i t i o n of p a r t i c u l a r models. A s i n g l e g l o b a l method must s u f f i c e f o r the r e c o g n i t i o n of a l l polygon types. Although Roberts' r e s e a r c h can now be e a s i l y f a u l t e d , i t s t i l l remains an amazing f i r s t s t e p towards a theory f o r machine p e r c e p t i o n . 2.5.2 Guzman's SEE Guzman's (1968) work d i v e r g e d from the paradigm e s t a b l i s h e d by Roberts. Guzman's program, c a l l e d SEE, attempts to p a r t i t i o n r e g i o n s of l i n e drawings i n t o p o l y h e d r a l o b j e c t s using only l o c a l c o r n e r j u n c t i o n i n f o r m a t i o n . SEE employs a two pass 2: Mechanisms f o r Kachine P e r c e p t i o n 27 method. In the f i r s t pass, r e l a t i o n a l "connectedness" l i n k s are placed between adjacent r e g i o n s as a f u n c t i o n of the p i c t u r e j u n c t i o n types t h a t the two r e g i o n s share. In order t o cope with the i n h e r e n t ambiguity o f p i c t u r e j u n c t i o n s , Guzman used a number of complicated i n h i b i t i o n r u l e s t o temper the l i n k p l a c i n g process. The second pass attempts to compute the t r a n s i t i v e c l o s u r e of r e g i o n s s h a r i n g two or more l i n k s while again using i n h i b i t i o n r u l e s to moderate the process. The simple method of t h i s second pass depends c r i t i c a l l y on the "tuned" performance of both i t s i n h i b i t i o n r u l e s and the r u l e s o f the f i r s t pass. The f i r s t pass must c r e a t e enough l i n k s so t h a t a complete scene l a b e l l i n g can be obtained; the second pass method must then c l o s e enough r e g i o n s so that a unigue unambiguous i n t e r p r e t a t i o n r e s u l t s . Both methods, however, must be c o n s e r v a t i v e enough to prevent the j o i n i n g of sepa r a b l e o b j e c t s to each other cr the background. Guzman claimed t h a t SEE performed r e c o g n i t i o n without the use of models, a divergence from the e a r l i e r paradigm of Roberts. Yet, as Mackworth (1977b) p o i n t s out, the m o d e l - s p e c i f i c knowledge represented i n Roberts* cue r e c o g n i t i o n procedure i s hidden by Guzman i m p l i c i t l y i n the complicated ad hoc i n h i b i t i o n r u l e s . 2: Mechanisms f o r Machine P e r c e p t i o n 28 2.5,3 Huffman and Clowes Huffman (1971) and Clowes (1971) l a t e r independently g e n e r a l i z e d the work of Guzman t o use j u n c t i o n shapes appearing i n the p i c t u r e as cues f o r t h e i r i n t e r p r e t a t i o n as co r n e r s i n the scene. By d i f f e r e n t i a t i n g between the p i c t u r e domain and the scene domain, both Huffman and Clowes reasoned t h a t each p i c t u r e j u n c t i o n can have only a few v a l i d corner i n t e r p r e t a t i o n s i n scenes c o n t a i n i n g r e a l t h r e e - d i m e n s i o n a l p o l y h e d r a l o b j e c t s . Such p h y s i c a l c o n s t r a i n t s were seen to be unary p r e d i c a t e s on the way a p a r t i c u l a r j u n c t i o n type can be l a b e l l e d . As w e l l , each such j u n c t i o n i s f u r t h e r c o n s t r a i n e d by a b i n a r y r e l a t i o n along the p i c t u r e edges i t shares with other j u n c t i o n s . An edge must have the same scene l a b e l l i n g at both of the j u n c t i o n s d e f i n i n g i t s ends. Clowes and Huffman s i g n i f i c a n t l y extended our knowledge of r e c o g n i t i o n mechanisms s u i t a b l e f o r machine v i s i o n . Unlike Guzman, they r e f r a i n e d from t r y i n g t o perform r e c o g n i t i o n i n the p i c t u r e domain using o n l y l o c a l knowledge about j u n c t i o n type. Instead, they used p i c t u r e j u n c t i o n s as cues t o invoke p a r a l l e l unary and b i n a r y c o n s t r a i n t s i n the scene domain. They then s a t i s f i e d the r e s u l t i n g system of simultaneous c o n s t r a i n t s by employing, i n one case, a d e p t h - f i r s t search and i n the other, a b r e a d t h - f i r s t s e a r c h . U n f o r t u n a t e l y , l i k e t h e i r predecessor, both men n e g l e c t e d the v i r t u e s of using e x p l i c i t o b j e c t models to guide the 2: Mechanisms f o r Hachine P e r c e p t i o n 29 r e c o g n i t i o n process. Instead, t h e i r models are e f f e c t i v e l y compiled i n t o the s e t s of p o s s i b l e corner i n t e r p r e t a t i o n s . As w e l l , Huffman and Clowes used only p r i m i t i v e cues, the p i c t u r e j u n c t i o n types given i n the input data. Cue d i s c o v e r y i s a t r i v i a l computation independent of the semantics of the p a r t i c u l a r scene being i n t e r p r e t e d . In other words, cues cannot be r e c u r s i v e l y the r e s u l t of the r e c o g n i t i o n process. Consequently, t h i s r e c o g n i t i o n mechanism makes use n e i t h e r c f a h i e r a r c h y of o b j e c t models, nor of a h i e r a r c h y of cues a s s o c i a t e d with those models. 2.5.4 Waltz's Algorithm The scene a n a l y s i s program of Waltz (1972) e l a b o r a t e d f u r t h e r the technigues developed by Guzman, Huffman, and Clowes. Waltz extended t h e i r approach i n two important d i r e c t i o n s . F i r s t , he i n c o r p o r a t e d more knowledge s p e c i f i c to the v i s u a l world of toy b l o c k s by expanding the s e t of j u n c t i o n l a b e l s used. The new s e t of l a b e l s i n c l u d e d knowledge about crack edges between adjacent b l o c k s and a crude r e p r e s e n t a t i o n of shadows. Such an expanded l a b e l s e t c r e a t e d a huge number of p o s s i b l e corner l a b e l l i n g s f o r each* j u n c t i o n type, thereby i n c r e a s i n g c o n s i d e r a b l y the complexity of the search space. Waltz, however, n o t i c e d that a f t e r a p p l y i n g to each j u n c t i o n type the unary c o n s t r a i n t of what corner i n t e r p r e t a t i o n s could appear i n the " r e a l world", the remaining s e t of v a l i d l a b e l s 2: Mechanisms f o r Machine P e r c e p t i o n 30 was much reduced. Adding more dimensions t o the l a b e l l i n g of polyhedron j u n c t i o n s i n c r e a s e d the r i c h n e s s of the domains semantics without e x p o n e n t i a l l y i n c r e a s i n g the complexity of the search space. Second, i n order to cope with the expanded s e t of l a b e l s , H a l t z developed a j u n c t i o n f i l t e r i n g a l g o r i t h m to f u r t h e r c o n s t r a i n the search space before attempting a d e p t h - f i r s t or b r e a d t h - f i r s t search f o r a g l o b a l scene i n t e r p r e t a t i o n . T h i s f i l t e r i n g a l g o r i t h m i s based on the notion of a c o n s i s t e n c y c o n d i t i o n , "C", which h o l d s t r u e i f , f o r every l a b e l assigned t o a p a r t i c u l a r j u n c t i o n , t h e r e i s e i t h e r a matching l a b e l assignment at each l a b e l l e d , neighbouring j u n c t i o n , or that j u n c t i o n has not yet been l a b e l l e d . The f i l t e r i n g a l g o r i t h m operates by t o u r i n g the s e t of p i c t u r e j u n c t i o n s once i n some a r b i t r a r y order. At each j u n c t i o n , the a l g o r i t h m f i r s t a t t a c h e s a l i s t of a l l corner i n t e r p r e t a t i o n s which s a t i s f y the unary p r e d i c a t e s f o r t h a t j u n c t i o n type. Waltz noted t h a t such l i s t s were s t a t i c and co u l d be compiled once f o r each j u n c t i o n type. Next, the co r n e r i n t e r p r e t a t i o n s of each newly l a b e l l e d j u n c t i o n are "pruned" a g a i n s t the l a b e l s e t s of each neighbouring j u n c t i o n s h aring an edge with t h i s j u n c t i o n such t h a t c o n d i t i o n "C" holds. That i s , any corner i n t e r p r e t a t i o n of the new j u n c t i o n having an edge l a b e l t h a t does not match an edge l a b e l of each al r e a d y l a b e l l e d n eighbouring j u n c t i o n , i s d e l e t e d . Then, i n a spreading b r e a d t h - f i r s t s e a r c h , each neighbouring j u n c t i o n prunes i t s 2: Mechanisms f o r Machine P e r c e p t i o n 31 l a b e l s et a g a i n s t t h i s j u n c t i o n and each of i t s neighbours do l i k e w i s e u n t i l , once again, c o n d i t i o n "C" holds throughout the network. The s i g n i f i c a n c e o f t h i s a l g o r i t h m i s t h a t i t r e q u i r e s o n l y a s i n g l e pass through the s e t of p i c t u r e j u n c t i o n s . When i t terminates, a l l i n c o n s i s t e n t corner i n t e r p r e t a t i o n s have been e l i m i n a t e d . Often, the alg o r i t h m y i e l d s a s i n g l e l a b e l l i n g f o r each j u n c t i o n , thereby negating the need f o r a subsequent scene i n t e r p r e t a t i o n search. B a l t z both extended the use i n machine v i s i o n of domain s p e c i f i c knowledge and i n t r o d u c e d the use of c o n s t r a i n t propagation techniques to the f i e l d . He demonstrated t h a t by i n c o r p o r a t i n g enouqh semantic i n f o r m a t i o n about a " b l o c k s wcrld" scene, an o v e r - c o n s t r a i n e d network r e p r e s e n t a t i o n can be c o n s t r u c t e d which through the use of c o n s t r a i n t propagation technigues can q u i c k l y y i e l d a unique i n t e r p r e t a t i o n , From the present p e r s p e c t i v e of developing a computational model of r e c o g n i t i o n f o r p e r c e p t i o n , Waltz can be c r i t i c i z e d f o r the same d e f i c i e n c i e s as h i s predecessors. His program makes no e x p l i c i t use of models of t h e polyhedra i t r e c o g n i z e s . Instead, i t r e l i e s on the i m p l i c i t knowledge of polyhedra embedded i n the j u n c t i o n l a b e l s . L i k e w i s e , the cue d i s c o v e r y process i s completely a c o n t e x t - f r e e p r o c e s s . Cues are, i n f a c t , p r i m i t i v e e n t i t i e s , the p i c t u r e j u n c t i o n s given i n the i n p u t data. T h e i r d i s c o v e r y can be n e i t h e r a f u n c t i o n o f the p a r t i a l knowledqe so f a r known about a p a r t i c u l a r scene, nor can they be complex a b s t r a c t e n t i t i e s computed r e c u r s i v e l y as the r e s u l t of 2 : Mechanisms f o r Kachine P e r c e p t i o n 32 r e c o g n i t i o n . 2.5.5 Hackworth's MftPSEE The c o n s t r a i n t s a t i s f a c t i o n techniques developed by Waltz and others have been r e c e n t l y q e n e r a l i z e d by Mackworth (1975, 1977a) to a c l a s s of network c o n s i s t e n c y a l g o r i t h m s . These are shown to be more e f f i c i e n t search methods than automatic b a c k t r a c k i n g f o r s e a r c h t a s k s which can be formulated as n-ary c o n s t r a i n t s a t i s f a c t i o n problems. Network c o n s i s t e n c y forms the b a s i s of a r e c o g n i t i o n model f o r machine p e r c e p t i o n which a p p l i e s g e n e r a l c o n s t r a i n t s a t i s f a c t i o n a l g o r i t h m s to networks of simultaneous c o n s t r a i n t s . Mackworth (1977a) has r e c e n t l y used network c o n s i s t e n c y techniques f o r the i n t e r p r e t a t i o n of freehand sketch maps. The proqram, c a l l e d (lapsee, i n t e r p r e t s a hand-drawn map of an i s l a n d a c c o r d i n g to the c o n v e n t i o n a l semantics of cartoqraphy. The proqram beqins by performinq a very c o n s e r v a t i v e p a r t i a l r e q ion seqmentation of the i n p u t s k e t c h to y i e l d a s e t of primary cues based on simple p i c t u r e f e a t u r e s . Cues are f e a t u r e s d e r i v e d from the sketch such as acute anqles, p o i n t c l u s t e r s , free-ends of l i n e s , and j u n c t i o n types. These cues are then used to invoke primary models t h a t provide p a r t i a l - i n t e r p r e t a t i o n s of the map i n the l o c a l e of the cue. Note that the i n t e r p r e t a t i o n provided by a model may be i n i t i a l l y h i q h l y ambiquous. However, each model e s t a b l i s h e s c o n s t r a i n i n q r e l a t i o n s h i p s with i t s 2: Mechanisms f o r Machine Pe r c e p t i o n 33 geographic neighbours a c c o r d i n g t o the c a r t o g r a p h i c semantics. The r e s u l t i n g network can be v i s u a l i z e d as a hyper-graph whose nodes are p i c t o r i a l o b j e c t s (regions and chains of l i n e s ) and whose n-ary a r c s are c o n s t r a i n i n g r e l a t i o n s d e r i v e d from the models. Mapsee then a p p l i e s a network c o n s i s t e n c y a l g o r i t h m to the network t h a t p r o g r e s s i v e l y e l i m i n a t e s i n c o n s i s t e n t i n t e r p r e t a t i o n s f o r the v a r i o u s c a r t o g r a p h i c f e a t u r e s represented by the models. I f the c o n v e n t i o n a l semantics of the models chosen i s r i c h enough, and i f a giv e n s k e t c h map i s e x p l i c i t i n i t s r e p r e s e n t a t i o n , the r e s u l t i n g system i s over c o n s t r a i n e d and the a l g o r i t h m may converge t o a s i n g l e p o s s i b l e i n t e r p r e t a t i o n . Mapsee demonstrates f i r s t t h a t cue/model d r i v e n r e c o g n i t i o n can be combined with network c o n s i s t e n c y search technigues and t h a t these methods may be a p p l i e d t o p e r c e p t i o n task domains o u t s i d e the " b l o c k s world". Second, Hapsee d e f i n e s a c y c l i c r e c o g n i t i o n model f o r machine p e r c e p t i o n . Hackworth (19771) has noted t h a t p i c t u r e segmentation r e q u i r e s scene i n t e r p r e t a t i o n and c o n v e r s e l y t h a t i n t e r p r e t a t i o n r e q u i r e s segmentation. He c a l l s t h i s phenomenon "the c h i c k e n and egg problem" f o r machine p e r c e p t i o n . Hapsee's i n i t i a l c o n s e r v a t i v e p i c t u r e segmentation, although inadequate f o r a g l o b a l i n t e r p r e t a t i o n , y i e l d s enough primary cues t o invoke a p p r o p r i a t e models. The subsequent c o n s t r a i n t s a t i s f a c t i o n among these models provides an i n i t i a l i n t e r p r e t a t i o n which can then be used to guide a more 2: Mechanisms f o r Machine P e r c e p t i o n 3a c o n t e x t - s e n s i t i v e re-segmentation. T h i s process may be i t e r a t e d u n t i l a complete i n t e r p r e t a t i o n i s obtained. T h i r d , network c o n s i s t e n c y a l g o r i t h m s provide a uniform s y n t a c t i c c o n t r o l s t r u c t u r e f o r s e a r c h i n g d e c l a r a t i v e network r e p r e s e n t a t i o n s . C o n s i s t e n c y a l g o r i t h m s tend t o converge towards a unigue i n t e r p r e t a t i o n by f o c u s i n g on those nodes i n the network «hich remain the most ambiguous. Each c y c l e i n Mapsee's r e c o g n i t i o n process computes a new approximate scene i n t e r p r e t a t i o n t h a t i s used to d r i v e a c o n t e x t - s e n s i t i v e re-segmentation, thereby y i e l d i n g s e m a n t i c a l l y r i c h e r cues f o r the next c y c l e . T h i s i t e r a t i v e mechanism i s seen as a means of " b o o t s t r a p p i n g 1 1 i n t o an i n t e r p r e t a t i o n thereby a v o i d i n g the " c h i c k e n and egg problem". However, s i n c e Mapsee u t i l i z e s n o n - h i e r a r c h i c a l d e s c r i p t i v e models, cues must s t i l l be p r i m i t i v e f e a t u r e s detected by the re-segmentation. They cannot be more complex e n t i t i e s r e c o g n i z e d d u r i n g the scene i n t e p r e t a t i o n as p a r t of a h i e r a r c h y o f cues and models. Network c o n s i s t e n c y technigues encourage the use of purely d e c l a r a t i v e knowledge r e p r e s e n t a t i o n s and e x h i b i t the f a m i l i a r b e n e f i t s and l i m i t a t i o n s o f that r e p r e s e n t a t i o n {Wincgrad, 1975). Since models are r e a l i z e d as s e t s of c o n s t r a i n i n g r e l a t i o n s h i p s among other models, network c o n s i s t e n c y i s a very modular computational paradigm. New c o n s t r a i n t s and new models can e a s i l y be i n c r e m e n t a l l y added and d e l e t e d from the network. As w e l l , s i n c e a l l of the domain s p e c i f i c knowledge i s embodied i n the d e c l a r a t i v e models, the system i s p o r t a b l e . I t can be 2: Mechanisms f o r Machine P e r c e p t i o n 35 e a s i l y a p p l i e d to other r e c o g n i t i o n tasks which e x h i b i t a semantics expressable as a system of mutual simultaneous c o n s t r a i n t s . On the other hand, the di v o r c e of the d e c l a r a t i v e models from the procedures used to search the network s t r u c t u r e f o r c e s the use of a s i n g l e g l o b a l s y n t a c t i c search method, the network c o n s i s t e n c y a l g o r i t h m . No d o m a i n - s p e c i f i c knowledge such as h e u r i s t i c s e arch methods a s s o c i a t e d with p a r t i c u l a r models i s p o s s i b l e . Mackworth (1977c) has noted the l i m i t a t i o n s of a uniform search method f o r n o n - h i e r a r c h i c a l d e s c r i p t i v e models and has advocated " e x p l o r i n g c o n t r o l s t r a t e g i e s f o r schema-based t h e o r i e s of p e r c e p t i o n " . 2.5.6 Freuder«s SEER Freuder (1976) has r e c e n t l y developed a r e c o g n i t i o n model f o r schema-based r e p r e s e n t a t i o n s that i s p r i m a r i l y concerned with the s p e c i f i c a t i o n of c o n t r o l s t r u c t u r e s f o r machine p e r c e p t i o n . . His program, SEER, r e c o g n i z e s a scene of a common machi n i s t ' s hammer represented as g r a y - l e v e l video data. Freuder argues that most r e c o g n i t i o n schemes employ c c n t r o l a l g o r i t h m s which do not r e l y on computed p a r t i a l r e s u l t s or the semantics of the scene being p e r c e i v e d . To the c o n t r a r y , SEER employs the d i s c o v e r y of p a r t i a l hammer components combined with g e n e r a l knowledge about hammers t o guide the r e c o g n i t i o n process. In SEER, knowledge i s rep r e s e n t e d i n two forms of 2: Mechanisms f o r Machine Percep t i o n 36 h i e r a r c h i c a l semantic network s t r u c t u r e s . General knowledge about hammers i s represented i n schema s t r u c t u r e s c a l l e d GK networks, whereas knowledge s p e c i f i c t o a p a r t i c u l a r hammer i n s t a n c e i s r e p r e s e n t e d i n a schema i n s t a n c e c a l l e d a PK network. The nodes of a GK network r e p r e s e n t items of v i s u a l knowledge about hammers, such as handles and heads. The l i n k s between these nodes r e p r e s e n t how these items may e s t a b l i s h each oth e r ' s r e c o g n i t i o n . On the other hand, a PK network rep r e s e n t s a p a r t i a l l y i n s t a n t i a t e d i n s t a n c e of a GK concept and i n h e r i t s i t s s t r u c t u r e and procedures. Both the GK and PK networks form t r e e data s t r u c t u r e s . ftt the l e a v e s of each PK t r e e are procedures which search f o r i n s t a n c e s of the s p e c i f i c GK concept. The leaves of a p a r t i c u l a r PK t r e e s t r u c t u r e r e p r e s e n t the s t a t e of the p r o c e d u r a l methods concerned with the r e c o g n i t i o n of that schema i n s t a n c e . In Preuder's model, r e c o g n i t i o n proceeds using both top-down and bottom-up search w i t h i n a PK s t r u c t u r e . When a new f e a t u r e i s d i s c o v e r e d , i t i s used as bottom-up evidence f o r the hypothesis of h i g h e r c o n j e c t u r e s of which the f e a t u r e may be p a r t . A new PK s t r u c t u r e i s c r e a t e d t o r e p r e s e n t t h i s new p o s s i b l e r e l a t i o n s h i p . As w e l l , the c r e a t i o n of new c o n j e c t u r e s permits the top-down e x p l o r a t i o n of t h e i r subgoals thereby r e s u l t i n g i n the c r e a t i o n of subordinate c o n j e c t u r e s . Since a number o f c o n j e c t u r e s can be a c t i v e s i multaneously, the c o n t r o l s t r u c t u r e question c e n t e r s about which c o n j e c t u r e to 2: Mechanisms f o r Machine Percep t i o n 37 e x p l o r e next. The mechanism used i n SEES i s the f a a i l i a r p r i o r i t y - g u e u e m u l t i p r o c e s s i n g scheme. Co n j e c t u r e s are assigned a p r i o r i t y when placed on the queue and t h e i r p r i o r i t y may be changed durinq the r e c o q n i t i o n process. A g l o b a l monitor then s e l e c t s the h i g h e s t p r i o r i t y c o n j e c t u r e and attempts to ccnfirra i t by a c t i v a t i n g one of i t s p r o c e d u r a l methods. The r e c o g n i t i o n model def i n e d by SEES f o l l o w s a c y c l i c process. A c o n j e c t u r e chosen by the scheduler i s explored. I f the c o n j e c t u r e i s achieved, i t may then be e x p l o i t e d r e s u l t i n g i n the hypothesis of suggested higher c o n j e c t u r e s as new PK s t r u c t u r e s . These new schemata are added t o the p r i o r i t y queue and the process i s repeated. Freuder*s work has focused a t t e n t i o n on an important aspect of machine p e r c e p t i o n , the c o n t r o l of the processor d u r i n g the search process. He has combined the use of a schema-based r e p r e s e n t a t i o n with a h i e r a r c h y of cue invoked models. As v e i l , he d e f i n e s a p r i o r i t y queue m u l t i p r o c e s s i n q scheme t o i n t e q r a t e top-down and bottom-up se a r c h u s i n q m u l t i p l e a c t i v e hypotheses. SEEB r e a l i z e s top-down se a r c h by s i m u l a t i n q the e x p l o r a t i o n of c o n j e c t u r e s as subgoals and r e a l i z e s bottcm-up search by e x p l o i t i n q the consequences of s u c c e s s f u l l y recognized c o n j e c t u r e s . As was p o i n t e d out f o r KBL, the use of m u l t i p r o c e s s i n q to s i m u l a t e p a r a l l e l search s u f f e r s from a number of d e f i c i e n c i e s . I t i s a s y n t a c t i c , n o n - d e t e r m i n i s t i c method of s i m u l a t i n q p a r a l l e l e x e c u t i o n , and i s i n e p t at r e a l i z i n q i n t e l l i g e n t l y 2: Mechanisms f o r Machine P e r c e p t i o n 38 guided p a r a l l e l s e a r c h . The reguirement t h a t some procedure compute a p r i o r i t y f o r a new process manifests the "c h i c k e n and egg problem" i n two s i g n i f i c a n t ways. F i r s t , i t assumes that a procedure can a s s i g n a g l o b a l p r i o r i t y t o a process being placed on the p r i o r i t y queue based o n l y on i n f o r m a t i o n l o c a l t o t h a t procedure. And, more i m p o r t a n t l y , t h i s method r e q u i r e s that a p r i o r i t y be assigned t o a process before i n f o r m a t i o n i s di s c o v e r e d i n the scene to help decide which processes to run. The procedure t h a t p i c k s a p r i o r i t y f o r a process i s , i n e f f e c t , computinq a n o n - d e t e r m i n i s t i c s c h e d u l i n g of processes. T h i s computation must be made before the i n f o r m a t i o n r e q u i r e d t c make t h i s d e c i s i o n has been d i s c o v e r e d . T h i s mechanism operates e s s e n t i a l l y backwards. A mechanism i s needed f o r s i m u l a t i n g p a r a l l e l s e a r c h t h a t schedules processes s e m a n t i c a l l y by u t i l i z i n g the d i s c o v e r y of p a r t i c u l a r cues during the r e c o g n i t i o n process to schedule those processes which can e x p l o i t the e x i s t e n c e o f those very cues. 2: Mechanisms f o r Machine Pe r c e p t i o n 39 CHAPTER 3: A PROCEDURAL MODEL 3.1 I n t r o d u c t i o n T h i s chapter p r e s e n t s the development of a procedural model of r e c o g n i t i o n f o r schema-based r e p r e s e n t a t i o n s . The model i s motivated by both the c h a r a c t e r i z a t i o n of pe r c e p t i o n o u t l i n e d i n the f i r s t chapter and the c u r r e n t methodology of machine p e r c e p t i o n examined i n the second chapter. F i r s t , an i n f o r m a l overview of the model w i l l be given i n order to h i g h l i g h t a number of i t s a s p e c t s . Then i n the remainder of the chapter, t e c h n i q u e s f o r r e a l i z i n g the model as a computational mechanism w i l l be d i s c u s s e d i n d e t a i l . 3.2 Model Overview A theory of machine p e r c e p t i o n was c h a r a c t e r i z e d i n the f i r s t chapter as having both a formalism f o r r e p r e s e n t i n g knowledge and a s e t of s e a r c h mechanisms f o r performing r e c o g n i t i o n on that r e p r e s e n t a t i o n . 3: A Pr o c e d u r a l Model 40 3.2. 1 Schemata In t h i s model, knowledge i s represented as schemata. A schema i s a modular r e p r e s e n t a t i o n o f e v e r y t h i n g known about some concept, o b j e c t , event, or s i t u a t i o n . That knowledqe i s manifest i n t h r e e forms. F i r s t , each schema c o n t a i n s f a c t u a l knowledge about the concept t h a t the schema r e p r e s e n t s . Such f a c t s form a d e s c r i p t i o n o f the concept and may be represented d e c l a r a t i v e l y , p r o c e d u r a l l y , o r as some combination of data and attached procedures. Second, each schema may c o n t a i n p r o c e d u r a l h e u r i s t i c knowledge to guide the search process f o r the schema's concept. And t h i r d , schemata form r e l a t i o n s with other schemata thereby c r e a t i n g h i e r a r c h i c a l network s t r u c t u r e s . T h i s a l l o w s complex concepts t o be rep r e s e n t e d by composition as networks of schemata and provi d e s an e n c y c l o p e d i c r e t r i e v a l mechanism analogous to t h a t of semantic networks (Q u i l l i a n , 1 9 6 8 ) . For example. F i g u r e 3.1 i l l u s t r a t e s a schema f o r a h y p o t h e t i c a l v i s i o n system. The n o t a t i o n employed i s s i m i l a r to t h a t used by Bobrow and Hinograd (1977). This schema r e p r e s e n t s a s t e r e o t y p i c a l b i c y c l e and c o n s i s t s o f a s e t of named r e l a t i o n s or s l o t s (Minsky, 1975), each c o n t a i n i n g e i t h e r a p r i m i t i v e value ( o f t e n a name), a p o i n t e r to another schema, c r an e x p e c t a t i o n i n d i c a t i n g what type of i n f o r m a t i o n may be used to f i l l the s l o t . When the b i c y c l e s t e r e o t y p e i s used t o re p r e s e n t an i n s t a n c e of a p a r t i c u l a r b i c y c l e , the st e r e o t y p e schema i s copied t o c r e a t e a schema i n s t a n c e and i t s s l o t s , i n i t i a l l y 3: A P r o c e d u r a l Model 41 NAME: BICYCLE FRONT-WHEEL: (A WHEEL DIAMETER = (RANGE 19 27) WITH (A TIRE WIDTH = NARROW) TYPE = SPOKED CONNECT (AND FRAME CRANK SET) (TD-METHOD FIND-BIKE-WHEEL) (BO-METHOD FOUND-BIK E-WHEEL)} REAR-WHEEL: (A WHEEL DIAMETER = (RANGE 19 27) FRAME: (A FRAME WITH (A TIRE WIDTH = MRROW) TYPE = SPOKED CONNECT (AND FRAME CRANKSET) (TD-METHOD FIND- BIKE-WHEEL) (BU-METHOD FOUND-BIKE-WHEEL)) TYPE = DOUBLE-DIAMOND (TD-METHOD FIND-BIKE-FRAME) (BU-METHOD FOUND-BIKE—FRAME)} CRANKS ET: (A MECHANISM TYPE = CHAIN-DRIVE WITH (A PEDAL-CRANK) MAY-HAVE (A MECHANISM TYPE =DERAILLEUR) (TD—METHOD FIND-CRAKKSET) ) STEERING-SET: (A MECHANISM TYPE = STEERING-FORK WITH (A HANDLE—EAR) (TD-METHOD FIND-STEERING-SET) ) ISA: VEHICLE INSTANCES: NIL j F i g u r e 3.1: B i c y c l e Schema 3: A Pro c e d u r a l Model 12 c o n t a i n i n g e x p e c t a t i o n s , are r e p l a c e d s y s t e m a t i c a l l y by i n f o r m a t i o n s p e c i f i c t o the b i c y c l e as i t i s dis c o v e r e d . T h i s s t e r e o t y p e b i c y c l e schema i l l u s t r a t e s a number of f e a t u r e s of the r e c o g n i t i o n model. The f i r s t s l o t of the schema s p e c i f i e s t h a t the name of the schema i s BICYCLE. By naming each s t e r e o t y p e schema, i t can be r e f e r r e d to e i t h e r by a p o i n t e r or by simply using i t s name. The next f i v e s l o t s i n the schema represent composition knowledge about b i c y c l e s . A b i c y c l e i s composed of a f r o n t wheel, a r e a r wheel, a double-diamond frame, a power t r a n s m i s s i o n mechanism c a l l e d a crankset, and a s t e e r i n g f o r k mechanism c a l l e d a s t e e r i n g - s e t . For p e r c e p t i o n , the composition r e l a t i o n s i n a s t e r e o t y p e schema de f i n e those s t r u c t u r a l and f u n c t i o n a l a s p e c t s of the concept that can be used t o re c o g n i z e i n s t a n c e s o f that concept. A b i c y c l e i s re c o g n i z e d by the d i s c o v e r y of i t s component p a r t s composed i n a way t h a t r e p r e s e n t s the g e s t a l t of a b i c y c l e . 3.2.2 Schema H i e r a r c h i e s Schemata form h i e r a r c h i c a l networks i n two s i g n i f i c a n t ways. Complex s t e r e o t y p i c a l concepts are represented by schemata which are a composition o f other concepts represented by sub-schemata. The r e s u l t i n g h i e r a r c h i c a l s t r u c t u r e i s c a l l e d a composition h i e r a r c h y . T h i s s t a t i c h i e r a r c h y r e p r e s e n t s the composition of a l l p o s s i b l e i n s t a n c e s of the c l a s s . 3: A Procedural Model 43 F i g u r e 3.2 shows a composition h i e r a r c h y f o r the s t e r e o t y p i c a l b i c y c l e schema. B i c y c l e s are composed of wheels, a frame, and v a r i o u s mechanical mechanisms. Each of these g e n e r i c components form a s t e r e o t y p i c a l c l a s s of o b j e c t s represented by a s t e r e o t y p e schema. In t u r n , each of the these s t e r e o t y p e s i s composed of i t s own g e n e r i c components represented by s t e r e o t y p e sub-schemata. For i n s t a n c e , the WHEEL schema r e p r e s e n t s the c l a s s o f a l l wheels. Each wheel i n s t a n c e w i l l be composed of a t i r e , r im, and c e n t r a l hub assembly. A p a r t i c u l a r wheel w i l l be represented by a s p e c i f i c t i r e i n s t a n c e of a p a r t i c u l a r type and by s p e c i f i c i n s t a n c e s of the s t e r e o t y p e rim and hub schemas as w e l l . Figure 3.2 a l s o i l l u s t r a t e s the i n c l u s i o n i n the model of an i n v e r s e composition r e l a t i o n between schemata. For each s t e r e o t y p e schema having a composition r e l a t i o n with one or more sub-schemata, each o f these sub-schemata have an i n v e r s e r e l a t i o n with t h a t schema. T h i s r e l a t i o n i s o s u a l l y c a l l e d the " p a r t - o f " r e l a t i o n and i s e s s e n t i a l t o performing bottom-up search w i t h i n the schemata network. Schemata form h i e r a r c h i e s i n a second way. Each schema r e p r e s e n t s a s t e r e o t y p i c a l concept that may have many p a r t i a l l y s p e c i f i e d i n s t a n c e s . These i n s t a n c e s may themselves f u n c t i o n as s t e r e o t y p e schemata each having a number of more f u l l y s p e c i f i e d i n s t a n c e s . In t h i s manner, schemata form i n s t a n c e h i e r a r c h i e s ^ At the top of an i n s t a n c e h i e r a r c h y i s a schema r e p r e s e n t i n g an u n i n s t a n t i a t e d g e n e r i c concept. Each of i t s sub-schemata 3: A Procedural Model F i g u r e 3.2: B i c y c l e Composition H i e r a r c h y 3: A Procedural Model 45 i n s t a n c e s r e p r e s e n t p a r t i a l l y s p e c i f i e d occurrences of that concept. Each of the descendants of these i n s t a n c e s , i n turn, r e p r e s e n t s more f u l l y s p e c i f i e d i n s t a n c e s u n t i l , a t the bottom of the r e s u l t i n g t r e e s t r u c t u r e , completely s p e c i f i e d i n s t a n c e s become le a v e s of the t r e e . Instance h i e r a r c h i e s are a l s o r e f e r r e d to as "ISA" h i e r a r c h i e s (Fahlman, 1975). At each i n t e r i o r node i n an i n s t a n c e h i e r a r c h y , the p a r t i a l l y i n s t a n t i a t e d schema r e p r e s e n t s a n o n - d e t e r m i n i s t i c d e s c r i p t i o n of a s m a l l e r c l a s s of concepts than i t s parent s t e r e o t y p e a l e v e l above. Schemata near the top of the i n s t a n c e h i e r a r c h y r e p r e s e n t l a r g e c l a s s e s of p o s s i b l e i n s t a n c e s , whereas, schemata nearer the bottom r e p r e s e n t s m a l l e r , more f u l l y s p e c i f i e d c l a s s e s of concepts. In the b i c y c l e schema, the l a s t two s l o t s of the schema e s t a b l i s h an i n s t a n c e h i e r a r c h y . Since b i c y c l e s are i n s t a n c e s of the more gen e r a l concept of v e h i c l e , the ISA r e l a t i o n i n d i c a t e s that t h i s schema i s an i n s t a n c e of another s t e r e o t y p e , the VEHICLE schema. In t h i s example, the b i c y c l e schema has, as y e t , no i n s t a n c e s o f i t s own, as i n d i c a t e d by the NIL value f o r the INSTANCES r e l a t i o n . These two h i e r a r c h i e s serve d i f f e r e n t purposes. Composition h i e r a r c h i e s are s t a t i c data s t r u c t u r e s that f a c i l i t a t e r e p r e s e n t i n g complex conceptual o b j e c t s . The c r e a t i o n of a p a r t i c u l a r b i c y c l e i n s t a n c e uses the b i c y c l e composition h i e r a r c h y as a template from which to c o n s t r u c t the schema i n s t a n c e . Each occurrence of an e x p e c t a t i o n f o r a frame, 3: A Procedural Model 46 mechanism, or wheel i n the b i c y c l e s t e r e o t y p e w i l l be r e p l a c e d by an i n s t a n c e (perhaps only p a r t i a l l y s p e c i f i e d ) of t h a t s t e r e o t y p e . In c o n t r a s t , i n s t a n c e h i e r a r c h i e s are dynamic data s t r u c t u r e s t h a t provide a primary a s s o c i a t i v e r e t r i e v a l mechanism upon which t o base search over the schemata network. These h i e r a r c h i e s are viewed as taxonomies of concepts. Each node i n an i n s t a n c e h i e r a r c h y i s a ste r e o t y p e schema t h a t maintains an index o f a l l i t s i n s t a n c e s . For small data-bases, the schema's index can be a simple l i s t of a l l i t s i n s t a n c e s . For l a r g e r networks, each schema maintains an index of i t s sub-in s t a n c e s based on observable and r e c o g n i z a b l e cues. The i n s t a n c e h i e r a r c h y then becomes an i n v e r t e d index s t r u c t u r e f o r performing a s s o c i a t i v e r e t r i e v a l i n the network. analogous s y n t a c t i c mechanisms i n c l u d e EPAM (Feigenbaum, 1963) and the a s s o c i a t i v e r e t r i e v a l o f p a t t e r n s i n most a r t i f i c i a l i n t e l l i g e n c e programming languages (Bobrow S Raphael, 1974). P a t t e r n s are indexed i n a t r e e s t r u c t u r e d database by common pa t t e r n elements. A s i m i l a r semantic mechanism i s found i n the Linnaean b o t a n i c a l taxonomy where, f o r i n s t a n c e , p l a n t l i f e i s organized i n t o a h i e r a r c h i c a l database indexed by e a s i l y p e r c e i v e d cues. The cues used are p h y s i c a l observable p r o p e r t i e s o f each c l a s s c f pl a n t l i f e . The c h o i c e of cues i s not made from a p r i o r i c o n s i d e r a t i o n s , but f o r convenience. Cues are r e c o g n i z a b l e f e a t u r e s o f each c l a s s t h a t are e a s i l y observed and can f u n c t i o n as r e l i a b l e d i s c r i m i n a t o r s . 3: A Pr o c e d u r a l Model 47 In t h i s r e c o g n i t i o n model, i n s t a n c e h i e r a r c h i e s are indexed by cues t h a t are e a s i l y r e c o g n i z e d f e a t u r e s of a s t e r e o t y p e c l a s s . For example, c o n s i d e r an i n s t a n c e h i e r a r c h y f o r the wheel schema. The s t e r e o t y p e wheel schema r e p r e s e n t s the c l a s s of a l l wheels i n c l u d i n g a l l p a r t i a l l y and f u l l y s p e c i f i e d i n s t a n c e s . For a s m a l l number of wheel i n s t a n c e s , the database can be organized as a simple l i s t o f i n s t a n c e s bound to a v a r i a b l e i n the wheel s t e r e o t y p e . The advantage of t h i s scheme»s s i m p l i c i t y i s balanced by the n e c e s s i t y of s e a r c h i n g the l i s t s e q u e n t i a l l y t o f i n d a p a r t i c u l a r wheel i n s t a n c e . Such a b l i n d search makes no use of any observable f e a t u r e s of the d e s i r e d i n s t a n c e used as cues. For l a r g e r databases, the i n v e r t e d index s t r u c t u r e i s advantageous. F i g u r e 3.3 i l l u s t r a t e s an a s s o c i a t i v e database f o r the wheel i n s t a n c e h i e r a r c h y usinq t h i s scheme. I n d i c e s of the h i e r a r c h y are chosen to be r e a d i l y observable f e a t u r e s of wheels t h a t can e f f e c t i v e l y d i s c r i m i n a t e amonq v a r i o u s c l a s s e s of wheels. In t h i s example, three d i f f e r e n t observable f e a t u r e s of wheels are used. Neither the s t r u c t u r e of the h i e r a r c h y nor the c h o i c e of indexed f e a t u r e s i s made from a p r i o r i c o n s i d e r a t i o n s . The c h o i c e o f both s t r u c t u r e and index i s a r b i t r a r i l y based on the a b i l i t y t o d i s c r i m i n a t e amonq v a r i o u s wheels usinq such a v a i l a b l e i n f o r m a t i o n as the type of the observed wheel's rim, the width of i t s t i r e , and i t s diameter. Each of these f e a t u r e s , as i n the Linnaean taxonomy, i s a cue r e c o q n i z a b l e d u r i n g the p e r c e p t i o n process. 3: A P r o c e d u r a l Model 48 F i g u r e 3.3: Indexed Instance H i e r a r c h y 3: A Procedural Kodel 3.2.3 Recognizers P e r c e p t i o n i s not a p a s s i v e r e f l e c t i o n of s e n s a t i o n but an a c t i v e process motivated by p l a n s , e x p e c t a t i o n s , and d e s i r e s ( B a r t l e t t , 1932). P e r c e p t i o n i s a r e c o g n i t i o n task t h a t composes a d e s c r i p t i o n of a p e r c e i v e d concept from a seguence of e x t e r n a l o b s e r v a t i o n s o f the world. T h i s concept i s represented as a schema i n s t a n c e which i s composed of r e l a t i o n s h i p s among other more p r i m i t i v e concepts. In t h i s model, each s t e r e o t y p e schema i s c o n s i d e r e d to be an a c t i v e r e c o g n i z e r f o r i t s s t e r e o t y p i c a l concept, an i n d i v i d u a l r e c o g n i z e r i n a system of such r e c o g n i z e r s . Every schema c o n t a i n s the a c t i v e knowledge necessary to guide the r e c o g n i t i o n process f o r i t s concept from senscry o b s e r v a t i o n s . Such a c t i v e h e u r i s t i c knowledge i s c a l l e d a method. Methods are procedures s p e c i f i c a l l y t a i l o r e d f o r the r e c o g n i t i o n of t h e i r a s s o c i a t e d schemata. Methods allow the e x p l o i t a t i o n of domain s p e c i f i c s e arch techniques. Instead of r e l y i n g on g e n e r a l search methods to conduct the search f o r every schema i n the system, s p e c i f i c methods can be a s s o c i a t e d with p a r t i c u l a r schemata t o e x p l o i t s p e c i a l techniques t h a t are p a r t i c u l a r l y e f f e c t i v e f o r t h a t schema. The e x p e c t a t i o n s a s s o c i a t e d with s t e r e o t y p e schemata play an important r o l e i n the r e c o q n i t i o n process. They are dynamic p r o p e r t i e s o f each schema t h a t chanqe as the u n i n s t a n t i a t e d i n s t a n c e proceeds towards beinq f u l l y s p e c i f i e d . At each p o i n t 3: A P r o c e d u r a l Model 50 i n the process, the schema's e x p e c t a t i o n s r e p r e s e n t what a d d i t i o n a l i n f o r m a t i o n i s r e q u i r e d t o complete i t s r e c o g n i t i o n . From a d i f f e r e n t p e r s p e c t i v e , they r e p r e s e n t the schema's knowledge of the world: what i t expects t o occur next c r be found next from o b s e r v a t i o n . E x p e c t a t i o n s embody the notion of a plan or s c r i p t (Schank & Abelson, 1975). E x p e c t a t i o n s may be represented by simple d e f a u l t values to be r e p l a c e d by observed values when they are d i s c o v e r e d , or they may be rep r e s e n t e d by complex p a t t e r n s with attached p r o c e d u r a l methods. These attached methods use both top-down and bottom-up search mechanisms. Top-down methods are designed to search f o r i n f o r m a t i o n to s a t i s f y the requirements of i t s e x p e c t a t i o n . Bottom-up methods are designed t o continue the r e c o g n i t i o n of t h e i r schemata based on s a t i s f a c t i o n of t h e i r a s s o c i a t e d e x p e c t a t i o n s . The n o t i o n s of these two d i f f e r e n t types of pr o c e d u r a l methods are s i a i l a r t o the c h a r a c t e r i z a t i o n of Servants and Demons proposed by Bobrow and Winograd (1977). In the b i c y c l e schema c f F i g u r e 3.1, e x p e c t a t i o n s are represented as d e c l a r a t i v e s p e c i f i c a t i o n s of the type of schema i n s t a n c e s which may r e p l a c e the e x p e c t a t i o n i n the s l o t . Each of these e x p e c t a t i o n s has e i t h e r or both a top-down method and bottom-up method a s s o c i a t e d with i t . For example, both the f r o n t and r e a r wheel s l o t s of the b i c y c l e schema c o n t a i n e x p e c t a t i o n s t h a t s p e c i f y a spoked wheel with a narrow t i r e having a diameter between 19 and 27 i n c h e s . Attached t o these e x p e c t a t i o n s are s p e c i f i c methods t a i l o r e d f o r the r e c o g n i t i o n 3: A P r o c e d u r a l Bodel 51 of b i c y c l e wheels. Two d i f f e r e n t methods are s p e c i f i e d . One method, FIND-BIKE-WHEEL, i s a h y p o t h e s i s - d r i v e n procedure tthich can be c a l l e d upon t o attempt top-down search t o f i l l the wheel s l o t . The second method, c a l l e d FO0ND-BIKE-HHEEL, i s a procedure f o r performing bottom-up search. I t w i l l be invoked when a wheel matching the s p e c i f i e d e x p e c t a t i o n s f o r a b i c y c l e wheel has been recog n i z e d . I t s f u n c t i o n i s to f i r s t r e p l a c e the e x p e c t a t i o n i n the wheel s l o t with the new recognized wheel i n s t a n c e , then to continue the r e c o g n i t i o n process f o r the b i c y c l e u t i l i z i n g the knowledge gained by the d i s c o v e r y cf the new wheel. 3.2.4 Non-Determinism U n f o r t u n a t e l y , p e r c e p t i o n i s not a d e t e r m i n i s t i c process. P e r c e p t i o n r e q u i r e s the s e a r c h of a knowledge base to a s s i g n an i n t e r p r e t a t i o n t o sensory i n p u t . For l a r g e knowledge bases, t h i s search cannot be a simple top-down g o a l - d i r e c t e d process. Our knowledge of the world i s f a r too complex to r e l y s o l e l y on g o a l - d i r e c t e d search mechanisms. Ne i t h e r can the search be a completely bottcm-up process d r i v e n by o b s e r v a t i o n . Sensory data i s too ambiguous to permit a r e l i a n c e on purely d a t a - d r i v e n mechanisms. Machine p e r c e p t i o n must u t i l i z e an i n t e g r a t i o n cf both g o a l - d i r e c t e d and d a t a - d r i v e n search. Bobrow and Norman (1975) have c a l l e d these two modes, c o n c e p t u a l l y - d r i v e n and d a t a - d r i v e n . G o a l - d i r e c t e d or c o n c e p t u a l l y - d r i v e n search 3: 8 Procedural Kodel 52 p r o v i d e s a c t i v e guidance based on d o m a i n - s p e c i f i c knowledge of the hypothesis being attempted, whereas d a t a - d r i v e n search u t i l i z e s the o b s e r v a t i o n o f cues to i n t e l l i g e n t l y s e l e c t l i k e l y hypotheses. In t h i s r e c o g n i t i o n model, schemata may employ both h y p o t h e s i s - d r i v e n and d a t a - d r i v e n methods to perform the r e c o g n i t i o n process. H y p o t h e s i s - d r i v e n r e c o g n i t i o n i n v o l v e s a top-down search of a composition h i e r a r c h y . Schemata attempt to r e c o g n i z e i n s t a n c e s of t h e i r s t e r e o t y p e s by making o b s e r v a t i o n s from sensory i n p u t and by r e c u r s i v e l y c a l l i n g on the e f f o r t s of t h e i r sub-schemata as subgoals. In order to r e c o g n i z e a b i c y c l e u sing top-down s e a r c h , the b i c y c l e schema attempts to look f o r sub-schemata i n s t a n c e s that s a t i s f y i t s e x p e c t a t i o n s . To do so i t w i l l invoke i t s own top-down methods a s s s o c i a t e d with each o f i t s e x p e c t a t i o n s i n some l i k e l y order. Each of these methods w i l l then attempt to r e c o g n i z e s u i t a b l e sub-schemata by c a l l i n g on the methods of those schemata as subgoals. To r e a l i z e bottom-up, d a t a - d r i v e n search i n schemata networks r e g u i r e s t h a t m u l t i p l e hypotheses be allowed to e x i s t s i multaneously. S i n c e the r e c o g n i t i o n of the schemata r e p r e s e n t i n g these hypotheses are conducted by p r o c e d u r a l methods, these methods must be allowed to apply t h e i r h e u r i s t i c techniques c o n c u r r e n t l y . In bottom-up s e a r c h , t h e r e f o r e , methods are r e a l i z e d as concurrent processes. In t h i s model, a m u l t i - p r o c e s s i n q mechanism f o r s i m u l a t i n q concurrent methods i s 3: A Procedural Model 53 based on the notion o f deductive method s c h e d u l i n g . A p a r t i c u l a r method, r e a l i z e d as a process, a p p l i e s i t s h e u r i s t i c techniques to the r e c o g n i t i o n of i t s schema's s t e r e o t y p e u n t i l one or more of the schema's e x p e c t a t i o n s prove d i f f i c u l t to achieve. The method may then suspend i t s e x e c u t i o n by c r e a t i n g new e x p e c t a t i o n s f o r the schema t h a t d e s c r i b e i t s u n r e a l i z e d o b j e c t i v e s . I t remains attached to these new e x p e c t a t i o n s u n t i l such time as more evidence i s d i s c o v e r e d matching those e x p e c t a t i o n s and sup p o r t i n g the renewed p r o b a b i l i t y of the schema's success. When such matching evidence i s d i s c o v e r e d , the suspended method i s resumed. Methods i t e r a t e through a c y c l e of being resumed by the d i s c o v e r y of matching evidence, then computing a new set of e x p e c t a t i o n s about t h e i r e v o l v i n g schema i n s t a n c e s , and then suspending themselves and p o s s i b l y ether methods to those e x p e c t a t i o n s . Since m u l t i p l e methods may be attached to m u l t i p l e e x p e c t a t i o n s , these e x p e c t a t i o n s r e p r e s e n t d i v e r s e p o s s i b l e d i r e c t i o n s f o r a schema's s c r i p t . The choice of search path i s not made by b l i n d h y p o t h e s i s but i s d a t a - d r i v e n , chosen by the d i s c o v e r y o f evidence matching a p a r t i c u l a r e x p e c t a t i o n . The method a s s o c i a t e d with t h a t e x p e c t a t i o n i s then a c t i v a t e d t o continue i t s schema's r e c o g n i t i o n . A branch i n the schema's n o n - d e t e r m i n i s t i c s c r i p t has been taken. In the f o l l o w i n g s i t u a t i o n , f o r example, a wheel i n s t a n c e has been re c o g n i z e d i n the i n p u t scene. I t s f e a t u r e s match the e x p e c t a t i o n s o f e i t h e r the f r o n t or r e a r wheel s l o t s cf the 3: A Procedural Model 54 b i c y c l e schema. Both of the bottom-up methods a s s o c i a t e d with these e x p e c t a t i o n s may be a c t i v a t e d . He assume t h a t the f r o n t wheel's e x p e c t a t i o n i s matched f i r s t and i t s method invoked. T h i s bottom-up method w i l l e x p l o i t the f a c t t h a t a f r o n t wheel has been d i s c o v e r e d to guide the search f o r ether p a r t s of the b i c y c l e . Since the f r o n t wheel has a CONNECT r e l a t i o n with the s t e e r i n g - s e t , the method loo k s i n the neighborhood of i t s known wheel i n the i n p u t scene f o r the remainder of the b i c y c l e . Such an a p p l i c a t i o n of common-sense knowledge i s r e a l i z e d as a bottom-up proce d u r a l method a s s o c i a t e d with a p a r t i c u l a r schema. For t h i s example, we assume that t h i s bottom-up method does not e a s i l y d i s c o v e r s i g n i f i c a n t i n f o r m a t i o n i n the v i c i n i t y of the known wheel i n s t a n c e . Instead of r e t a i n i n g c c n t r o l w a s t e f u l l y , i t computes a new set of e x p e c t a t i o n s f o r the b i c y c l e based on that i n f o r m a t i o n which i t has discerned. T y p i c a l of the e x p e c t a t i o n s which might be i n c l u d e d i s the d i s c o v e r y of a s t e e r i n g - s e t t h a t must be connected t c the s p e c i f i c wheel i n s t a n c e . I t s o r i e n t a t i o n must be above the wheel i n the scene, as i s normally the case f o r b i c y c l e s . These e x p e c t a t i o n s w i l l act as c o n s t r a i n i n g i n f o r m a t i o n on the search f o r new b i c y c l e components. The method suspends i t s e l f and p o s s i b l y other methods, as w e l l , t o these new e x p e c t a t i o n s . I f evidence matching one of these e x p e c t a t i o n s i s d i s c o v e r e d , i t s suspended method i s resumed to continue i t s techniques., using the new i n f o r m a t i o n . 3: A Procedural Kodel 55 3.2.5 Recursion P e r c e p t i o n i s a l s o a r e c u r s i v e process. The r e c o g n i t i o n of some concept may be used r e c u r s i v e l y as an i n t e r n a l cue i n the pe r c e p t i o n of more a b s t r a c t concepts. In t h i s model, cues can be p r i m i t i v e f e a t u r e s of the e x t e r n a l world or they can be a b s t r a c t i n t e r n a l f e a t u r e s r e p r e s e n t e d as schema i n s t a n c e s . When a method s a t i s f i e s a l l i t s schema's e x p e c t a t i o n s f o r a f u l l y s p e c i f i e d concept, t h a t i n s t a n c e becomes an i n t e r n a l high l e v e l cue. By a l l o w i n g cues t o be a r b i t r a r i l y complex concepts, a mechanism i s r e a l i z e d f o r a v o i d i n g the "chicken and egg problem" f o r schemata (Havens, 1976). S t a r t i n g at the sensory data l e v e l , p r i m i t i v e cues present i n the input can be used t o d r i v e the hyp o t h e s i s and r e c o g n i t i o n of l o w - l e v e l concepts. These f e a t u r e s then behave as high e r l e v e l cues s t i m u l a t i n g the hypo t h e s i s o f more a b s t r a c t i n t e r p r e t a t i o n s . T h i s bottcm-up r e c o g n i t i o n mechanism depends on the e x i s t e n c e of the i n v e r s e composition r e l a t i o n s ( P a r t - o f ) i n the schemata network. When a concept has been re c o g n i z e d , the completed i n s t a n c e uses i t s knowledge of what high e r schemata i n any composition h i e r a r c h i e s i t might p l a u s i b l y be pa r t o f . Attempts are then made to match the e x p e c t a t i o n s of those schemata. In t h i s model, p r i m i t i v e cues are dis c o v e r e d from f e a t u r e s e x t r a c t e d from the i n p u t image using c o n t e x t - f r e e cue d i s c o v e r y methods. In the v i s i o n domain, such technigues i n c l u d e region segmentation and l i n e - f i n d i n g a l g o r i t h m s . ; The p r i m i t i v e cues 3: A Pr o c e d u r a l Model 5 6 are matched a g a i n s t the e x p e c t a t i o n s of l o w - l e v e l schemata thereby a c t i v a t i n g t h e i r attached bottom-up methods. Each of these methods then attempts t o c o n f i r m i t s own schema's hypo t h e s i s . When one or more of these methods succeed, the r e c o g n i z e d schema i n s t a n c e becomes a h i g h e r - l e v e l cue using i t s i n v e r s e composition knowledge t o attempt to match the e x p e c t a t i o n s of higher schemata of which i t may be p a r t . T h i s r e c u r s i v e process i s seen to be a bottom-up r e c o g n i t i o n itodel f o r schemata d r i v e n by both p r i m i t i v e c o n t e x t - f r e e cues and a b s t r a c t c o n t e x t - s e n s i t i v e cues recognized r e c u r s i v e l y . To i l l u s t r a t e , when a wheel i s found i n the scene, i t s d i s c o v e r y becomes an a b s t r a c t cue i n the higher hypothesis of the b i c y c l e schema. The f a c t t h a t i t s recognized f e a t u r e s , such as type and s i z e , match the b i c y c l e ' s e x p e c t a t i o n s i n d i c a t e s that the b i c y c l e i s a l i k e l y h y p o thesis and that i t s methods should be invoked. T h i s i s c h a r a c t e r i z e d as a matching process between cue and e x p e c t a t i o n . Then, i f the b i c y c l e scheira i s e v e n t u a l l y s u c c e s s f u l i n r e c o g n i z i n g a b i c y c l e i n s t a n c e , that i n s t a n c e w i l l become a higher cue i n the r e c o g n i t i o n process, perhaps, i n t h i s example, h y p o t h e s i z i n g a c l a s s of scenes c o n t a i n i n g b i c y c l e s . , 3.3 E a r l e y ' s Algorithm In an attempt to develop computational mechanisms f o r r e a l i z i n g t h i s model, the author i n v e s t i g a t e d the formal 3: A P r o c e d u r a l Hodel 57 r e c o g n i t i o n models used i n p a r s i n g t h e o r y . The c o n t e x t - f r e e p a r s i n g domain can be viewed as a h i g h l y r e s t r i c t e d subset of the p e r c e p t u a l domain. C o n t e x t - f r e e p a r s i n g i s a r e c o g n i t i o n task t h a t a s s i g n s an i n t e r p r e t a t i o n to an input sentence based on a h i e r a r c h i c a l knowledge base, that i s , a c o n t e x t - f r e e p h r a s e - s t r u c t u r e grammar. The i n t e r p r e t a t i o n i s i n h e r e n t l y a r e c u r s i v e process f o r which both top-down and bottcm-up r e c o g n i t i o n a l g o r i t h m s have been developed e x h i b i t i n g well understood p r o p e r t i e s . In p a r t i c u l a r , the bottom-up p a r s i n g a l g o r i t h m of E a r l e y (1972) has some i n t e r e s t i n g p r o p e r t i e s from the p e r s p e c t i v e of machine p e r c e p t i o n , E a r l e y ' s a l g o r i t h m i s an e f f i c i e n t bottom-up r e c o g n i z e r t h a t can operate d i r e c t l y from any n c n - l e f t - r e c u r s i v e c c n t e x t - f r e e grammar. The a l g o r i t h m i s q u i t e e l e g a n t . I t can operate i n time order n 3 and space order n 2 where n i s the l e n g t h of the i n p u t sentence, Morever, i t does not r e q u i r e b a c k t r a c k i n g t o handle non-determinism. Appendix-A provides a formal p r e s e n t a t i o n of the a l q o r i t h m . In s t u d y i n g h i s a l g o r i t h m , not as a p a r s e r , but as a bookkeeping scheme f o r the s i m u l a t i o n of m u l t i p l e bottcm-up processes s i m u l t a n e o u s l y o p e r a t i n g on the same i n p u t sentence, i t was n o t i c e d that the algorithm dynamically i n v e r t s c e r t a i n p o r t i o n s of a h i e r a r c h y (the grammar) based on a s e l e c t i o n f u n c t i o n (the i n p u t sentence). The a l q o r i t h m operates from a c o n t e x t - f r e e qrammar and a s e t of v a l i d p a r s e r s . Each parser attempts t o r e c o g n i z e a complete s e n t e n t i a l form d e r i v e d from the r i g h t - h a n d - s i d e o f a p a r t i c u l a r r u l e i n the grammar. 3 : A P rocedural fcodel 58 I n i t i a l l y , the set c o n t a i n s only a s i n g l e parser which attempts to r e c o g n i z e a s e n t e n t i a l form d e r i v e d from the s t a r t symbol of the grammar. Such a d e r i v a t i o n w i l l be, of c o u r s e , a complete sentence i n the language. I f a non-terminal symbol may appear next i n the d e r i v a t i o n of any p a r s e r , new p a r s e r s are c r e a t e d f o r every r u l e i n the grammar having that non-terminal as i t s l e f t - h a n d - s i d e . T h i s f u n c t i o n i s c a l l e d p r e d i c t i o n i n the a l g o r i t h m . The a l g o r i t h m proceeds by scanning i n a l e f t - t o - r i g h t order each symbol i n the i n p u t sentence. I f the observed symbol can be a v a l i d next t e r m i n a l symbol i n the s e n t e n t i a l forms of any of the a c t i v e p a r s e r s i n the c u r r e n t parse l i s t , then those p a r s e r s are propagated i n t o the next parse l i s t . A l l ether p a r s e r s are d e l e t e d . The a l g o r i t h m scans the i n p u t once. I t hypothesizes new p a r s e r s by p r e d i c t i o n from the grammar when t h e i r r u l e can appear next i n the d e r i v a t i o n . Old parsers which cannot d e r i v e some p o r t i o n of the i n p u t sentence t o the c u r r e n t p o s i t i o n are then destroyed. E a r l e y * s a l g o r i t h m e x h i b i t s some i n t e r e s t i n g p r o p e r t i e s from the standpoint of a model of r e c o g n i t i o n f o r computer p e r c e p t i o n . The a l g o r i t h m p r o v i d e s a mechanism f o r implementing bottom-up search yet operates d i r e c t l y from a top-down h i e r a r c h y . P o r t i o n s of the h i e r a r c h y are dynamically i n v e r t e d , s e l e c t i v e l y , depending on what t e r m i n a l symbols are observed i n the input and what non-terminal symbols are recognized r e c u r s i v e l y from the i n p u t . These are appealing a t t r i b u t e s 3: A P r o c e d u r a l Kodel 59 s i n c e schema systems are o r g a n i z e d as top-down h i e r a r c h i e s and i t i s d e s i r e d t o d r i v e the bottom-up r e c o g n i t i o n process i y the d i s c o v e r y of both p r i m i t i v e and r e c o g n i z e d cues. As a bookkeeping scheme, E a r l e y ' s a l g o r i t h m i s a p p l i c a b l e not only t o p a r s i n g but a l s o t o m u l t i p r o c e s s i n g i n g e n e r a l . The a l g o r i t h m s y s t e m a t i c a l l y s i m u l a t e s m u l t i p l e c o - e x i s t e n t p a r s i n g processes o p e r a t i n g from the same h i e r a r c h y and on the same i n p u t . As w e l l , i t p r o v i d e s a s c h e d u l i n g mechanism based, not on emulating p a r a l l e l s e a rch, but on concurrent deduction. P a r s e r s remain suspended u n t i l such time as the t e r m i n a l or non-terminal symbol f o r which they are l o o k i n g i s d i s c o v e r e d . Then, each such matched p a r s e r i s resumed t o continue i t s r e c o g n i t i o n . The algorithm a l s o handles non-determinism n a t u r a l l y and e f f i c i e n t l y . When a t e r m i n a l symbol i s scanned cr a non-terminal symbol i s r e c o g n i z e d , the a l g o r i t h m propagates i n t o the next parse l i s t every suspended parser that was e x p e c t i n g t h a t c o n s t i t u e n t . A l l others are d e l e t e d . No b a c k t r a c k i n g i s r e q u i r e d . C o n s t i t u e n t s need be found only once i n the i n p u t and i n v a l i d i n t e r p r e t a t i o n s are d e l e t e d as soon as p o s s i b l e . Althouqh the above p r o p e r t i e s are d e s i r a b l e , there are a number of problems with adaptinq B a r l e y ' s a l q o r i t h m as a search mechanism f o r the q e n e r a l and more complex domain of p e r c e p t i o n . Minker (1973) has c o n s i d e r e d and r e j e c t e d i t s use as a problem space r e p r e s e n t a t i o n . Woods (1974) has f a v o r a b l y compared i t s a b i l i t i e s with those of h i s auqmented t r a n s i t i o n network 3: A Procedural Model 60 p a r s e r s . There appear to be three major d i f f i c u l t i e s i n h e r e n t i n t h i s approach. F i r s t , the process of p r e d i c t i n g which t e r m i n a l and non-terminal symbols may appear next i n the d e r i v a t i o n i s too top-down, e x h i b i t i n g aspects o f "the c h i c k e n and egg problem". For a l a r g e knowledge h i e r a r c h y , the p r e d i c t i o n process may have to tour very l a r g e branches of the h i e r a r c h y . In the p a r s i n g domain, t h i s i n e f f i c i e n c y can be t o l e r a t e d by s u i t a b l y r e s t r i c t i n g the grammars employed. For machine p e r c e p t i o n , no such r e s t r i c t i o n s of the knowledge base are f e a s i b l e . In s p i t e o f t h i s d i f f i c u l t y , Kaplan (1973) has proposed a s i m i l a r p r e d i c t i o n scheme f o r c r e a t i n g p a r a l l e l i n t e r p r e t a t i o n s i n h i s p a r s i n g system, GSP. Second, the a l g o r i t h m depends upon the s t r i c t s e q u e n t i a l nature of p a r s i n g to e f f i c i e n t l y l i m i t the p r o l i f e r a t i o n of p a r s e r s . A f t e r the next i n p u t symbol has propagated a l l p a r s e r s s t i l l v a l i d to the next parser s e t , a l l the remaining parsers can be d e l e t e d . They r e p r e s e n t i n v a l i d i n t e r p r e t a t i o n s of some p o r t i o n of the i n p u t sentence. In p e r c e p t i o n , however, some aspe c t s are encoded s e q u e n t i a l l y , such as the s u r f a c e form of n a t u r a l language. However, other aspects have very l i t t l e s e q u e n t i a l content, f o r example, image a n a l y s i s . Where sequence i s an e x p l i c i t part of p e r c e p t i o n , i t can be e f f e c t i v e l y used t o c o n s t r a i n i n v a l i d i n t e r p r e t a t i o n s , but an e f f i c i e n t p e r c e p t i o n mechanism must handle n o n - s e q u e n t i a l aspects as w e l l . The l a s t d i f f i c u l t y p e r c e i v e d with E a r l e y ' s a l q o r i t h m i s 3: A P r o c e d u r a l Model 61 t h a t the mode of search employed i s completely bcttom-up. There i s no top-down mode d e f i n e d . As has been s e e r , f o r p e r c e p t i o n , both top-down and bottom-up mechanisms are e s s e n t i a l . 3.4 Three Phases of R e c o g n i t i o n The c o n t e x t - f r e e p a r s i n g a l g o r i t h m of E a r l e y was shown to e x h i b i t a number of p r o p e r t i e s d e s i r a b l e f o r a r e c o g n i t i o n nsodel f o r machine pe r c e p t i o n . A few d i f f i c u l t i e s were a l s o noted. T h i s s e c t i o n develops a new r e c o g n i t i o n model f o r p e r c e p t i o n u s i n g some of the technigues developed by E a r l e y w h i l e , a t the same time, a v o i d i n g the d i f f i c u l t i e s i n h e r e n t i n h i s a l g o r i t h m . T h i s model supports both top-down and bottcm-up search i n schema-based r e p r e s e n t a t i o n s . The bottom-up mechanisms w i l l be e x p l a i n e d f i r s t s i n c e they are d e r i v e d , i n p a r t , from the previous d i s c u s s i o n . The r e c o g n i t i o n model c o n s i s t s of three phases, c a l l e d e x p e c t a t i o n , matching, and completion. 3.4.1 E x p e c t a t i o n The e x p e c t a t i o n phase of t h i s model i s analogous to the p r e d i c t i o n f u n c t i o n of E a r l e y ' s a l g o r i t h m . In the top-down r e c o g n i t i o n model f o r schemata given by Kuipers (1575), e x p e c t a t i o n s are d e s c r i b e d as s t a t i c p r o p e r t i e s of the s t e r e o t y p e which are s y s t e m a t i c a l l y r e p l a c e d by s p e c i f i c i n f o r m a t i o n as i t i s d i s c o v e r e d . In t h i s model, e x p e c t a t i o n s 3: A Procedural Model 62 are computed dynam i c a l l y d u r i n g the r e c o g n i t i o n process as a f u n c t i o n of the c u r r e n t p a r t i a l i n s t a n t i a t i o n c f the schema. At any p o i n t , a schema's e x p e c t a t i o n s r e p r e s e n t a n o n - d e t e r m i n i s t i c d e s c r i p t i o n of a l l p o s s i b l e f i n a l i n s t a n t i a t i o n s of the schema. Bound to each e x p e c t a t i o n i s a method designed to continue the r e c o g n i t i o n of the schema based on the s a t i s f a c t i o n of t h a t s p e c i f i c e x p e c t a t i o n . An i n s t a n c e h i e r a r c h y i s regarded, i n t h i s model, as a n o n - d e t e r m i n i s t i c r e p r e s e n t a t i o n of a general c l a s s of o b j e c t s . R e c o g n i t i o n i s c h a r a c t e r i z e d as the d i f f e r e n t i a t i o n of the st e r e o t y p e i n t o a s p e c i f i c i n s t a n c e . T h i s process of r e f i n i n g the e x p e c t a t i o n s of a s t e r e o t y p e towards a f u l l y s p e c i f i e d i n s t a n c e has been c a l l e d s p e c i a l i z a t i o n jBobrow & Wincgrad, 1977). In the top-down r e c o g n i t i o n model, however, a schema st e r e o t y p e i s portrayed as r e p r e s e n t i n g a p a r t i c u l a r c l a s s of o b j e c t s such as t a b l e s or c h a i r s . The r e c o g n i t i o n process r e s u l t s i n the d e s c r i p t i o n o f a p a r t i c u l a r t a b l e or c h a i r . I f , du r i n g t h i s process, the schema i s found to be i n a p p r o p r i a t e , a replacement schema must be s e l e c t e d by some s u b s t i t u t i o n procedure. In t h i s model, t h i s s u b s t i t u t i o n i s not necessary. The schema i n s t a n t i a t i o n i s c h a r a c t e r i z e d as being a process of d i f f e r e n t i a t i o n i n s t e a d o f s e l e c t i o n . 3: A Procedural Hodel 63 3.4.2 Matching The second phase of the model i s the matching phase. The e x p e c t a t i o n and matching phases form an i t e r a t i v e r e c o g n i t i o n c y c l e . In bottom-up r e c o g n i t i o n , the e x p e c t a t i o n s bound w i t h i n schemata are s a t i s f i e d by s u i t a b l e o b s e r v a t i o n s from some input medium or by the r e c u r s i v e r e c o g n i t i o n of other schemata. A f t e r a schema has c r e a t e d a s e t of e x p e c t a t i o n s and bound methods t o those e x p e c t a t i o n s , the e x p e c t a t i o n s may be matched by observed or recognized evidence, thereby a c t i v a t i n g the a s s o c i a t e d methods. Each method f i r s t i n c o r p o r a t e s the new evidence i n t o the e v o l v i n g i n s t a n c e of i t s schema's s t e r e o t y p e . I t may then c a l c u l a t e , based on t h i s new evidence, a next s e t of e x p e c t a t i o n s , suspending i t s e l f and perhaps other methods to these new e x p e c t a t i o n s . T h i s expectation/matching c y c l e may c o - e x i s t over time with the r e c o g n i t i o n c y c l e s o f many ether schemata. T h i s c y c l e r e a l i z e s a m u l t i p r o c e s s i n g mechanism f o r s i m u l a t i n g p a r a l l e l search. The matching phase depends on the a v a i l a b i l i t y of an a s s o c i a t i v e r e t r i e v a l mechanism i n the schemata network. New evidence, d i s c o v e r e d by o b s e r v a t i o n and deduction, must be ab l e t o f i n d those schemata c o n t a i n i n g e x p e c t a t i o n s which i t can match. Two such mechanisms are proposed, both of which i n v o l v e p a t t e r n matching over schema systems and are s i m i l a r to the extended concept of d e s c r i p t i o n matching advocated by Bobrcw and flinograd (1S77). In g e n e r a l however, the problem i s q u i t e 3: A P r o c e d u r a l Model 64 complex. Indeed, a comprehensive theory of deductive a s s o c i a t i v e r e t r i e v a l over semantic networks i s r e q u i r e d . This problem can be seen to be, r e c u r s i v e l y , t h e r e c o g n i t i o n problem. The f i r s t mechanism uses simple p a t t e r n matching and a s s o c i a t i v e r e t r i e v a l as i s f a m i l i a r i n the newer P l a n n e r - l i k e a r t i f i c i a l i n t e l l i g e n c e programming languages (Bobrow 8 Raphael, 1974). In t h i s system, the e x p e c t a t i o n s of a schema are represented as n - t u p l e p a t t e r n s i n a p a t t e r n a s s o c i a t i v e database c o n t a i n e d w i t h i n the schema. McCalla (1977) has advocated such an implementation f o r schemata i n a n a t u r a l language dialo g u e system. The second mechanism i n v o l v e s using the i n s t a n c e h i e r a r c h i e s as a s s o c i a t i v e databases. Such a taxcncmic o r g a n i z a t i o n w i t h i n the system of schemata prov i d e s the necessary r e t r i e v a l mechanisms t o support the matching phase of the r e c o g n i t i o n model. The matching process t h e r e f o r e i n v o l v e s a c u e - d r i v e n search over the schemata network i n c o n j u r c t i o n with s y n t a c t i c matching of e x p e c t a t i o n s represented as p a t t e r n s . 3.4.3 Completion A schema completes the r e c o g n i t i o n of an i n s t a n c e when a l l i t s e x p e c t a t i o n s are s a t i s f i e d . I t must r e t u r n t h a t success to higher schemata of which the i n s t a n c e can be a component pa r t . T h i s i s the completion phase of the r e c o g n i t i o n model and i s analogous to the completion f u n c t i o n of E a r l e y ' s a l g o r i t h m 3: A P r o c e d u r a l Model 6 5 (Appendix-fi,) . I f the completing schema's method was c a l l e d u s i n g top-down search as a subgoal. then the schema has an e x p l i c i t c a l l e r and must e v e n t u a l l y r e t u r n a success or f a i l u r e to t h a t c a l l e r . On the other hand, a schema's method nay be a c t i v a t e d using bottom-up search by having an a s s o c i a t e d e x p e c t a t i o n matched by some other process. T h i s method has no e x p l i c i t c a l l e r and i s r e f e r r e d t o as a s u p e r g o a l . The d i s t i n c t i o n between subgoals and supergoals i s based on the way i n which they are a c t i v a t e d . Subgoals are a c t i v a t e d as s u b r o u t i n e s attached t o the c a l l i n g r o u t i n e , whereas supergoals are a c t i v a t e d as processes whose e x i s t e n c e may continue a f t e r c o n t r o l has returned to the c a l l e r . Both types of methods are d i r e c t e d at completing the r e c o g n i t i o n of t h e i r schemata and both may use a combination of top-down and bottcm-up techniques to do so. When a supergoal has s a t i s f i e d i t s schema's i n t e r n a l requirements f o r the r e c o g n i t i o n o f an i n s t a n c e of the schema's s t e r e o t y p e , the r e c o g n i z e d concept becomes an a b s t r a c t cue. I t e n t e r s the matching phase by attempting to match the e x p e c t a t i o n s of those higher schemata of which the p a r t i c u l a r i n s t a n c e might be a p l a u s i b l e p a r t . . Such knowledge i s a v a i l a b l e to the completed schema i n s t a n c e through the i n v e r s e composition r e l a t i o n s of i t s s t e r e o t y p e . Figure 3 . 4 i l l u s t r a t e s both the c y c l i c and the r e c u r s i v e nature of t h i s process. For example, the r e c o g n i t i o n of Schema-1 at the f i r s t l e v e l i n the h i e r a r c h y may proceed over 3 : A Pro c e d u r a l Rodel 66 p r i m i t i v e cues from o b s e r v a t i o n c o n t e x t - f r e e F i g u r e 3.4: R e c o g n i t i o n C y c l e s 3: A Procedural Kodel 67 time with the r e c o g n i t i o n of other schemata. , Schema-1 may go through s e v e r a l c y c l e s c f c r e a t i n g e x p e c t a t i o n s , suspending i t s methods to those e x p e c t a t i o n s , and being resumed by matching p r i m i t i v e cues computed from the i n p u t data. When a l l the e x p e c t a t i o n s of Schema-1 have been s a t i s f i e d , i t then e n t e r s i t s completion phase. Since i t was not c a l l e d as a subgoal c f any higher schema, i t s d e s c r i p t i o n i s , i n e f f e c t , an a b s t r a c t h i g h - l e v e l cue. From the i n f o r m a t i o n contained i n t h i s d e s c r i p t i o n , i t attempts to match the e x p e c t a t i o n s of schemata a t the second l e v e l i n the h i e r a r c h y , i n t h i s case, Schema-2 and Schema-3. I f the match i s s u c c e s s f u l , the methods of one or both of these schemata are resumed as supergoals of Schema-1 to continue t h e i r r e c o g n i t i o n . T h e i r r e c o g n i t i o n may a l s c proceed through a number of expectation/matching c y c l e s c o n c u r r e n t with other r e c o g n i z e r s . But, u n l i k e Schema-1, t h e i r e x p e c t a t i o n s are matched by n o n - p r i m i t i v e cues recognized r e c u r s i v e l y as the r e s u l t of p e r c e p t i o n . Completion i s seen as a "handle" i n the r e c o g n i t i o n model f o r r e a l i z i n g a number of d e s i r a b l e f e a t u r e s c f a theory of machine p e r c e p t i o n . I t p r o v i d e s a mechanism f o r s i m u l a t i n g p a r a l l e l search v i a a d e d u c t i v e method s c h e d u l i n g scheme, f o r r e a l i z i n g a r e c u r s i v e cue/model h i e r a r c h y , f o r r e a l i z i n g method h i e r a r c h i e s , and f o r c o o r d i n a t i n g the e f f o r t s of concurrent methods. The remaining s e c t i o n s of t h i s chapter w i l l e x p l a i n how these f e a t u r e s are achieved i n the model. , In the a n a l y s i s o f E a r l e y * s a l g o r i t h m , i t was pointed out 3: fl Procedural Model 6 8 t h a t the p r e d i c t i o n phase may be c o m p u t a t i o n a l l y very expensive. In t h i s r e c o g n i t i o n model, the problem i s avoided by noting that the e x p e c t a t i o n phase f o r seme p a r t i c u l a r schema need net be performed u n t i l such time as another completing s u p e r g c a l or some input o b s e r v a t i o n attempts to match that schema. When a supergoal attempts to match a schema o f which i t can l i k e l y be p a r t , i t must f i r s t search f o r a p a r t i c u l a r i n s t a n c e of t h a t schema t o match. I f no such i n s t a n c e can be found, then the superg o a l c a l l s upon the schema s t e r e o t y p e to c r e a t e a new i n s t a n c e . Thereby, the e x p e c t a t i o n phase i s performed on l y when needed. 3 .5 Scheduling Proposals f o r s i m u l a t i n g p a r a l l e l search u s u a l l y employ a m u l t i p r o c e s s i n g scheme that r e l i e s on some g l o b a l a l g o r i t h m to a l l o c a t e the processor. fl popular technique i s a weighted t i m e - s l i c i n g mechanism based on a p r i o r i t y queue (Bobrow 6 Sinograd, 1977). T h i s type of mechanism i s e f f e c t i v e at s i m u l a t i n q the concurrent e v a l u a t i o n of procedures but i t i s not e f f e c t i v e at s i m u l a t i n q the p a r a l l e l a p p l i c a t i o n of n o n - d e t e r m i n i s t i c s e a r c h methods. The technique i s d i r e c t e d at s c h e d u l i n q processes, not a t the methods t h a t are implemented as processes. The scheme i s too low l e v e l . I t t y p i c a l l y f o r c e s the proqrammer to a s s i q n a q l o b a l numeric p r i o r i t y to a process when i t i s placed on the p r i o r i t y queue. 3 : A Procedural Model 69 A s c h e d u l i n g mechanism, o p e r a t i n g at a higher l e v e l , i s needed. Methods should become a c t i v e when t h e i r a p p l i c a b i l i t y t o the r e c o g n i t i o n process i s d i s c o v e r e d o r deduced, not when a process spontaneously reaches the f r o n t of a p r i o r i t y gueue. To i l l u s t r a t e t h i s f u r t h e r , c o n s i d e r an automatic deduction system that i s implemented i n a m u l t i p r o c e s s environment. The system i s attempting a complex proo f . One p a r t i c u l a r deductive process has shown c o n s i d e r a b l e promise but has been unable to achieve some r e s u l t , say P{x). The process decides to suspend i t s e l f u n t i l such time as another process has succeeded i n deducing P{x). In t h i s p r i o r i t y d r i v e n system, which p r i o r i t y should be assigned to t h i s suspended process? How does one a s s i g n a p r i o r i t y number to a process i n order t h a t i t wait f o r a s p e c i f i c s i t u a t i o n to occur? Obviously, a m u l t i p r o c e s s i n g scheme based on d e d u c t i v e s c h e d u l i n g i n s t e a d of simple p a r a l l e l i s m i s r e q u i r e d . Processes should be scheduled when t h e i r a p p l i c a b i l i t y to the system's task has been computed. The bottcm-up search problem i s not to simulate p a r a l l e l l i s m , t u t to c o o r d i n a t e the simultaneous e f f o r t s of m u l t i p l e methods. When a method achieves some i n t e r m e d i a t e r e s u l t , the sc h e d u l i n q mechanism should ask, "What methods are suspended w a i t i n q f o r t h i s r e s u l t ? " . The completion phase of the r e c o q n i t i o n model provides such a s c h e d u l i n q mechanism. In f a c t , the r e c o q n i t i o n model can be c h a r a c t e r i z e d as the computation of what methods should be scheduled next. Methods remain suspended to p a t t e r n s 3: A Procedural Model 7 0 r e p r e s e n t i n g e x p e c t a t i o n s u n t i l resumed e x p l i c i t l y by some lower completing supergoal. A method i s resumed when i t i s deduced t h a t the method co u l d be a p p l i c a b l e to the r e c o g n i t i o n process. A completing supergoal may resume, i n t u r n , the methods bound to e x p e c t a t i o n s of a l l higher schemata that i t s schema i n s t a n c e can succeed i n matching. Each such resumed method i s a c t i v a t e d a l s o as a supergoal and proceeds t o continue the r e c o g n i t i o n of i t s own schema. The r e c o g n i t i o n of a schema i n s t a n c e need be computed on l y once. By s e q u e n t i a l l y resuming more than one higher supergoal, a s i n g l e schema i n s t a n c e can be part of the r e c o g n i t i o n of m u l t i p l e higher schemata. No bac k t r a c k i n g of subgoals or use of s i m i l a r i t y network schemes i s r e q u i r e d . Each completing superqoal behaves as a h e u r i s t i c s c h e d u l i n g mechanism, resuming the methods of those higher schemata which i t i s s u c c e s s f u l at matching. That s c h e d u l i n g mechanism may be t a i l o r e d s p e c i f i c a l l y f o r each s i t u a t i o n . A s y n t a c t i c g l o b a l s c h e d u l e r i s not r e q u i r e d . For i n s t a n c e , a supergoal can resume highe r methods i n order of expected l i k e l i h o o d of a p p l i c a b i l i t y or i t can resume f i r s t only the methods of those schemata which alre a d y have e x i s t i n g i n s t a n c e s . I f none of those succeed, then i t can c r e a t e new schema i n s t a n c e s to match, thereby saving the expense of the e x p e c t a t i o n process u n t i l i t i s needed. The completion mechanism can be c h a r a c t e r i z e d as a bottom-up generator i n c o n t r a s t t o the top-down generators cf Conniver. When a completing method matches a higher superqoal, i t i s generating a p o s s i b l e successor process. I t t o u r s a 3: A P r o c e d u r a l Model 71 schema h i e r a r c h y i n i n v e r t e d , bottom-up order. The completing method's computations are suspended while the higher schema's supergoal attempts t o complete i t s r e c o g n i t i o n . I f c o n t r o l r e t u r n s to the completing method, i t w i l l then generate the next p o s s i b l e higher s u p e r g o a l . T h i s mechanism i s a generator f o r bottom-up search i n s t e a d of top-down search. 3.6 Method H i e r a r c h i e s I t i s c l e a r t h a t machine p e r c e p t i o n must u t i l i z e h e u r i s t i c d o m a i n - s p e c i f i c search knowledge i n order t o cope with the complexity of the p e r c e p t u a l process. By i n c o r p o r a t i n g t h i s knowledge as p r o c e d u r a l methods a s s o c i a t e d with s t e r e o t y p i c a l schemata i n a composition h i e r a r c h y , a method h i e r a r c h y {Newell. 1972) isomorphic to the composition h i e r a r c h y i s termed. Methods e x h i b i t a t r a d e o f f between a p p l i c a b i l i t y and power. Methods a p p l i c a b l e t o a l a r g e c l a s s of search problems are i n h e r e n t l y i n e f f i c i e n t f o r any s p e c i f i c problem. Conversely, methods h e u r i s t i c a l l y engineered f o r the accomplishment of a narrow s p e c i f i c t a s k can achieve power and e f f i c i e n c y . A comprehensive r e c o g n i t i o n scheme f o r p e r c e p t i o n must i n c l u d e p r o v i s i o n s f o r such a method h i e r a r c h y to i n t e l l i g e n t l y guide the search process. In the p u r e l y top-down r e c o g n i t i o n model, a method h i e r a r c h y c a p a b i l i t y i s s t r a i g h t f o r w a r d . The methods a s s o c i a t e d with each schema may be c r e a t e d s p e c i f i c a l l y to search f o r 3: A Pro c e d u r a l Model 72 i n s t a n c e s of t h a t schema. The h i e r a r c h y i s r e a l i z e d by the f a c t t h a t , i n top-down search, schemata c a l l on the e f f o r t s of ether schemata as subgoals. Each l e v e l of s u b g o a l i n g a p p l i e s a more powerful and s p e c i f i c method t o the achievement of t h a t p a r t i c u l a r subgoal. In bottom-up s e a r c h , however, a c h i e v i n g a method h i e r a r c h y i s not so s t r a i g h t f o r w a r d . M u l t i p l e methods may be a c t i v e s i m u l t a n e o u s l y . Which method should, at any given i n s t a n t , d i r e c t the search process? Most bottom-up search schemes have used a s i n g l e t o p - l e v e l method t o d r i v e the o p e r a t i o n cf the system <Waltz, 1972) (Mackworth, 1977a). M u l t i p r o c e s s i n g schemes t y p i c a l l y a l t e r n a t e t h e a p p l i c a t i o n of methods as processes which are run and then suspended again on the p r i o r i t y gueue. There i s , however, poor c o o r d i n a t i o n between a l t e r n a t i n g methods. The f o l l o w i n g mechanism i s u t i l i z e d t c r e a l i z e a method h i e r a r c h y i n bottom-up search. As has been d e s c r i b e d , a supergoal method can compute, based on the p a r t i a l i n s t a n t i a t i o n of i t s schema, a next s e t of e x p e c t a t i o n s . I t may then suspend other methods to p a t t e r n s w i t h i n the schema r e p r e s e n t i n g those e x p e c t a t i o n s . A f t e r the method has performed the e x p e c t a t i o n phase, i t can e i t h e r t e r m i n a t e i t s e x e c u t i o n , r e l i n q u i s h i n g c o n t r o l t o some higher method, or i t can remain a c t i v e , r e t a i n i n g access to the p r o c e s s o r . T h i s mechanism provides e f f e c t i v e l y an e x t r a "degree of freedom" i n the search process. I f the method r e l i n q u i s h e s c o n t r o l , then i t i s r e l y i n g oc the 3: A P r o c e d u r a l Model 73 e f f o r t s of other methods to d i s c o v e r evidence t h a t w i l l match i t s schema's e x p e c t a t i o n s . On the other hand, i f the reethod r e t a i n s c o n t r o l of the proc e s s o r , i t may use i t s own s p e c i a l i z e d knowledge to d i r e c t the d i s c o v e r y and deduction of evidence to s a t i s f y i t s own e x p e c t a t i o n s . T h i s mechanism a l l o w s each schema the choice of a p p l y i n g i t s own s p e c i a l i z e d h e u r i s t i c knowledge to d i r e c t the search process or y i e l d i n g t o the h e u r i s t i c s of h i g h e r , more g e n e r a l methods. In top-down s e a r c h , each method, as a subgoal, i s f o r c e d t o d i r e c t the search process r e g a r d l e s s of the schema's a p p l i c a b i l i t y o r e x p e r t i s e . ft major reason f o r the p a t h o l o g i c a l behavior of pure top-down search (Sussman S McDermott, 1972) i s t h a t i n a p p l i c a b l e methods do not know when to g u i t . In bottom-up se a r c h , however, the c h o i c e of when to apply a method's techniques i s not c r i t i c a l . The d e c i s i o n i s based l o c a l l y on a schema's a n t i c i p a t i o n of suc c e s s . I f a schema a p p l i e s a bottom-up method, but the schema i t s e l f i s i n a p p r o p r i a t e , c o n t r o l w i l l soon propagate to the methods of more a p p r o p r i a t e schemata. Evidence w i l l be d i s c o v e r e d which matches the e x p e c t a t i o n s o f those more a p p r o p r i a t e schemata. T h e i r methods w i l l then assume c c n t r o l thereby c o r r e c t i n g the mistake. The e s s e n t i a l d i f f e r e n c e from top-down search i s t h a t t h i s d e c i s i o n does not have to be made l o c a l l y by each method. In s t e a d , i t i s made g l o b a l l y by the d i s c o v e r y of evidence s u p p o r t i n g the choice of a d i f f e r e n t method. In the worst case, a l l t h a t i s l o s t i s some e f f i c i e n c y f o r a shor t while. There i s 3: ft P r o c e d u r a l ffodel 74 no c h r o n i c p a t h o l o g i c a l behavior. Hack-worth s i m i l a r convergence e f f e c t i n the use c o n s t r a i n t propagation a l g o r i t h m , NC. 3.7 C o o r d i n a t i o n and Communication Since m u l t i p l e methods can be a c t i v e c o n c u r r e n t l y , methods may si m u l t a n e o u s l y attempt t o r e c o g n i z e d i f f e r e n t schemata or more than one method may attempt to r e c o g n i z e the same schema i n s t a n c e . I t i s necessary t o provide c o o r d i n a t i o n and communication among s i s t e r methods. In t h i s model, communication among s i s t e r methods i s accomplished through t h e i r common schema i n s t a n c e . The i n s t a n c e i s a data s t r u c t u r e accessed by a l l methods a s s o c i a t e d with that schema. Each method c o n t r i b u t e s to the i n s t a n t i a t i o n o f the schema and i s aware o f the c o n t r i b u t i o n s o f i t s s i s t e r s . When seme p a r t i c u l a r method decides that the r e c o g n i t i o n of t h i s schema i n s t a n c e has been completed, i t must communicate that success t o every a c t i v e s i s t e r method. Such a mechanism i s d e f i n e d within the completion phase. When a method begins the completion phase, i t i s assumed that the e f f o r t s of a l l ether methods a s s o c i a t e d with the r e c o g n i t i o n o f t h i s p a r t i c u l a r schema i n s t a n c e are no longer needed. A l l such s i s t e r methods are suspended w i t h i n the completed schema i n s t a n c e . As w e l l , there must be c o o r d i n a t i o n among the methods c f a method h i e r a r c h y . A number of methods i n the h i e r a r c h y may be 3: A Pr o c e d u r a l Model (1977a) has noted a cf h i s bottcm-up 75 s i m u l t a n e o u s l y attempting the r e c o g n i t i o n of t h e i r a s s o c i a t e d schemata. Since the method h i e r a r c h y i s isomorphic tc the composition h i e r a r c h y , when a method a t some l e v e l i n the method h i e r a r c h y i s s u c c e s s f u l at r e c o g n i z i n g a schema i n s t a n c e a t that l e v e l , the methods a t lower l e v e l s are no longer needed. These lower methods were attempting to re c o g n i z e components of the now completed schema i n s t a n c e and to d i s c o v e r cues to propagate i t s r e c o g n i t i o n . That r e c o g n i t i o n i s now complete and these methods are a l s o suspended. Completion then i s seen as a c o o r d i n a t i o n mechanism among co o p e r a t i n g concurrent methods. When a schema i s s u c c e s s f u l l y r e c o g n i z e d , a l l methods c u r r e n t l y attempting the r e c o g n i t i o n of t h a t schema or sub-schemata of t h a t schema are suspended. Completion was c h a r a c t e r i z e d above as a bottom-up generator. T h i s mechanism i s r e a l i z e d by the conventions d e s c r i b e d here., The bottom-up generator i s composed of a l l the methods suspended by the completion process. On f a i l u r e , the generator i s resumed to generate a new p l a u s i b l e higher s u p e r g o a l , resuming a l l the suspended methods to continue the se a r c h f o r that next s u p e r g o a l . 3.8 I n t e g r a t i o n The p r e s e n t a t i o n o f t h i s r e c o g n i t i o n model has so f a r conce n t r a t e d on r e a l i z i n g bottom-up search mechanisms. Ore of the premises f o r the model's development was that i t should 3: a P r o c e d u r a l flodel 76 provide an i n t e g r a t i o n of top-down and bottom-up search. T h i s s e c t i o n d e s c r i b e s such an i n t e g r a t i o n . In t h i s model, methods may execute e i t h e r as subgoals or super g o a l s . a subgoal method may attempt to complete i t s task by using e i t h e r top-down or bottom-up technigues. Top-down search i s implemented i n the f a m i l i a r manner by methods r e c u r s i v e l y c a l l i n g the methods of other schemata as subgcals. as w e l l , a subgoal method may use bottom-up technigues by computing a set of e x p e c t a t i o n s f o r i t s schema, then attempting to s a t i s f y those e x p e c t a t i o n s by making o b s e r v a t i o n s and deductions. T h i s process may, i t s e l f , r e c u r s i v e l y use an i n t e g r a t i o n of top-down and bottom-up technigues. The only r e s t r i c t i o n i s that the subgoal method e v e n t u a l l y r e t u r n a success or f a i l u r e to i t s e x p l i c i t c a l l e r . L i k e w i s e , supergoal methods may use e i t h e r top-down or bottom-up search t o achieve t h e i r t a s k s . Supergoals may c a l l o t her methods as subgoals. a l t e r n a t i v e l y , a supergoal method may c r e a t e a s e t of e x p e c t a t i o n s f o r i t s schema, then e i t h e r r e l i n q u i s h c o n t r o l to some other method, or using i t s h e u r i s t i c knowledge, d i r e c t the d i s c o v e r y and deduction of i n f o r m a t i o n to s a t i s f y i t s own e x p e c t a t i o n s . In summary, both top-down and bottom-up methods can be int e r m i x e d f r e e l y . When a completing schema i s attempting t o match the e x p e c t a t i o n s of higher schemata, i t must f i r s t f i n d i n s t a n c e s of those schemata to match. T h i s device i n v o l v e s the semantic network matching d e s c r i b e d e a r l i e r . Part of the h e u r i s t i c 3 : a P r o c e d u r a l Model 77 knowledge c o n t a i n e d i n a schema's methods c o n s i s t s c f procedures f o r s e a r c h i n g the schema network to look f o r higher schemata t o match. In f a c t , t h e r e i s no sharp d i s t i n c t i o n between when a schema ceases the r e c o g n i t i o n of an i n s t a n c e and when i t begins the completion process. Overlapping may occur to the p o i n t t h a t the completion process i n v o l v e s using both top-down and bottom-up search techniques and the expectation/matching c y c l e may i n v o l v e a s p e c t s of completion. For i n s t a n c e , i n order to e f f i c i e n t l y c a l c u l a t e a next s e t of e x p e c t a t i o n s , a method may need t o match higher supergoals i n order to c o n s t r a i n the number of e x p e c t a t i o n s produced. T h i s d i s t i n c t i o n i s made more f o r conc e p t u a l than computational reasons. In a l a r g e schema system, i t w i l l be advantageous t o b l u r the d i s t i n c t i o n i n crder t o f a c i l i t a t e communication up and down the the schema h i e r a r c h y . 3: fl Procedural Kodel 78 CHAPTER 4: AN EXAJPLE FBQM MACHINE VISION 4 .1 P e r s p e c t i v e T h i s chapter presents a d e t a i l e d example of the o p e r a t i o n o f the r e c o g n i t i o n model on a computer v i s i o n task. T h i s example has been implemented as a running Maya program which i s given i n Appendix-C. I n the next chapter, the implementation of the example w i l l be covered as p a r t o f the d e s c r i p t i o n of Maya. The example chosen i s a small but c h a r a c t e r i s t i c machine v i s i o n problem from the "blocks world". The problem i s to re c o g n i z e from p e r f e c t l i n e drawings a c l a s s of polyhedra i n c l u d i n g cubes, wedges, and pyramids. The r e c o g n i z e r operates from a schema r e p r e s e n t a t i o n of polyhedra and accepts input scenes c o n s i s t i n g of v e r t i c e s and l i n e s connecting v e r t i c e s . The problem i s not a v i s i o n t a s k of c u r r e n t r e s e a r c h i n t e r e s t . I t i s presented t o i l l u s t r a t e the o p e r a t i o n o f the r e c o g n i t i o n model developed i n t h i s t h e s i s . There are three major reasons f o r t h i s c h o i c e . F i r s t , the problem i s c h a r a c t e r i s t i c of machine p e r c e p t i o n t a s k s . The world of p o l y h e d r a l o b j e c t s i s b e l i e v e d t o be the simplest task domain t h a t c a p t u r e s the e s s e n t i a l aspects of scene a n a l y s i s (Mackworth,1976). Second, the example i s r e s t r i c t e d enough i n i t s scope t h a t h e u r i s t i c concerns s p e c i f i c t o a p a r t i c u l a r 4: An Example from Machine V i s i o n 79 v i s i o n task do not overshadow more general i s s u e s of r e p r e s e n t a t i o n and r e c o g n i t i o n . And t h i r d , t h i s example i s s i m i l a r to an example given by Kuipers (1975) to i l l u s t r a t e the o p e r a t i o n of the top-down model of r e c o g n i t i o n f o r schema systems. T h i s c h o i c e of example, t h e r e f o r e , permits a comparison of the two r e c o g n i t i o n models. The method of p r e s e n t a t i o n w i l l be t o f i r s t d e s c r i b e the o v e r a l l s t r u c t u r e of the problem's s o l u t i o n , and then, by u t i l i z i n g a p r o t o c o l produced by the program, e x p l a i n the o p e r a t i o n of the program and the u n d e r l y i n g r e c o g n i t i o n model. Although the program does not exp l o r e a l l the i s s u e s addressed by the model, i t does provide a handle f o r t h e i r d i s c u s s i o n . 4.2 The Problem The knowledge of p o l y h e d r a l o b j e c t s i s represented i n t h i s example as a schemata network. The program uses the simple composition h i e r a r c h y of F i g u r e 4.1 to represent s t e r e o t y p i c a l scenes of p o l y h e d r a l b l o c k s . Each node i n t h i s h i e r a r c h y i s a s t e r e o t y p e schema r e p r e s e n t i n g a named concept. Each downward-directed a r c r e p r e s e n t s the composition r e l a t i o n between i t s schema and i t s sub-schemata, Scenes are composed of p o l y h e d r a l o b j e c t s . Polyhedra are composed c f polygon faces which, i n t u r n , are composed of p r i m i t i v e edges and v e r t i c e s . Each upward-pointing a r c r e p r e s e n t s the i n v e r s e composition r e l a t i o n , " p a r t - o f " . 4: An Example from Machine V i s i o n 80 Figure 4.1: Scene Composition Hier a r c h y 4: An Example from Machine V i s i o n 81 In t h i s example, p o l y h e d r a l o b j e c t s are d i f f e r e n t i a t e d i n t o cuboids, wedges, and pyramids. Cuboids are polyhedra composed of p a r a l l e l o g r a m f a c e s only. Wedges are o b j e c t s composed of p a r a l l e l o g r a m faces and a s i n g l e t r i a n g l e f a c e , and, pyramids are o b j e c t s c o n t a i n i n g two or more t r i a n g l e f a c e s . Polygons are d i f f e r e n t i a t e d i n t o t r i a n g l e s , p a r a l l e l o g r a m s , general q u a d r i l a t e r a l s , and a r b i t r a r y polygons of f i v e or mere si d e s c a l l e d m u l t i l a t e r a l s . N o t i c e t h a t the d i f f e r e n t i a t i o n cf the g e n e r i c polyhedron and polygon schemata i n t o s u b c l a s s e s i s not r e p r e s e n t e d e x p l i c i t l y i n the composition h i e r a r c h y . Polyhedra, f o r example, are not d i v i d e d i n t o cuboids, wedges and pyramids each of which, i n t u r n , would be d i v i d e d i n t o t r i a n g l e s and p a r a l l e l o q r a m s . To do so would expand c o n s i d e r a b l y the s i z e of the schema system and f o r c e an e x p l a n a t i o n of t h i s l a r q e r s t r u c t u r e i n order t o perform r e c o q n i t i o n . I n s t e a d , the knowledqe of t h e d i v i s i o n o f s t e r e o t y p e c l a s s e s i n t o s u b c l a s s e s and f i n a l l y i n t o s p e c i f i c i n s t a n c e s i s represented p r o c e d u r a l l y i n the methods attached to t h e s t e r e o t y p e schemata. The task of the polyhedron schema ,s methods i s to recoqnize i n s t a n c e s of cuboids, pyramids, and wedqes. Likewise f o r the polygon's methods, t h e i r task i s r e c o g n i z e from o b s e r v a t i o n i n s t a n c e s of t r i a n g l e s , p a r a l l e l o g r a m s , q u a d r i l a t e r a l s , and m u l t i l a t e r a l s . I n i t i a l l y , the taxonomic s t r u c t u r e i s represented w i t h i n the p r o c e d u r a l methods, but as s p e c i f i c i n s t a n c e s of polyqons and polyhedra are hypothesized and subsequently r e c o q n i z e d , they are added t o the i n s t a n c e h i e r a r c h y f o r those schemata. Thus the Hz An Example from Machine V i s i o n 82 s t r u c t u r e s are creat e d d y n a m i c a l l y . The c o n s t r u c t i o n c f the h i e r a r c h i c a l r e p r e s e n t a t i o n of a scene i s based on evidence d i s c o v e r e d i n the i n p u t , not on a l l p o s s i b l e compositions compiled before the r e c o g n i t i o n begins. The program i s run on the scene of Figure 4.2. The scene data i s input to the program as a set of l i n e s and v e r t i c e s , each o f which i s represented as a p r i m i t i v e f u l l y i n s t a n t i a t e d schema. As the data f o r each vertex i s read, a schema i n s t a n c e i s c r e a t e d and added t o the v e r t e x i n s t a n c e h i e r a r c h y . T h i s f u n c t i o n i s i l l u s t r a t e d i n F i g u r e 4.3. V e r t i c e s are d i v i d e d i n t o f o u r c l a s s e s i n t h i s h i e r a r c h y . They are ARROW, FORK, T, and I. Because there are only a few p r i m i t i v e vertex i n s t a n c e s i n the i n p u t data, the vertex h i e r a r c h y uses a simple o r g a n i z a t i o n . VERTEX maintains a simple l i s t of i t s i n s t a n c e s , FORK, L, T, and ARROW.; L i k e w i s e , each of these s t e r e o t y p e s c o n t a i n s a l i s t of i t s i n s t a n c e s , the p r i m i t i v e i n p u t v e r t i c e s . Besides o r g a n i z i n g the database o f v e r t i c e s by verte x type, the h i e r a r c h y a l s o p r o v i d e s an a t t r i b u t e i n h e r i t a n c e mechanism. For i n s t a n c e , Vertex - 1 i n h e r i t s t h e schema a t t r i b u t e s of i t s st e r e o t y p e , AR80W, which, i n t u r n , i n h e r i t s the more gen e r a l p r o p e r t i e s of VERTEX. I n h e r i t e d a t t r i b u t e s can i n c l u d e procedures, v a r i a b l e b i n d i n g s , p a t t e r n databases, and methods, thereby implementing method h i e r a r c h i e s . Figure 4.4a i l l u s t r a t e s a t y p i c a l p r i m i t i v e vertex schema, V e r t e x - i . Each such vertex c o n t a i n s a number of named s l o t s . The "ISA" s l o t (Fahlman, 1975) re p r e s e n t s the i n v e r s e i n s t a n c e 4: An Example from Machine V i s i o n Figure 4.2: Input Scene 4: An Example from Machine V i s i o n 84 F i g u r e 4.3: Vertex Instance Hierarchy 4: An Example from Machine V i s i o n 85 (LINE-NAME) (VERTEX-TYPE) INSTANCE (INTEGER) (CORNER) VERTEX-i F i g u r e 4.4a: Vertex Schemata (VERTEX) ^P^Z— INSTANCE (INTEGER) LINE-i (VERTEX) F i g u r e 4.4b: Li n e Schemata 4: An Example from Machine V i s i o n 8 6 r e l a t i o n between every i n s t a n c e and i t s s t e r e o t y p e . T h i s r e l a t i o n i s a u t o m a t i c a l l y c r e a t e d by Maya when the i n s t a n c e i s d e f i n e d . I t w i l l p o i n t e i t h e r to the FORK, 1, T, or ARROW schema. A second s l o t i n the vertex i n s t a n c e , c a l l e d NAME, point s to an atom r e p r e s e n t i n g the schema's name, V e r t e x - i . Three a d d i t i o n a l s l o t s i n the i n s t a n c e (two f o r L - v e r t i c e s ) are used to represent s e c t o r s o f the p i c t u r e plane that each vertex imposes . on i t s immediate l o c a l e , as shown i n F i g u r e 4.5. When the vertex has been r e c o g n i z e d as part of one or more pclygon f a c e s , these s e c t o r s w i l l be c o r n e r s of those f a c e s . The remaining s l o t s of the vertex i n s t a n c e r e p r e s e n t data f o r the p a r t i c u l a r v e r t e x . . The s l o t s l a b e l l e d 11, 12, and 13 p o i n t to the corresponding l i n e i n s t a n c e s given i n the input p i c t u r e . l i k e w i s e , the s l o t s l a b e l l e d ANGIE-I1-L2 and ANGIE-I2-I3 are used t o i n d i c a t e approximate angles of each of the s e c t o r s , as i s i l l u s t r a t e d i n F i g u r e 4.5. In a s i m i l a r manner, a schema i n s t a n c e i s c r e a t e d f o r each l i n e i n the i n p u t data. F i g u r e 4.4b d e p i c t s the s t r u c t u r e of p r i m i t i v e l i n e schemata. Each l i n e schema i s an i n s t a n c e of the g e n e r i c IINE schema and has s l o t s f o r i t s name, i t s length i n the p i c t u r e , and the names of the two v e r t i c e s , l a b e l l e d 7 1 and V2, connected by i t i n the p i c t u r e . As a matter of convenience, a l l of the i n p u t data i s read and represented as schema i n s t a n c e s before the r e c o g n i t i o n process begins. The output of the program c o n s i s t s of a h i e r a r c h i c a l d e s c r i p t i o n of the 4: An Example from Machine V i s i o n 87 L2 For ARROW, FORK, and T-Vertices L2 For L-Vertex Figure 4.5: Vertex L a b e l l i n g Conventions 4: fin Example from Machine V i s i o n 88 r e c o g n i z e d scene composed of f u l l y s p e c i f i e d schema i n s t a n c e s , or c o n v e r s e l y , a r e p o r t c f f a i l u r e . 4. 3 Annotated P r o t o c o l In the f o l l o w i n g pages, a p r o t o c o l i s used t o f a c i l i t a t e the e x p l a n a t i o n of the model. The sentences which are preceded by an a s t e r i s k and p r i n t e d i n upper case are the statements of the p r o t o c o l produced by the program. A l l others are the a u t h o r s commentary on the behavior of the program and the model. I t may be u s e f u l to use F i g u r e 4.6 t o f o l l o w the r e c o g n i t i o n p r o c e s s . The f a c e schema i n s t a n c e s c r e a t e d during the r e c o g n i t i o n are shown superimposed on the l i n e s and v e r t i c e s of the p i c t u r e . The r e c o g n i t i o n process begins by sending the t o p - l e v e l schema a message to i n t e r p r e t the input data as a scene. In order t o r e c o g n i z e a scene, the SCENE schema must f i n d a p o l y h e d r a l o b j e c t i n the d a t a . The schema has the c h o i c e of a p p l y i n g top-down or bottom-up te c h n i g u e s . I f i t chooses to conduct a top-down search, the d i f f i c u l t i e s mentioned with the top-down r e c o g n i t i o n model w i l l appear. S p e c i f i c a l l y , the SCENE schema w i l l be f o r c e d to hypothesize a l t e r n a t i v e l y cube, wedge, and pyramid schemata as subgoals. I f a hypothesis i s i n c o r r e c t , the schema w i l l have to choose a nex subgoal based only cr t h a t f a i l u r e . A l t e r n a t i v e l y , the SCENE schema may begin i t s r e c o g n i t i o n using bottom-up s e a r c h . L a t e r , when s u f f i c i e n t 4: An Example from Machine V i s i o n 89 F i g u r e 4.6: Re c o g n i t i o n of a Redge 4: An Example from Machine V i s i o n 90 s u p p o r t i n g evidence f o r a s i n g l e hypothesis has been found, the hypothesized schema can confirm i t s r e c o g n i t i o n u s i n g top-down technigues. * METHOD: TOP-LEVEL SCHEMA EXHAUSTIVELY OBSERVES EACH VERTEX Since no evidence has yet been d i s c o v e r e d supporting any p a r t i c u l a r h y p o t h e s i s , the t o p - l e v e l Scene schema chooses to use bottom-up search technigues by making o b s e r v a t i o n s i n the input data. The h e u r i s t i c method used by t h i s schema i s the same as t h a t given by Huffman (1971). The schema e x h a u s t i v e l y a c t i v a t e s each p r i m i t i v e v e r t e x schema i n the scene, beginning with the p e r i p h e r a l v e r t i c e s as they are l e s s ambiguous i n t e r p r e t a t i o n cues than i n t e r i o r v e r t i c e s . The o b s e r v a t i o n process c o n s i s t s o f a c t i v a t i n g each vertex schema t o perform i t s completion phase. Since the r e c o g n i t i o n of each vertex i s given as the input data, the vertex need only compute of which higher schemata i n the network i t may be p l a u s i b l y p a r t . In t h i s example, v e r t i c e s may be component p a r t s of both t r i a n g l e and p a r a l l e l o g r a m f a c e s . * SCENE SCHEMA OBSERVES VERTEX-1 Vertex-1 i s an ARROW vertex which, i n t u r n , i s an i n s t a n c e of the g e n e r i c Vertex schema. ARROW, FORK, and T - v e r t i c e s c o n t a i n three s e c t o r s s i n c e they d i v i d e the p i c t u r e plane 4: An Example from Machine V i s i o n 91 l o c a l l y i n t o t h r e e r e g i o n s . V e r t i c e s c o n t a i n i n g t h r e e s e c t o r s are taken t o be d e f a u l t and the g e n e r i c vertex schema provides a procedure f o r performing completion f o r these v e r t i c e s . Each such vertex i n h e r i t s t h i s method from the Vertex schema by the i n v e r s e i n s t a n c e r e l a t i o n maintained a u t o m a t i c a l l y by Maya. The only vertex having two s e c t o r s i s the L-v e r t e x which has a completion procedure d e f i n e d l o c a l l y and need not i n h e r i t i t from the vertex h i e r a r c h y . * FOB S E C T 0 R - L 1 - L 2 OF VERTEX-1, * CREATE A NEW SCHEMA: FACE-1 CONTAINING A CORNER FOR VERTEX-1 A vertex can be par t o f more than one polygon face because each s e c t o r of a vertex i s p o s s i b l y a corner of a d i f f e r e n t f a c e . The completion process f o r v e r t i c e s t h e r e f o r e c o n s i s t s of f i n d i n g and attempting to match polygon f a c e schemata f o r each of these s e c t o r s . For t h i s f i r s t v e r t e x , there a r e , as yet, no i n s t a n c e s of f a c e s t o match. Thus, the vertex matches the ge n e r i c polygon schema, FACE, which, i n t u r n , c r e a t e s a new i n s t a n c e , Face-1. The o b s e r v a t i o n o f Vertex-1 i s seen by FACE as a cue to hypothesize the e x i s t e n c e of another face i n s t a n c e . The matching o f Face-1 by Vertex-1 a c t i v a t e s a method a s s o c i a t e d with the new schema i n s t a n c e as a supergoal which promptly i n c o r p o r a t e s t h i s vertex as a corner of i t s newly e v o l v i n g d e s c r i p t i o n of a polygon f a c e . At t h i s p o i n t , a face has been hypothesized c o n t a i n i n g 4: An Example from Machine V i s i o n 92 Vertex-1. Face-1 can now continue the search v i a one of two mechanisms. The method could use f a m i l a r top-down search by c a l l i n g the methods of other sub-schemata as subgoals. For t h i s polygon, t h a t would i n v o l v e h y p o t h e s i z i n g a p a r t i c u l a r polygon f a c e type ( e i t h e r p a r a l l e l o g r a m , t r i a n g l e , g u a d r i l a t e r a l , or m u l t i l a t e r a l ) , then p r e d i c t i n g what types of v e r t i c e s each of the p o s s i b l e polygons c o u l d be composed of> and f i n a l l y l o c k i n g f o r those v e r t i c e s . T h i s mode i s r e j e c t e d by Face-1. The second mode o f search uses a bottom-up mechanism. The a c t i v e method of Face-1 c o u l d compute dynamically a new s e t of e x p e c t a t i o n s f o r the schema as a f u n c t i o n of the i n f o r m a t i o n provided by Vertex-1. That i s , Vertex-1 c o n s t r a i n s the p o s s i b l e f i n a l i n t e r p r e t a t i o n of Face-1. L a t e r , i f evidence i s d i s c o v e r e d matching these e x p e c t a t i o n s , the method w i l l be resumed as a supergoal to continue Face-1«s r e c o g n i t i o n . The schema can repeat t h i s c y c l e of computing a new s e t of e x p e c t a t i o n s and w a i t i n g f o r some e x p e c t a t i o n to be s a t i s f i e d . A l t e r n a t i v e l y , a t some point i n the c y c l e , i t can apply top-down technigues t o the v e r i f i c a t i o n o f i t s hypothesis. * CREATE TWO PROCESSES BOUND TO EXPECTATIONS FOR LINE-1 -6 AND LINE-1 -5 The method of Face-1 c r e a t e s two e x p e c t a t i o n s and binds a new method to each. E x p e c t a t i o n s are i n d i c e s of the schema a s s o c i a t i v e r e t r i e v a l mechanism. These i n d i c e s must be knowable 4 : An Example from Machine V i s i o n 93 by both the schema c r e a t i n g the e x p e c t a t i o n s and every ether schema t h a t can match them. E x p e c t a t i o n s are c o n s t r a i n t s cn the f i n a l i n t e r p r e t a t i o n . For t h i s problem, the l i n e s connecting v e r t i c e s are such a convention. Since both Face-1 and any v e r t i c e s t h a t can be p a r t of Face-1 have access to these l i n e s , they can be used as c o n s t r a i n i n g i n f o r m a t i o n cn the i n t e r p r e t a t i o n of v e r t i c e s as polygon f a c e s (Mackworth, 1975, 1977b) . A f t e r c r e a t i n g a s e t of e x p e c t a t i o n s f o r Face-1, the schema's method i s s t i l l a c t i v e . Since the method i s designed f o r the r e c o g n i t i o n of polygons, i t can apply i t s technigues to the f u r t h e r r e c o g n i t i o n of i t s own schema, or i t can r e l i n q u i s h c o n t r o l to the method of Vertex-1 which a c t i v a t e d i t . Should the method apply i t s technigues c r d e f e r to the more g e n e r a l knowledge o f the scene schema at the top of the method h i e r a r c h y ? The c h o i c e i s completely h e u r i s t i c , and i s based on the methods a p p r a i s a l of i t s p r o b a b i l i t y of s u c c e s s . The d e c i s i o n i s made from l o c a l i n f o r m a t i o n , such as how much evidence has been c o l l e c t e d s u p p o r t i n g the schema's hypothesis. Since very l i t t l e evidence has been d i s c o v e r e d s u p p o r t i n g the r e c o g n i t i o n of Face-1, i t s method suspends i t s e l f . * FOE SECT0B-12-L3 OF VEBTEX-1, * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-1 C o n t r o l r e t u r n s to Vertex-1 which i s s t i l l a c t i v e l y pursuing i t s 4: An Example frcm Machine V i s i o n 9 4 completion phase. , T h i s time, however, i t f i n d s a polygon f a c e i n s t a n c e to match s i n c e the polygon i n s t a n c e h i e r a r c h y c o n t a i n s Face-1. The match f a i l s . Sector-L2-L3 cannot be part of Face-1 because Sector-L1-L2 of the same vertex i s alre a d y part of t h i s f a c e . * CREATE A NEW SCHEMA: FACE-2 CONTAINING A CCRNEB FOB VERTEX-1 A new face r e c o g n i z e r , Face-2, i s now hypothesized and i t s method a c t i v a t e d as a sup e r g o a l of Vertex-1. As i n the case of F a c e - 1 , the method c r e a t e s t he f i r s t c o r n e r c f Face-2 by i n c c r p o r a t i n g Sector-L2-L3 of Vertex-1 i n t o i t s d e s c r i p t i o n . * CREATE TWO PROCESSES BOUND TO EXPECTATIONS FOR LINE-1-2 AND LINE-1-6 Again the f a c e schema c r e a t e s two e x p e c t a t i o n s , binds methods to them, and r e t u r n s c o n t r o l t o Vertex-1 which a c t i v a t e d i t . * FOR SECTOR-L3-L1 OF VERTEX-1, * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-2 * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-1 * CREATE A NEW SCHEMA: FACE-3 CONTAINING A CORNER FOR VERTEX-1 * CREATE TWO PROCESSES BOUND TO EXPECTATIONS FOR LINE-1-5 AND LINE-1-2 4: An Example from Machine V i s i o n 95 Vertex-1 c o n t i n u e s l o o k i n g f o r higher schemata to match, t h i s time f o r i t s t h i r d s e c t o r , S e c t o r - L 3 - L 1 . Attempts at matching the two e x i s t i n g f a c e r e c o g n i z e r s f a i l , and a new schema, F a c e - 3 , i s c r e a t e d as b e f o r e . Vertex-1 has now f i n i s h e d i t s completion phase by s e a r c h i n g the polygon i n s t a n c e h i e r a r c h y f o r a l l schema i n s t a n c e s of which i t s s e c t o r s might p l a u s i b l y be p a r t . In t h i s example, t h i s search i n v o l v e s only attempting to match the e x p e c t a t i o n s of each f a c e i n s t a n c e . In g e n e r a l , the search f o r h i g h e r matching schemata w i t h i n the schema h i e r a r c h y can be a r b i t r a r i l y complex, perhaps r e c u r s i v e l y i n v o l v i n g r e c o g n i t i o n . * SCENE SCHEMA OBSERVES VERTEX-2 C o n t r o l has returned t o the scene schema which cont i n u e s to observe v e r t i c e s i n the h e u r i s t i c o r d e r i n g mentioned e a r l i e r . Vertex-2 i s a c t i v a t e d next to perform i t s completion phase. The v e r t e x w i l l attempt to f i n d face r e c o g n i z e r s t c match, t h a t i s , f a c e hypotheses of which i t can be p a r t . * PGR SECT0R-L1-L2 OF VEBTEX-2, * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-3 * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-2 * FACE-2 HAS BEEN MATCHED BY VERTEX-2 Vertex-2 has found Face-2 and matched H z An Example from one of i t s Machine V i s i o n 96 e x p e c t a t i o n s , namely, that i t shares Line-1-2 with the matching vertex. The method a s s o c i a t e d with that e x p e c t a t i o n i s a c t i v a t e d ; i t uses the f o l l o w i n g scheme f o r r e c o g n i z i n g faces. Two methods are d e f i n e d to f o l l o w the p e r i p h e r y of the face being r e c o g n i z e d . One method f o l l o w s the pe r i p h e r y of the face i n a c l o c k w i s e d i r e c t i o n , the ether i n a co u n t e r - c l o c k w i s e d i r e c t i o n . The search proceeds from some vertex v i a a connecting l i n e t o the next vertex and so on u n t i l the region comprising the face has teen c l o s e d . * VERIFY FACE-2 USING TOP-DOWN SEARCH When enough evidence has been disco v e r e d u s i n g bottom-up search to conclude t h a t the r e c o g n i t i o n of a polygon f a c e i s l i k e l y , the schema a p p l i e s a top-down method t o the v e r i f i c a t i o n of the hypothesis. The d i s c o v e r y of two neighbouring v e r t i c e s i s c o n s i d e r e d by the face r e c o g n i z e r t o be enough evidence t o switch from bottom-up to top-down search mode. In g e n e r a l , the c h o i c e of search modes i s a h e u r i s t i c d e c i s i o n made by a schema's methods. * GET NEXT CLOCKWISE NEIGHBOUR VERTEX: VEBTEX-3 FROM LINE-2-3 * INCORPORATE THIS VERTEX INTO A NEW CORNER OF FACE-2 The top-down method uses a c l o c k w i s e t o u r o f neighbouring v e r t i c e s u n t i l a c l o s e d f i g u r e i s formed. As each vertex i s An Example from Machine V i s i o n 97 d i s c o v e r e d , i t i s composed i n t o a co r n e r i n the e v o l v i n g d e s c r i p t i o n of the polygon face. I f another f a c e r e c o g n i z e r i s d i s c o v e r e d during t h i s t o u r attempting the r e c o g n i t i o n c f the same f a c e , then i t s p a r t i a l l y completed d e s c r i p t i o n i s merged i n t o t h i s f a c e r e c o g n i z e r ' s d e s c r i p t i o n and the tour i s continued. Note that t h i s t r a n s f e r of i n f o r m a t i o n from one schema i n s t a n c e t o another i s s t r a i g h t f o r w a r d and does not v i o l a t e the c r i t e r i o n o f schema modularity f o r the r e c o g n i t i o n model. Because both schemata are i n s t a n c e s of the same s t e r e o t y p e , they a l r e a d y have access t o i n f o r m a t i o n about the i n t e r n a l s t r u c t u r e of each other. * GET NEXT CLOCKWISE NEIGHBOUR VEHTEX: VERTEX-6 FROM IINE-3-6 * INCORPORATE THIS VERTEX INTO A NEW CORNER OF FACE-2 * GET NEXT CLOCKWISE NEIGHBOUR VERTEX: VERTEX-1 FROM LINE-1-6 * THIS VERTEX IS ALREADY CONTAINED IN FACE-2 The top-down method c o n t i n u e s t o i n c o r p o r a t e v e r t i c e s i n t o the d e s c r i p t i o n of Face-2 u n t i l i t attempts to add V e r t e x - 1 . Since t h i s vertex i s already p a r t of t h i s f a c e , the top-down method has found a c l o s e d r e g i o n , the polygon f a c e . * COMPARE FACE-2 TO POLYGON MODEL * COMPLETED FACE-2 IS A PARALLELOGRAM I t i s the task of Face-2 t o decide the type of i t s pclygon 4: An Example from Machine V i s i o n 98 from i n f o r m a t i o n obtained d u r i n g i t s r e c o g n i t i o n . In t h i s example, p a r t o f t h a t i n f o r m a t i o n i s the s i z e of the angle of each vertex s e c t o r i n the f a c e ' s d e s c r i p t i o n . Face-2 compares t h i s i n f o r m a t i o n to an i n t e r n a l model of t r i a n g l e s , p a r a l l e l o g r a m s , q u a d r i l a t e r a l s , and m u l t i l a t e r a l s , and decides t h a t i t i s a p a r a l l e l o g r a m . In g e n e r a l , the models that a schema has of i t s s t e r e o t y p e concept guide the search p i o c e s s and are manifest as the methods a s s o c i a t e d with the schema. * MATCH THIS FACE TO THE EXPECTATIONS OF POLYHEDRON RECOGNIZEES Face-2 now beqins i t s completion phase as a h i g h - l e v e l i n t e r n a l cue i n the r e c o g n i t i o n process. P a r t of the kncwledqe contained i n the f a c e schema i s of what hiqher concepts i n the schema composition h i e r a r c h y polygons can be a p a r t . In t h i s example, polygons can be part of only p o l y h e d r a l o b j e c t s . Face-2 w i l l attempt to s t i m u l a t e the r e c o q n i t i o n of p a r t i c u l a r polyhedron schemata by sendinq messages to each of the r e c o g n i z e r s . The completed f a c e schema i s c h a r a c t e r i z e d as a bottcm-up qenerator of p o s s i b l e higher schemata i n the composition h i e r a r c h y . The a l g o r i t h m used by t h i s generator i s to attempt to match a s i n g l e polyhedron schema i n s t a n c e o f which i t must be a p a r t . F a i l i n g to f i n d such a schema, i t w i l l attempt to match every polyhedron schema t h a t i t may be part o f . In t h i s l a t t e r case, a new polyhedron r e c o g n i z e r must a l s o be c r e a t e d with t h i s U: An Example from Machine V i s i o n 99 polygon as i t s f i r s t component f a c e because i t c o u l d , c o n c e i v a b l y , be part of no e x i s t i n g polyhedron i n s t a n c e . Since there are no e x i s t i n g polyhedra i n s t a n c e s to match, Face-2 matches the g e n e r i c polyhedra schema. * IS FACI-2 COMPATIBLE WITH THIS CLASS OF POLYHEDBA? * YES The polyhedron i n s t a n c e analyzes Face-2 to decide whether i t w i l l accept the completed f a c e as p a r t o f i t s d e s c r i p t i o n . As shown by t h i s example, the polygon schema can recognize more types of polygons than the polyhedron schema can accept as v a l i d f a c e s of polyhedra. T h i s i l l u s t r a t e s a modularity c f the r e c o g n i t i o n model. A schema need only knew about r e c o g n i z i n g i n s t a n c e s of i t s own s t e r e o t y p e . I t does not need t o know the requirements of other schemata. I f a schema can be part of some higher schema, then i t w i l l be a b l e to match the e x p e c t a t i o n s of t h a t schema during i t s completion phase. The c r e a t i c n of e x p e c t a t i o n s w i t h i n a schema and the matching of those e x p e c t a t i o n s by another schema i s c h a r a c t e r i z e d as a pr o c e d u r a l c o n s t r a i n t s a t i s f a c t i o n process between two schemata. * CEEATE A NEW SCHEMA: POLYHEDRON-1 CONTAINING FACE-2 P a r a l l e l o g r a m s are v a l i d f a c e s of polyhedra i n t h i s example. A new schema i n s t a n c e i s c r e a t e d and p a r a l l e l o g r a m Face-2 i s 4: An Example from Machine V i s i o n 100 i n c o r p o r a t e d i n t o i t s new d e s c r i p t i o n . T h i s r e c o g n i z e r could use e i t h e r top-down or bottom-up technigues to f u r t h e r the r e c o g n i t i o n of a polyhedron. To use top-down search would i n v o l v e h y p o t h e s i z i n g the e x i s t e n c e of p a r t i c u l a r polygon faces and then a c t i v a t i n g those sub-schemata as subgoals. Bottcm-up search, on the other hand, would not r e q u i r e a commitment to a p a r t i c u l a r h y p o t h e s i s . I n s t e a d , the polyhedron, based on i t s p a r t i a l i n s t a n t i a t i o n from Face-2, can c r e a t e new e x p e c t a t i o n s of what polygon f a c e s would have to be d i s c o v e r e d t o propagate i t s r e c o g n i t i o n . U n l i k e top-down search where a committment must be made t o a s i n g l e h y p o t h e s i s at a time, u s i n g bottom-up mechanisms, the polyhedron schema can c r e a t e e x p e c t a t i o n s f o r m u l t i p l e p o s s i b l e polygon f a c e s , and wait f o r the d i s c o v e r y of such a fa c e or f a c e s . In t h i s example, s i n c e there i s l i t t l e evidence s u p p o r t i n g a p a r t i c u l a r h y p o t h e s i s , Polyhedron-1 w i l l use the bottom-up mechanism. * COMPUTE EXPECTATIONS ABOUT OTHER FACES OF POLY HEDRON-1 Polyhedra are composed o f polygonal f a c e s connected by common edges and v e r t i c e s . To recognize i n s t a n c e s of polyhedra, the polyhedron schema compares t h e i n s t a n c e s of polygonal faces t h a t i t has matched with i t s own i n t e r n a l model of polyhedra. For t h i s example, the model i s based on the n o t i o n of edge connectedness as used by Guzman (1968). Any two pol y g o n a l faces s h a r i n g a common edge which i s the shank o f an ARROW vertex are 4: An Example from Machine V i s i o n 101 p a r t of the same o b j e c t . These are c a l l e d "connect" edges. Other edges shared by two f a c e s are c a l l e d "maybe-ccnnect" edges. The use of t h i s scheme i s intended t o demonstrate the concept of model guided r e c o g n i t i o n . A whole v a r i e t y of i n f o r m a t i o n about the i n t e r p r e t a t i o n of three-di m e n s i o n a l scenes (Mackworth, 1977b) has been ignored f o r the sake of s i m p l i c i t y . * FOE LINE-1-6 OF FACE-2, * CREATE A PROCESS BOUND TO THE CONNECT EXPECTATION: LINE-1-6 * FOR LINE-3-6 OF FACE-2, * CREATE A PROCESS BOUND TO THE CONNECT EXPECTATION: LINE-3-6 Polyhedron-1 c r e a t e s e x p e c t a t i o n s f o r each "connect" edge of Face-2, b i n d i n g a method to each e x p e c t a t i o n . The "connect" edges of Face-2 are Line-1-6 and Line-3-6 which are the shanks of ARROW v e r t i c e s 1 and 3 r e s p e c t i v e l y . * FOB LINE-2-3 OF FACE-2, * CREATE A PROCESS BOUND TO THE MAYBE-CONNICT EXPECTATION: LINE-2-3 * FOR LINE-1-2 OF FACE-2, * CREATE A PROCESS BOUND TO THE MAYBE-CONNECT EXPECTATION: LINE-1-2 D i f f e r e n t methods are bound t o "maybe-connect" e x p e c t a t i o n s f o r each other edge of Face-2. *J: An Example from Machine V i s i o n 102 A f t e r the a c t i v e method of Polyhedron-1 has completed the e x p e c t a t i o n phase, i t may choose to terminate i t s e x e c u t i o n or i t may attempt to s t i m u l a t e the r e c o g n i t i o n of polygon f a c e s as cues t o d r i v e i t s own r e c o g n i t i o n and subsequently the r e c o g n i t i o n of a scene. Again, the choice i s a h e u r i s t i c d e c i s i o n , Polyhedron-1 must estimate i t s l i k e l i h o o d of success. However, the c h o i c e i s not c r i t i c a l . I f Polyhedron-1 decides to d i r e c t the o b s e r v a t i o n of v e r t i c e s from the i n p u t scene but i t i s an i n v a l i d hypothesis f o r t h i s scene, c o n t r o l w i l l soon migrate away from t h i s schema. The v e r t i c e s observed by Polyhedron-1 w i l l s t i m u l a t e the r e c o g n i t i o n of f a c e s which w i l l attempt to match the e x p e c t a t i o n s of polyhedron schemata. I f Polyhedron-1 i s the wrong h y p o t h e s i s , these f a c e s w i l l i n s t e a d match o t h e r , p o s s i b l y new, polyhedron r e c o g n i z e r s thereby a c t i v a t i n g t h e i r methods i n s t e a d . On the other hand, i f Polyhedron-1 i s indeed a v a l i d h y p o t hesis but the method y i e l d s c o n t r o l t o the weaker method of the Scene schema above i t i n the method h i e r a r c h y , t h i s method w i l l d i s c o v e r a polygon f a c e i n the scene t h a t w i l l succeed i n matching an e x p e c t a t i o n c f Polyhedron-1 thereby r e a c t i v a t i n g one of i t s methods. Thus search i s seen t o converge towards a v a l i d i n t e r p r e t a t i o n . To the c o n t r a r y , i n the top-down model, a bad hypothesis can dominate the search process f o r a c a t a s t r o p h i c a l l y long time. For these reasons, Polyhedron-1 decides t o apply a bottom-up technique f o r s t i m u l a t i n g i t s own r e c o g n i t i o n . 4: An Example from Machine V i s i o n 1 0 3 * METHOD: SEARCH FOR OTHER FACES OF POLYHEDRON-1 BY OBSERVING VERTICES OF FACE-2 THAT MAY BE PART OF MORE THAN ONE FACE T h i s h e u r i s t i c observes t h a t each s e c t o r of the v e r t i c e s of t h i s polyhedron can be p a r t o f more than one f a c e . T h i s method i s both more powerful than the simple enumeration of v e r t i c e s used by the scene schema and more s p e c i a l i z e d because such a second face i s l i k e l y t o be part of t h i s same polyhedron. However, i t s e x p e r t i s e i s good on l y f o r r e c o g n i z i n g polyhedra, not scenes. T h i s method h i e r a r c h y i s seen t o i n c o r p o r a t e a t r a d e - o f f between power and a p p l i c a b i l i t y . * POLYHEDRON-1 OBSERVES VERTEX-6 The next ver t e x observed i s a FORK vertex, Vertex-6. Sector-L1-L3 o f t h i s vertex i s already p a r t of Face-2, but the remaining two s e c t o r s may be p a r t s of two other, but, as yet, unknown f a c e s . * FOR SECT0B-L1-L2 OF VEBTEX-6, * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-3 * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-1 * FACE-1 HAS BEEN MATCHED BY VERTEX-6 Vertex-6 conducts i t s completion phase by a t t e u p t i n g to Hz An Example from Machine V i s i o n 104 match the e x p e c t a t i o n s p r e v i o u s l y c r e a t e d by Faces - 3 and 1. Vertex - 6 cannot be p a r t of any i n t e r p r e t a t i o n cf Face - 3 and t h a t match f a i l s . I t i s , however, s u c c e s s f u l at matching an e x p e c t a t i o n o f Face-1, s p e c i f i c a l l y , t h a t i t shares Line-1 - 6 with some vertex. The bottom-up method t h a t had been bound to t h i s e x p e c t a t i o n i s a c t i v a t e d as a supergoal o f V e r t e x - 6 . This i s the second vertex d i s c o v e r e d f o r Face-1 and, as b e f o r e , the Polygon schema attempts to v e r i f y t h e e x i s t e n c e of t h i s f a c e i n s t a n c e using top-down search. In t h i s example, the top-down search a t the vert e x l e v e l i s achieved by a simple t o u r i n g of the input schema i n s t a n c e s because v e r t i c e s were given as data. In g e n e r a l , however, goal d i r e c t e d s e a r c h can be of a r b i t r a r y complexity, perhaps i n v o l v i n g r e c u r s i v e l y the use of bottom-up mechanisms. & subgoal at any l e v e l can c r e a t e e x p e c t a t i o n s , b i n d methods to those e x p e c t a t i o n s , and then attempt t o make ob s e r v a t i o n s matching those e x p e c t a t i o n s . The only r e s t r i c t i o n on the search mechanisms used by a subgoal i s that i t e v e n t u a l l y must r e t u r n a success or f a i l u r e to i t s c a l l e r . * VERIFY FACE-1 USING TOP-DOWN SEARCH * GET NEXT CLOCKWISE NEIGHBOUR VERTEX: VERTEX-4 FROM LINE-4 -6 * INCORPORATE THIS VERTEX INTO A NEW CORNER OF FACE-1 * GET NEXT CLOCKWISE NEIGHBOUR VERTEX: VERTEX-5 FROM LINE-4-5 * INCORPORATE THIS VERTEX INTO A NEW CGBNEB OF FACE-1 * GET NEXT CLOCKWISE NEIGHBOUR VERTEX: VERTEX-1 FROM LINE-1-5 * THIS VERTEX IS ALREADY CONTAINED IN FACE-1 4: An Example from Machine V i s i o n 105 * COMPARE FACE-1 TO POLYGON HODEL * COMPLETED FACE-1 IS A PARALLELOGRAM Face-1 has found a c l o s e d f i g u r e composed of v e r t i c e s - 1 , 6, 4, and 5. A d e s c r i p t i o n of t h i s polygon face i s c r e a t e d with a c o r n e r f o r each vertex. The face i s compared a g a i n s t the polygon schema's i n t e r n a l model of polygons. The f i g u r e i s a g u a d r o l a t e r a l having egual opposite a n g l e s , and i s l a b e l l e d as a v a l i d p a r a l l e l o g r a m . * MATCH THIS FACE TO THE EXPECTATIONS OF POLYHEDRON RECOGNIZEES Face-1 begins i t s completion phase. I t must f i n d i n s t a n c e s of polyhedron r e c o g n i z e r s having e x p e c t a t i o n s of being matched by a p a r a l l e l o g r a m . Face-1 w i l l resume each s u c c e s s f u l l y matched schema as a s u p e r g o a l process. T h i s supergoal a c t i v a t i o n i s seen as an i n t e l l i g e n t process s c h e d u l i n g mechanism. Instead o f a c t i v a t i n g processes through some g l o b a l s c h e d u l i n g a l g o r i t h m , each completing schema can use i t s own domain s p e c i f i c s c h e d u l i n g a l g o r i t h m . Processes are scheduled by the d i s c o v e r y of evidence suggesting t h e i r a p p l i c a b i l i t y as supergoals. Face-1 • w i l l f i r s t attempt to match the e x p e c t a t i o n s c f an e x i s t i n g polyhedron r e c o g n i z e r t h a t i t shares a '•connect" edge with. I f i t i s s u c c e s s f u l , the method bound t o the polyhedron's e x p e c t a t i o n w i l l be resumed as a supe r g o a l p r o c e s s . I f Face-1 4: An Example from Machine V i s i o n 106 i s able to f i n d such a "connect" e x p e c t a t i o n and Batch i t s u c c e s s f u l l y , i t s task i s done. Otherwise, Face-1 must attempt i n sequence t o match t h e e x p e c t a t i o n s of a l l polyhedron r e c o g n i z e r s with which i t shares a "maybe-connect" edqe, and i t must a l s o c r e a t e a new polyhedron schema i n s t a n c e i n case i t i s not part of any e x i s t i n g i n t e r p r e t a t i o n . For each polyhedron r e c o q n i z e r matched by the face schema, the method bound t o the matched e x p e c t a t i o n i s resumed as a supergoal process. * ATTEMPT TO MATCH THE CONNECT EXPECTATIONS OF POLYHEDBGN-1 * TRY LINE-U-6 * TRY LINE-1-6 * A CONNECT EXPECTATION OF POLYHEDRON-1 HAS BEEN MATCHED BY FACE-1 Face-1 f i n d s and attempts t o match Polyhedron-1. T h i s face schema shares a "connect" edge with Face-2 of the polyhedron, so the match i s s u c c e s s f u l and the polyhedron's method i s resumed. • I S FACE-1 COMPATIBLE WITH THIS CLASS OF POLYHEDRA? * YES The method of Polyhedron-1 compares the polygon i n s t a n c e to i t s i n t e r n a l model of polyhedra. In t h i s system, polyhedra are composed of both t r i a n q l e s and p a r a l l e l o q r a m s . Face-1 i s accepted and i t s i n t e r p r e t a t i o n r e s u l t s i n the propaqation of 4: An Example from Machine V i s i o n 107 Polyhedron-1* s r e c o g n i t i o n . * COMPUTE TRANSITIVE EDGE CLOSURE FOR THIS FACE * FOR LINE-1-5 OF FACE-1, * CREATE A PROCESS BOUND TO THE MAYBE-CONNECT EXPECTATION: LINE-1-5 * FOR LIflE-4-5 OF FACE-1, * CREATE A PROCESS BOUND TO THE MAYBE-CONNECT EXPECTATION: LINE-4-5 * FOR LINE-4-6 OF FACE-1, * CREATE A PROCESS BOUND TO THE CONNECT EXPECTATION: LINE-4-6 Polyhedron-1 i n c o r p o r a t e s the new face i n s t a n c e i n t o i t s d e s c r i p t i o n by computing which edges of Face-1 are edges a l r e a d y contained i n Polyhedron-1. T h i s i s c a l l e d i t s t r a n s i t i v e edge c l o s u r e . At the same time, a new set of e x p e c t a t i o n s are cre a t e d f o r each remaining edge of Face-1 not c l o s e d with edges of the polyhedron. These edges r e p r e s e n t the cues by which other completing f a c e schemata w i l l be able to match t h i s schema's e x p e c t a t i o n s . * DOES DESCRIPTION OF POLYHEDRON-1 SATISFY THE CRITERIA .FOR A COMPLETE POLYHEDRAL OBJECT? * NO At t h i s p o i n t , the polyhedron checks to see i f i t s i n s t a n c e 4: An Example from Machine V i s i o n 108 i s f u l l y i n s t a n t i a t e d . I t i s net. There are s t i l l "connect" e x p e c t a t i o n s remaining u n s a t i s f i e d . * METHOD: OBSERVE VERTICES THAT WILL DRIVE THE RECOGNITION OF NEIGHBOURING FACES Having f i n i s h e d i t s e x p e c t a t i o n phase, Polyhedron-1 a p p l i e s a bcttom-up method by o b s e r v i n g v e r t i c e s which should s t i m u l a t e the r e c o g n i t i o n of neighbouring f a c e s . The r e c o g n i t i o n of such f a c e s w i l l h o p e f u l l y s a t i s f y i t s own e x p e c t a t i o n s . I t does t h i s by o b s e r v i n g t h r e e - l i n e v e r t i c e s of i t s component f a c e s t h a t may be part of some yet unrecognized f a c e . Notice that t h e r e are now two methods o f Polyhedron-1 si m u l t a n e o u s l y a c t i v e . Both methods are observing v e r t i c e s t o s t i m u l a t e the r e c o g n i t i o n of neighbouring f a c e s . They may communicate with each ether through t h e i r common data s t r u c t u r e , the schema i n s t a n c e of Polyhedron-1. Both can c o n t r i b u t e to i t s r e c o g n i t i o n , but t h e i r e f f o r t s must be c o o r d i n a t e d . I f one of the methods should decide t h a t e i t h e r a f u l l y i n s t a n t i a t e d i n s t a n c e has been fcund, or that the polyhedron i s a bad h y p o t h e s i s , the other method must be suspended. I t i s no longer a p p l i c a b l e to the d i s c o v e r y of a scene. * POLYHEDRON-1 OBSERVES VERTEX-4 * FOR SECTOR-L1-L2 OF VEBTEX-4, * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-3 Hz An Example from Machine V i s i o n 109 * CREATE A NEW SCHEMA: FACE-4 CONTAINING A COB NEE FOR VEETEX-4 * CREATE TWO PROCESSES BOUND TO EXPECTATIONS FOR LINE-4-6 AND LINE-3-4 The polyhedron method f i r s t observes Vertex-4 because i t i s a vert e x of one of i t s component faces t h a t c o u l d be part cf another undiscovered f a c e . Vertex-4 begins i t s completion phase by t r y i n g to f i n d e x i s t i n g uncompleted f a c e r e c o g n i z e r s to match. Only Face-3 remains uncompleted, but the match f a i l s . Sector-L1-L2 of vertex-4 cannot be p a r t of the background region represented by Face-3. As a r e s u l t . Vertex-4 requests the polygon schema t o c r e a t e a new polygon f a c e i n s t a n c e . Face-4 i s c r e a t e d , added t o the polygon i n s t a n c e h i e r a r c h y , and one cf i t s methods i s a c t i v a t e d . The new r e c o g n i z e r i n c o r p o r a t e s Vertex-4 i n t o i t s d e s c r i p t i o n and uses the ve r t e x to c r e a t e a new set of ex p e c t a t i o n s f o r the schema. As be f o r e , these e x p e c t a t i o n s c o n s i s t o f methods bound to p a t t e r n s c o n t a i n i n g l i n e cues, i n t h i s case, Line-4-6 and Line-3-4. Face-4 has f i n i s h e d i t s ex p e c t a t i o n phase and r e t u r n s c o n t r o l to Vertex-4. * FOR SECTOR-L3-L1 OF VERTEX-4, * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-4 * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-3 * CREATE A NEW SCHEMA: FACI-5 CONTAINING A CORNER FOR VERTEX-4 * CREATE TWO PROCESSES BOUND TO EXPECTATIONS FOR LINE-3-4 AND LINE-4-5 4: An Example from Machine V i s i o n 110 Vertex-4 s t i l l has one remaining uncommitted s e c t o r , Sector-L3-L1. N e i t h e r of the l i n e s of t h i s s e c t o r can match Face-4, Nor can they match the e x p e c t a t i o n s of Face-3, though they are pa r t of the same r e g i o n . There i s not yet c o n s t r a i n i n g i n f o r m a t i o n ( p o s s i b l y p r o v i d e d by Vertex-5) to l i n k them t o same i n t e r p r e t a t i o n . Thus, a new f a c e , Face-5, i s c r e a t e d i n the manner d e s c r i b e d f o r Face-4. The behaviour o f Vertex-4 i s c h a r a c t e r i z e d as a bottcm-up generator of p o s s i b l e higher supergoals. Each time c o n t r o l i s returned t o Vertex-4, i t generates another p l a u s i b l e pclygon face of which to be a p a r t . As w e l l , i t generates these faces i n h e u r i s t i c order, f i r s t attempting t o a c t i v a t e those a l r e a d y e x i s t i n g pclygon r e c o g n i z e r s which i t can match s u c c e s s f u l l y . Only i f t h a t f a i l s , w i l l i t generate a new polygon face i n s t a n c e . * POLYHEDRON-1 OBSERVES VERTEX-6 Vertex-4 has f i n i s h e d g e n erating supergoals and r e t u r n s c o n t r o l to Polyhedron-1 which proceeds with i t s methcd c f ob s e r v i n g l i k e l y v e r t i c e s , t h i s time a c t i v a t i n g Vertex-6. * FOR SECTOR-L2-L3 OF VERTEX-6, * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-5 * ATTEMPT TO MATCH THE EXPECTATIONS OF FACE-4 * FACE-4 HAS BEEN MATCHED BY VERTEX-6 4: An Example from Machine V i s i o n 111 Sector-L2-L3 i s the only s e c t o r of Vertex-6 not a l r e a d y p a r t of seme polygon f a c e . Vertex-6 f i r s t attempts to match Face-5 as a p o s s i b l e higher s u p e r g o a l , but the match f a i l s . An attempt at matching Face-4 succeeds, thereby a c t i v a t i n g a method of t h i s f a c e . * VERIFY FACE-4 USING TOP-DOWN SEARCH * GET NEXT CLOCKWISE NEIGHBOUR VERTEX: VERTEX-3 FROM LINE-3-6 * INCORPORATE THIS VERTEX INTO A NEW CORNER OF FACE-4 * GET NEXT CLOCKWISE NEIGHBOUR VERTEX: VERTEX-4 FROM LINE-3-4 * THIS VERTEX IS ALREADY CONTAINED IN FACE-4 * COMPARE FACE-4 TO POLYGON MODEL * COMPLETED FACE-4 IS A TRIANGLE Face-4 searches f o r i t s remaining v e r t i c e s by h y p o t h e s i z i n g another vertex, f i n d i n g that vertex by f o l l o w i n g Line-3-6. I t then c o n f i r m s t h a t i t s component l i n e s and v e r t i c e s form a c l o s e d f i g u r e and t h a t i t s type i s a t r i a n g l e . * MATCH THIS FACE TO THE EXPECTATIONS OF POLYHEDRON RECOGNIZERS * MATCH THE CONNECT EXPECTATIONS OF POLYHEDRGN-1 * TRY LINE-3-6 * A CONNECT EXPECTATION OF POLYHEDRON-1 HAS BEEN MATCHED EY FACE-4 * IS FACE-4 COMPATIBLE WITH THIS CLASS OF POLYHEDRA? * YES 4: An Example from Machine V i s i o n 112 Face-4 f i n d s Polyhedron-1, the s i n g l e member of the polyhedron i n s t a n c e h i e r a r c h y , and matches a "connect" e x p e c t a t i o n of t h i s r e c o g n i z e r . Both Face-4 and Face-2 share the common "connect" edge. Line-3-6. E x p e c t a t i o n s are equated with c o n s t r a i n t s . Line-3-6 c o n s t r a i n s the i n t e r p r e t a t i o n of Face-4 and Face-2 to be pa r t of the same o b j e c t . The r e c o q n i t i o n process can be viewed as a pr o c e d u r a l c o n s t r a i n t propaqation, where the flow of c c n t r o l throuqh the schemata network i s d i r e c t e d by the procedural methods attached to the nodes i n the network. * COMPUTE TRANSITIVE EDGE CLOSURE FOR THIS FACE * FOR LINE-3-4 OF FACE-4, * CREATE A PROCESS BOUND TO THE MAYBE-CONNECT EXPECTATION: LINE-3-4 * FOB LINE-4-6 OF FACE-4, •LINE-4-6 MATCHES A CONNECT EXPECTATION OF POLYHEDBON-1 Polyhedron-1 i n c o r p o r a t e s the new fa c e i n t o i t s d e s c r i p t i o n by computinq the t r a n s i t i v e edqe c l o s u r e of Face-4 with i t s other f a c e s . * DOES DESCRIPTION OF POLYHEDBON-1 SATISFY THE CRITERIA FOR A COMPLETE POLYHEDRAL OBJECT? * YES: POLYHEDRON-1 IS A SEDGE 4: An Example from Machine V i s i o n 113 The a d d i t i o n of Face-4 has been enough new i n f o r m a t i o n to c o n s t r a i n the i n t e r p r e t a t i o n c f Polyhedrcn-1 to a f u l l y d i f f e r e n t i a t e d i n s t a n c e . There are no "connect" e x p e c t a t i o n s remaining i n the schema and each f a c e i n the schema's d e s c r i p t i o n i s l a b e l l e d "connect" with every other f a c e with which i t shares an edge. The completed i n s t a n c e i s compared aga i n s t the schema's i n t e r n a l model of polyhedra and i s l a b e l l e d a wedge s i n c e i t i s composed o f two p a r a l l e l o g r a m s and a s i n g l e t r i a n g l e . * HATCH COMPLETED POLYHEDRON-1 TO THE EXPECTATIONS OF THE SCENE SCHEMA The method of Polyhedron-1 now begins i t s schema's completion phase. However, i t i s not the only method of t h i s schema c u r r e n t l y a c t i v e . There are two other concurrent methods observing v e r t i c e s . In f a c t , these other methods were i n s t r u m e n t a l i n observing the v e r t i c e s t h a t s t i m u l a t e d Polyhedron-1's s u c c e s s f u l r e c o g n i t i o n . These methods have now performed t h e i r task and they must be suspended. The mechanism f o r a c h i e v i n g t h i s c o o r d i n a t i o n among concurrent methods i s r e a l i z e d w i t h i n completion. When a completing schema matches another schema as a s u p e r g o a l , the method performing the completion and a l l ether a c t i v e methods a s s o c i a t e d with the same completed schema i n s t a n c e are suspended. The implementation of t h i s c c n t r o l s t r u c t u r e mechanism as a Maya language p r i m i t i v e i s d i s c u s s e d i n the next 4: An Example from Machine V i s i o n 1 14 chapter. In t h i s example, Polyhedron-1 performs i t s completion phase r a t h e r d e t e r m i n i s t i c a l l y . I t knows th a t polyhedra are only part of scenes. The scene schema has an ex p e c t a t i o n w a i t i n g to be matched by a completing polyhedron. The match i s s u c c e s s f u l , and the method of the scene schema i s a c t i v a t e d . * SCENE RECOGNIZES HAS FOUND A SCENE COMPOSED OF POLYHEDRC N-1 For b r e v i t y , i t i s assumed that a scene i s composed of a s i n g l e p o l y h e d r a l o b j e c t . The scene schema has completed i t s r e c o g n i t i o n , f i n d i n g a scene composed of Pclyhedron-1. The program t e r m i n a t e s s u c e s s f u l l y , r e t u r n i n g to t o p - l e v e l the h i e r a r c h i c a l d e s c r i p t i o n of the scene. 4.4 Con c l u s i o n T h i s example provides a high l e v e l d e s c r i p t i o n of the o p e r a t i o n of t h i s r e c o g n i t i o n model i n a scene a n a l y s i s program. Many of the ideas embodied i n the model co u l d only be p a r t i a l l y i l l u s t r a t e d by t h i s s i n g l e example. The p r e c i s e s p e c i f i c a t i o n of these ideas i s made manifest i n t h i s t h e s i s as an a r t i f i c i a l i n t e l l i g e n c e programming language c a l l e d Maya. The next chapter d e s c r i b e s the design of t h i s programming language. 4: An Example frcm Machine V i s i o n 115 CHAPTEJ 5: MAYA 5.1 I n t r o d u c t i o n Maya i s a m u l t i p r o c e s s i n g LISP d i a l e c t t h a t d e f i n e s a number o f e x t e n s i o n s to the data types and c c n t r o l p r i m i t i v e s of the LISP language. Maya g e n e r a l i z e s the OBLIST and property l i s t s of LISP t o a new p r i m i t i v e data type c a l l e d the o b j e c t which can be used to r e p r e s e n t schemata and to c o n s t r u c t frame systems and semantic networks. Maya d e f i n e s s p e c i f i c c c n t r o l s t r u c t u r e s f o r i n t e g r a t i n g top-down and bottom-up search i n schema-based r e p r e s e n t a t i o n s . The language p r o v i d e s , as w e l l , p r i m i t i v e s f o r p a t t e r n matching and f o r c r e a t i n g and s c h e d u l i n g m u l t i p l e processes. An e x t e n s i v e i n t e r a c t i v e debugging system modelled a f t e r t h a t o f INTERLISP (Teitelman, 1974) i s a l s o provided. Although Maya, as a programming language, i s concerned with d e v e l o p i n g programming technology, the motivation behind the language has been the experimental implementation of the r e c o g n i t i o n model presented i n t h i s t h e s i s . The n a t u r a l r e a l i z a t i o n of such a model i s a programming language because i t p r o v i d e s a g e n e r a l e x p e r i m e n t a l v e h i c l e with which to evaluate the i d e a s of the model. Maya focuses on g e n e r a l questions df r e p r e s e n t a t i o n and process i n v o l v e d i n machine p e r c e p t i o n . 5: Maya 116 5.2 Language Overview T h i s s e c t i o n p r o v i d e s a gen e r a l overview of Maya by d e s c r i b i n g the data types d e f i n e d i n Maya and t h e i r e v a l u a t i o n , fi number of other g e n e r a l f e a t u r e s of the language w i l l a l s o be mentioned. Issues of schema r e p r e s e n t a t i o n and r e c o g n i t i o n w i l l be covered i n subseguent s e c t i o n s of t h i s chapter. A f a m i l i a r i t y with LISP must be assumed i n t h i s d i s c u s s i o n . The reader i s r e f e r r e d t o Appendix-B, the Maya Language Reference Manual, f o r d e t a i l s o f the v a r i o u s Maya p r i m i t i v e s i n v o l v e d . 5.2.1 Data Types Maya extends the p r i m i t i v e data types of LISP to f a c i l i t a t e programming i n schema-based systems. Maya i s embedded i n LISP and i t s data p r i m i t i v e s are r e a l i z e d u s i n g LISP forms. Belcw i s a BNF grammatical r e p r e s e n t a t i o n of the LISP implementation of Maya's data types. Angle brackets are used to d e l i m i t non-terminal symbols and the a s t e r i s k i s used as the Kleene s t a r , i n d i c a t i n g zero or more r e p e t i t i o n s . <FORM> — > —> —> —> —> -> -> -> -> -> -> <VAR> <LIST> <TUPLE> <OBJECT> <ITEM> <PAIR> <ATOM> < V A R > <LIST> <TUPLE> <OBJECT> ?<ATOM> (<FORM>*) ( 3 <FORM>*) {atOBJECTS <TYPEXPAIR>*) ( S I T E M a <RESXPAIR>*) <AT0MXFORM> 5: Maya 117 A form i n Maya may be an atom, v a r i a b l e , l i s t , n - t u p l e , item, or o b j e c t . In LISP, an atom i s used both as the name of a s e t of p r o p e r t i e s and as a v a r i a b l e . In Maya, an atom, <ATOE>, i s d i f f e r e n t i a t e d from a v a r i a b l e , <VAR>, because i t i s d e s i r a b l e t o d i s t i n g u i s h between the name of an o b j e c t and the value of a v a r i a b l e . Names are represented by atoms, whereas v a r i a b l e s are represented by atoms p r e f i x e d by a q u e s t i o n mark. Li k e w i s e , Maya d i f f e r e n t i a t e s between a l i s t , <LIST> # and an n - t u p l e , <TOPLE>. L i s t s are used, as i n LISP, to encode both a c t u a l l i s t s and f u n c t i o n c a l l s . The value of a l i s t i s the r e s u l t of a p p l y i n q the f u n c t i o n i n d i c a t e d by the CAR of the l i s t to the CDR of the l i s t . The value of a t u p l e , however, i s a t u p l e of the v a l u e s of i t s elements. Tuples are used e x t e n s i v e l y by the p a t t e r n matchinq f u n c t i o n s . The most s i q n i f i c a n t e x t e n s i o n s to the data types d e f i n e d of LISP are the i n c l u s i o n of o b j e c t s and items. The o t j e c t , <OB0ECT>, subsumes the property l i s t s , u s u a l l y c a l l e d p l i s t s , of LISP atoms. I t can be used to form schemata, frame systems, and semantic networks. A schema or frame may be thouqht c f as a c o l l e c t i o n of named s l o t s or r e l a t i o n s . A node i n a semantic network may be c o n s i d e r e d to be a s e t of named a t t r i b u t e / v a l u e p a i r s . <OBJECT>s can c o n v e n i e n t l y represent both of these s t r u c t u r e s . An o b j e c t i s composed of a LISP l i s t havinq the p r e f i x , 5: Maya 1 1 8 30BJECT8, a u s e r - s u p p l i e d type i n d i c a t o r , <TYPE>, and a set c f named a t t r i b u t e s , <PAIR>s. I t should be noted that the d i f f e r e n t p r e f i x e s a s s o c i a t e d with o b j e c t s , t u p l e s , and v a r i a b l e s permit Maya t o type check the use of each data type. Within the d e f i n i t i o n of o b j e c t s , an e x t r a type i n d i c a t o r i s provided t o allow f u r t h e r user s u p p l i e d type checking. Each <PAIR> i n an o b j e c t a s s o c i a t e s an atomic name with a <FORM>. A name i s s a i d to be defined by i t s binding i n some ob j e c t . Objects are c r e a t e d by the Maya p r i m i t i v e , OEJECT, which takes as arguments a type and a l i s t of names and t h e i r new d e f i n i t i o n s . The f u n c t i o n r e t u r n s an o b j e c t as value. Whereas o b j e c t s a s s o c i a t e atomic names with t h e i r d e f i n i t i o n s , items a s s o c i a t e v a r i a b l e names with t h e i r l o c a l values. In Maya, genera t o r s , such as the p a t t e r n matcher, always r e t u r n items, i . e . , they r e t u r n a set of l o c a l v a r i a b l e b i n d i n g s computed w i t h i n the generator. An item, <ITEM>, i s composed of a LISP l i s t having the p r e f i x , SITEM2, followed by a processor r e s e r v e d f i e l d , <RES>. Each <PAIR> of the item r e p r e s e n t s an a s s o c i a t i o n between a v a r i a b l e name and i t s value. Maya maintains a s t a c k composed o f o b j e c t s , items, and a number of i n t e r n a l s t r u c t u r e s used by the p r o c e s s c r f o r r e c o r d i n g procedure i n v o c a t i o n s and the s t a t e s of generators and the p a t t e r n matcher. The o b j e c t nearest the top of the stack i s c a l l e d the e n c l o s i n g o b j e c t . I t r e p r e s e n t s the c u r r e n t schema, semantic network node, or immediate co n t e x t i n which the user i s " o p e r a t i n g " . 5; Maya 119 A number of Maya p r i m i t i v e s operate on the e n c l o s i n g o b j e c t . For i n s t a n c e , PUT* adds d e f i n i t i o n s to the e n c l o s i n g o b j e c t . T h i s f u n c t i o n takes two arguments, an atomic name and a form to be bound to t h a t name i n the e n c l o s i n g o b j e c t . I f t h a t name a l r e a d y e x i s t s i n the o b j e c t , i t s d e f i n i t i o n i s r e p l a c e d . The f u n c t i o n , GET*, r e t u r n s the d e f i n i t i o n of a name from the e n c l o s i n g o b j e c t , whereas the p r i m i t i v e , EEM*, removes the d e f i n i t i o n of a s p e c i f i e d name from w i t h i n the o b j e c t . A f o u r t h p r i m i t i v e , c a l l e d SELF, r e t u r n s as value the e n t i r e e n c l o s i n g o b j e c t . T h i s f u n c t i o n provides a mechanism f c r o b t a i n i n g a p o i n t e r to the c u r r e n t schema. In order t o make Maya and LISP as compatible as p o s s i b l e , a few of LISP»s SUBBs have been a l t e r e d to accept o b j e c t s i n s t e a d of PLISTs. LISP p r o p e r t y l i s t f u n c t i o n s new recognize the header at the f r o n t of each o b j e c t . T h i s overhead i s j u s t i f i e d because i t allows Maya to c o n s i d e r a l l of LISP's database, i . e . , the OBLIST, as the g l o b a l o b j e c t of i t s database. Each LISP atom which has p r o p e r t i e s a s s o c i a t e d with i t w i l l have a PLIST of the f o l l o w i n g form bcund to i t s CDR: (80BJECT3 3PLISTS <PAIB>*) . For example, DEFUN and DEFINE always add t h e i r d e f i n i t i o n s to the e n c l o s i n g o b j e c t . T h i s permits o b j e c t s to c o n t a i n f u n c t i o n d e f i n i t i o n s l o c a l t o the o b j e c t . T h i s mechanism w i l l be used as one way to i n c o r p o r a t e p r o c e d u r a l knowledge i n t o schemata. 5: Maya 120 Maya c o n s i d e r s LISP*s v a r i a b l e s t o be the s e t of g l o b a l Maya v a r i a b l e s . Maya uses a deep-binding scheme to access v a r i a b l e s on the processor s t a c k . These v a r i a b l e b i n d i n g s may appear i n LAMBDA e x p r e s s i o n s , PHOG e x p r e s s i o n s , or as v a r i a b l e s d e f i n e d i n items contained on the stack. The assignment f u n c t i o n s , SET and SETQ, which are analogous to t h e i r LISP c o u n t e r p a r t s , w i l l a l t e r the value of the f i r s t v a r i a b l e of the s p e c i f i e d name that they f i n d on the s t a c k . Otherwise, they w i l l a s s i g n a new value to the LISP atom of the same name. 5.2.2 E v a l u a t i o n The e v a l u a t i o n a l g o r i t h m f o r Maya data types i s presented below i n pseudo-LISP code. The behavior of the e v a l u a t c r i s then e l a b o r a t e d i n some d e t a i l . F i n a l l y , the f u n c t i o n types r e c o g n i z e d by Maya are d e s c r i b e d . When Maya i s asked to eva l u a t e a form, the f o l l o w i n g a l g o r i t h m i s used (but not the f o l l o w i n g implementation cf t h a t a l g o r i t h m ) : (DEFUN EVALDATE (FORM) (CCND {(ATOM FORM)(FETCH-DEFINITION-FROM-STACK FORM)) {{VARP FORM) (FETCH-VALDE-FROM-STACK FORM)) f (TDPLEP FORM) (APPLY «3 (CDB FORM)) < (OBJECTP FORM) (ERROR) ) ((ITEMP FORM) (ERROR)) ( (ATOM (CAR FORM) ) (APPLY (FETCH-FUNCTION (CAR FORM)) (CDR FORK))) (T (APPLY-LAMBEA (CAR FORM) (CDR FORM))))) 5: Maya 121 I f FORM i s an atom, then the d e f i n i t i o n of t h a t name i s fe t c h e d from i t s f i r s t o ccurrence on the stack. I f i t i s not found on the st a c k , i t i s f e t c h e d from the g l o b a l o b j e c t , the PLIST of the LISP atom, when presented an atcm, Maya attempts t o f i n d i t s d e f i n i t i o n w i t h i n the f i r s t e n c l o s i n g o b j e c t . I f t h a t f a i l s , i t attempts to l o c a t e the d e f i n i t i o n w i t h i n the next e n c l o s i n g o b j e c t , and so on. I f i t i s not t o be found i n any e n c l o s i n g o b j e c t , then the d e f i n i t i o n of the atcm present i n the g l o b a l o b j e c t i s returned. Note that f o r every atom there w i l l always be a d e f i n i t i o n f o r i t i n the g l o b a l o b j e c t , although t h a t d e f i n i t i o n may be the n u l l o b j e c t , NIL. I f FORM i s a v a r i a b l e , i t s value i s f e t c h e d from the f i r s t occurrence o f the v a r i a b l e ' s name on the stack. The v a r i a b l e may appear on the st a c k i n two d i f f e r e n t ways. I t may be a l o c a l v a r i a b l e of some LAMBDA or PROG e x p r e s s i o n . Or i t may appear as a v a r i a b l e bound i n an item returned from a generator. In e i t h e r case, the f i r s t l o c a l b i n d i n g found i s retu r n e d as the value of the v a r i a b l e . I f , however, the processor cannot f i n d the v a r i a b l e ' s name on the s t a c k , Maya f e t c h e s the g l o b a l value of the v a r i a b l e , t h a t i s , the LISP value. I f FORM i s a t u p l e , i t i s evaluated by the t u p l e e v a l u a t o r u s i n g i n v e r s e guote mode, t h a t i s , atoms and p a t t e r n v a r i a b l e s are t r e a t e d as c o n s t a n t s . The value of a t u p l e i s a new tu p l e of i t s v a l u e s . I f FORM i s an o b j e c t or an item, an ERROR occurs. I f t he CAR of FORM i s an atom, the atom i s assumed to be 5 : Maya 122 the name of a Maya or LISP f u n c t i o n . The f u n c t i o n i s fe t c h e d from the f i r s t d e f i n i t i o n of the atom on the st a c k , e l s e from the LISP PLIST of the atom. I f the f u n c t i o n f e t c h e d i s of the types r e c o g n i z e d by Maya, i t i s a p p l i e d t o the CDF of the form. I f more than one f u n c t i o n by the same name e x i s t s , the f i r s t one found i s used. I f no r e c o g n i z a b l e f u n c t i o n can be found, an e r r o r occurs. A d i s c u s s i o n of the f u n c t i o n types recognized by Maya i s presented below. Otherwise, the CAR of FORM i s not atomic and i s assumed t o be a Maya LAMBDA or QLAMEDA e x p r e s s i o n . The expre s s i o n i s then a p p l i e d t o the CDR of FORM. I f the CAR i s not a LAMBDA or QLAMEDA ex p r e s s i o n , an e r r o r o c c u r s . 5.3 Representation T h i s s e c t i o n d i s c u s s e s the use of Maya language f o r implementing schemata networks and f o r r e a l i z i n g message passing and i n t e r p r e t a t i o n . 5.3.1 Schemata Schemata and schemata networks are r e a l i z e d i n Maya as o b j e c t s . Maya d e f i n e s a mechanism f o r c o n s i d e r i n g an object as a schema s t e r e o t y p e and then c r e a t i n g m u l t i p l e i n s t a n c e s from t h a t s t e r e o t y p e . The f u n c t i o n , NEW, when a p p l i e d t o an o b j e c t , c r e a t e s an in c r e m e n t a l copy of the o b j e c t and a s s i g n s i t type, 5; Maya p r i m i t i v e s p r o c e d u r a l 123 ^INSTANCES. Any changes made to the i n s t a n c e are r e f l e c t e d i n the i n c r e m e n t a l copy and not the s t e r e o t y p e o b j e c t . For example, a s t e r e o t y p e schema t o represent the concept of "dog" c o u l d be c o n s t r u c t e d as f o l l o w s : (PUT* 'DOG (OBJECT 'GENERIC NAME * DOG CLASS ' HAM MALI A) ) • T h i s e x p r e s s i o n c r e a t e s w i t h i n the e n c l o s i n g o b j e c t , a d e f i n i t i o n of the name, DOG, as an o b j e c t having t y p e , GENERIC, a r e f l e x i v e p o i n t e r to i t s own name, and the i n d i c a t o r t h a t dogs are of c l a s s , MAMMALIA. To c r e a t e a s p e c i f i c i n s t a n c e of dog, the f o l l o w i n g e x p r e s s i o n c o u l d be then e v a l u a t e d : (NEW DOG NAME 'FLOYD OWNER 'BILL). The name and ownership a t t r i b u t e s of the dog i n s t a n c e are d e f i n e d w i t h i n the i n s t a n c e and not the s t e r e o t y p e . F e t c h i n g the name, CLASS, from the i n s t a n c e w i l l r e t u r n MAMMALIA but f e t c h i n g NAME w i l l y i e l d FLOYD, the d e f i n i t i o n l o c a l t o the i n s t a n c e . Advantages o f t h i s scheme are t h a t i t makes i n s t a n c e s c o m p u t a t i o n a l l y inexpensive and changes made t o a s t e r e o t y p e are immediately r e f l e c t e d i n each descendent i n s t a n c e , unless s p e c i f i c a l l y r e d e f i n e d by the i n s t a n c e . The Maya p r i m i t i v e , SEND, i s the b a s i c mechanisn f o r a c c e s s i n g schemata networks, f o r t r a v e r s i n g arcs i n semantic networks, and f o r p r o c e d u r a l message passing and i n t e r p r e t a t i o n . I t s form i s : {SEND <A1XA2> . . . <An>) . The arguments, <A1> through <An>, are c a l l e d a message sequence. SEND e v a l u a t e s each of i t s arguments i n sequence r e t u r n i n g the 5: Maya 124 e v a l u a t i o n of i t s l a s t argument, <An>, as i t s value. I f the value of seme <Ai> y i e l d s an o b j e c t or an item, then i t i s pushed onto the processor s t a c k thereby augmenting the environment f o r e i t h e r atom d e f i n i t i o n s or v a r i a b l e b i n d i n g s r e s p e c t i v e l y . The seguence, <A1> through <An>, i s an encoding of a search procedure through the network. By pushing some o b j e c t , <Ai>, onto the s t a c k , the processor i n e f f e c t "goes t o " t h a t o b j e c t . Now the e v a l u a t i o n of <Ai+1> i s computed from w i t h i n the new e n c l o s i n g o b j e c t , perhaps i t s e l f y i e l d i n g another o b j e c t or item. Knowledge may be represented i n schemata i n three d i f f e r e n t ways. F i r s t , i t can be represented d e c l a r a t i v e l y as e i t h e r atoms d e f i n e d w i t h i n the schema o b j e c t or as p a t t e r n s i n a tupleibase contained w i t h i n the o b j e c t . we saw above how atoms c o u l d be a s s o c i a t e d with d e f i n i t i o n s by c r e a t i n g a new o b j e c t u s i n g e i t h e r OBJECT or NEW. Atom b i n d i n g s can a l s o be added t o e x i s t i n g o b j e c t s by u s i n g SEND and PUT*. For example, to add a new schema s l o t to the ge n e r i c schema, DOG: {SEND DOG (PUT* «VIBTUE * MANS—BEST-FBIEND)). SEND f i r s t e v a l u a t e s DOG which y i e l d s an o b j e c t , the dog schema. T h i s o b j e c t i s then pushed onto the processor s t a c k , thus becoming the e n c l o s i n g o b j e c t . The e v a l u a t i o n of PUT* then adds the new d e f i n i t i o n of the atom, VIRTUE, to the e n c l o s i n g o b j e c t . That i s , a new s l o t i s added to the schema, DOG. To access s l o t s i n a schema, i t i s again necessary to 5: Maya 125 "goto" t h a t schema's o b j e c t . For example, the form: (SEND DOG (PRINT CLASS) VIRTUE) , w i l l f i r s t p r i n t MAMMALIA and then r e t u r n MANS-BEST-FBIENB. D e c l a r a t i v e knowledge may a l s o be r e a l i z e d as p a t t e r n s i n a s s o c i a t i v e databases d e f i n e d w i t h i n schemata. Mechanisms f o r p a t t e r n matching i n schemata are discus s e d i n the next s e c t i o n . The second way knowledge can be represented i n schemata i s p r o c e d u r a l l y u s i n g l o c a l f u n c t i o n d e f i n i t i o n s . In Maya, the property l i s t of an atom i s represented as an o b j e c t bound t o t h a t atom. Since the EXPB f u n c t i o n property i s no d i f f e r e n t than any other p r o p e r t y , f u n c t i o n d e f i n i t i o n s can be l o c a l p r o p e r t i e s of o b j e c t s . For example, (DEFON F00 (X) X) c r e a t e s , as expected, a LAMBDA exp r e s s i o n bound to the name, EXPB, on the property l i s t of the atom, FOO. However, e v a l u a t i n g the f o l l o w i n g form: (SEND FOO EXPB) r e t u r n s the b i n d i n g of the atom, EXPB, w i t h i n the o b j e c t , FOO, which i s : (LAMBDA (X) X) . As w e l l , a new d e f i n i t i o n o f FOO can be l o c a l l y a s s o c i a t e d with a p a r t i c u l a r o b j e c t , f o r i n s t a n c e : (SEND DOG (DEFUN FOO (X) 'WOOF)). E v a l u a t i n g (FOO *A) y i e l d s A but e v a l u a t i n g : (SEND DOG (FOO »A)) y i e l d s i n s t e a d WOOF. Furthermore, the data s t r u c t u r e c r e a t e d by 5: Maya 126 t h i s example i s i t s e l f a network of o b j e c t s which can be accessed as f o l l o w s : (SEND DOG FOO EXPB) which y i e l d s (LAMBDA (X) 'WOOF). The t h i r d mechanism f o r r e p r e s e n t i n g knowledge i n schemata i s p r o c e d u r a l attachment (Winoqrad, 1975). In Maya, both g e n e r a t o r s f o r performing top-down s e a r c h and processes f o r r e a l i z i n g bottom-up search can be a s s o c i a t e d with t u p l e p a t t e r n s i n t u p l e b a s e s l o c a l to schemata. such procedures a t t a c h e d to pat t e r n s are Maya's mechanism f o r a s s o c i a t i n g top-down and bottom-up methods with a schema's e x p e c t a t i o n s , represented as p a t t e r n s . Top-down and bottom-up methods w i l l be d i s c u s s e d i n s e c t i o n s 5.5 and 5.6 r e s p e c t i v e l y . 5.3.2 Messages The e v a l u a t i o n of SEND can a l s o be d e f i n e d r e c u r s i v e l y i n terms of sending messages. The value of SEND a p p l i e d to the sequence, [<A1XA2> . ,. . <An>], i s r e c u r s i v e l y the r e s u l t of sending <A1> the messaqe, [<A2> . . . <An>], and so on, r e t u r n i n q f i n a l l y the value o f <An>. Thus, e v a l u a t i n q a messaqe sequence i s sendinq the value o f the CAB of the sequence a messaqe, the CDB of the sequence. An example f o l l o w s which i l l u s t r a t e s i n Maya the 5: Maya 127 c o n s t r u c t i o n of i n s t a n c e h i e r a r c h i e s , and the use of some c f the Maya p r i m i t i v e s to i n t e r p r e t simple p r o c e d u r a l messages. T h i s example i s e x t r a c t e d from a Maya program to play "Twenty Questions". In t h i s program, an i n s t a n c e h i e r a r c h y i s used as a d i s c r i m i n a t i o n t r e e to i n t e r p r e t a s e r i e s of responses from the user. Each node i n the net c o n t a i n s a question plus the p o s s i b l e branches of the t r e e to take depending on the user's response. Although the example i s s i m p l i s t i c , i t demonstrates the use of Maya network s t r u c t u r e s and simple message passing and i n t e r p r e t a t i o n . (DEFUN TWENTY-QUESTIONS SEXPR NIL (PRINT •"PLEASE THINK OF SOME OBJECT") (SEND TOP-NODE (ASK 20)} ) The t o p - l e v e l f u n c t i o n sends the Top-Node of the d i s c r i m i n a t i o n net a message to ASK 20 g u e s t i o n s . (DEFUN ASK SEXPR (N) (AND (ZEROP ?N) (BETUBN '"YOU WIN" 'TWENTY-QUESTIONS)) (PRINT QUESTION) (SEND (EVAL (READ)) {ASK (SUB 1 ?N)))) In t h i s example, the message sent to each node i s p r o c e d u r a l . I t says: "Check to see i f we have asked more than 20 g u e s t i o n s ; i f so, then l o s e . Otherwise, p r i n t your guestion and r e c u r s i v e l y send t h i s same message (minus 1 from N) to your c h o i c e of next node." A few of the semantic net nodes of t h i s program f o l l o w : 5: Maya 128 (PUT* 'BIN—NODE (OBJECT •NODE)) (SEND BIN-NODE {DEFUN SSK SEXPB (N) (PRINT «"I BIN ! !") ?N)) (POT* 'NODE4 (OBJECT 'NODE QUESTION '"IS IT A SNAKE?" YES WIN-NODE NO N0DE7) ) (PUT* * NODE1 (OBJECT * NODE QUESTION *"HOW MANY LEGS DOES IT HAVE?" ZEBO NODE4 TWO NODE5 FOUR NODE6) ) (PUT* *TOP-NODE (OBJECT * NODE QUESTION »"IS IT ANIMAL, VEGETABLE, OR MINEBAI?" ANIMAL NODE1 VEGETABLE NODE2 MINERAL NODE3) ) In the r e c u r s i v e c a l l s to ASK, how does the r e c u r s i o n terminate? On f a i l u r e , that i s , a f t e r the twent i e t h q u e s t i o n , the f i r s t l i n e i n the body o f ASK w i l l terminate the r e c u r s i o n . On success however, the process i s q u i t e d i f f e r e n t . At NODE4, i f the user answers "yes" to the qu e s t i o n , " I s i t a snake?", a node c a l l e d WIN-NODE i s sent the message, (ASK (SUB 1 ?N) ) . Within WIN-NODE i s a l o c a l d e f i n i t i o n of the f u n c t i o n , ASK. WIN-NODE has i t s own i n t e r p r e t e r f o r t h i s p a r t i c u l a r message. I t always i n t e r p r e t s the message as a s u c c e s s f u l end of the Th i s example serves t o i l l u s t r a t e a few b a s i c f e a t u r e s of 5; Maya 129 Maya. Through the use of PUT* and OBJECT, semantic networks can be c o n s t r u c t e d . As w e l l , SEND can be used to send simple p r o c e d u r a l messages between o b j e c t s . In t h i s example, an answer t o the c u r r e n t guestion i s e l i c i t e d from the user. I f h i s answers are r e s t r i c t e d t o atoms, then the ex p r e s s i o n , (EVAL (READ) ) w i l l f e t c h an o b j e c t , the next node of the d i s c r i m i n a t i o n t r e e . SEND pushes t h i s o b j e c t onto the s t a c k , and subsequently e v a l u a t e s i n t h i s new context the r e s t of the messaqe, which i s the r e c u r s i v e c a l l t o ASK. SEND f e t c h e s each f u n c t i o n from i t s name's f i r s t d e f i n i t i o n on the stack. T h i s p r o v i d e s the mechanism to allow the o b j e c t r e c e i v i n g a message t o perform i t s own l o c a l i n t e r p r e t a t i o n of th a t message. In t h i s example, when SIN-NODE i s sent the message, ASK, the d e f i n i t i o n of ASK d e f i n e d l o c a l l y i s used because SEND had p r e v i o u s l y pushed WIN-NODE, i n c l u d i n g i t s l o c a l d e f i n i t i o n of ASK, onto the stack. Suppose, however, t h a t the user types an atomic answer that the program i s not e x p e c t i n g . The r e s u l t would be u n p r e d i c t a b l e because Maya w i l l f e t c h the f i r s t d e f i n i t i o n of the atom i t can f i n d . For a random answer, the d e f i n i t i o n i s l i k e l y to be NIL. I f we r e p l a c e the form, (EVAL (READ)) i n ASK with: (GET* (READ) • (WHAT?) ) and d e f i n e a new f u n c t i o n , we now have a s o l u t i o n : (DEFUN WHAT? 9EXPR NIL (PRINT '"WHAT ?") (RETURN (ASK ?N) •ASK)) 5: Ma ya 130 GET* always fetches d e f i n i t i o n s from w i t h i n the c u r r e n t e n c l o s i n g o b j e c t . I f GET* f a i l s to f i n d the name defined i n the e n c l o s i n g o b j e c t , the second argument i s e v a l u a t e d . I n t h i s case, (WHAT?) which j u s t asks the same q u e s t i o n again. 5.4 Pattern Hatching S y n t a c t i c p a t t e r n matching pro v i d e s a p r i m i t i v e l e v e l of comparison based only on s y n t a c t i c form. Maya d e f i n e s a number of p a t t e r n matching p r i m i t i v e s s i m i l a r to those provided i n most recent, a r t i f i c i a l i n t e l l i g e n c e programming languages, (Hewitt, 1972) (McDermott, 1973) (Davies, 1973). Maya uses i t s patte r n matcher t o compare t u p l e s , t o perform a s s o c i a t i v e r e t r i e v a l of t u p l e p a t t e r n s from databases, t o implement generators and processes, and as a s y n t a c t i c base upon which to b u i l d semantic a s s o c i a t i v e r e t r i e v a l over schemata systems. T h i s higher network matching may i n v o l v e a c t i v e search and deduction (Bobrow & Winograd, 1977). Semantic matching over schemata s t r u c t u r e s i s , as has alre a d y been pointed out, another c h a r a c t e r i z a t i o n of the r e c o g n i t i o n problem. The p a t t e r n matcher i n Maya i s c a l l e d MATCH. The form of a c a l l to MATCH i s as f o l l o w s : (MATCH <pattern><db>[ <else> J) . I t s f i r s t argument, <pattern>, i s matched a g a i n s t a datum, <db>, w,hich i s e i t h e r another t u p l e or an a s s o c i a t i v e database of t u p l e s c a l l e d a tuplebase. The matcher, on a s u c c e s s f u l match, 5: Maya 131 r e t u r n s an item composed of the bindings o f any pa t t e r n matching v a r i a b l e s assigned d u r i n g the match. On f a i l u r e , an o p t i o n a l t h i r d argument, <else>, i s ev a l u a t e d . T h i s o p t i o n a l argument i s c a l l e d a f a i l u r e e x i t and i s used to c o n t r o l f a i l u r e d r i v en s e a r c h . fin example of p a t t e r n matching i n Maya i s given by the f o l l o w i n g : (HATCH *<0N !:X !:Y> »<0N B1 TABLE> »(F00)). The e v a l u a t i o n of t h i s e x p r e s s i o n r e s u l t s i n a s u c c e s s f u l match r e t u r n i n g as value an item c o n t a i n i n g the v a r i a b l e s X bound to B1 and Y bound t o TABLE, I f the match had f a i l e d , the form, fFOO), would have been evaluated and retu r n e d as the value of MATCH, The item returned from the p a t t e r n matcher may a l s o c o n t a i n a r e a c t i v a t i o n t a g . T h i s t ag i s a p o i n t e r to the c u r r e n t i n v o c a t i o n of the matcher i n order t h a t i t may be r e c a l l e d f o r another match. Because the patte r n matcher i s implemented as a generator, MATCH provi d e s a n o n - d e t e r m i n i s t i c search mechanism f o r tuplebases. Tuplebases are accessed by the patte r n matcher, v a r i o u s database maintenance f u n c t i o n s , and a number of c o n t r o l s t r u c t u r e f u n c t i o n s f o r s c h e d u l i n g both top-down and bottcm-up methods. Any t u p l e p a t t e r n i n a tuplebase may have an a s s o c i a t e d value which i s i n c l u d e d i n the item r e t u r n from the matcher as the value c f the d i s t i n g u i s h e d v a r i a b l e , "?*". Tuplebases are composed of an i n v e r t e d index s t r u c t u r e which 52 Maya 132 uses Maya o b j e c t s to r e p r e s e n t each l e v e l of the index. Since they are formed from a p r i m i t i v e data type, t u p l e b a s e s may as w e l l be operated on with o r d i n a r y o b j e c t a c c e s s i n g f u n c t i o n s . For example, to c r e a t e a new t u p l e b a s e of a s s e r t i o n s w i t h i n the e n c l o s i n g o b j e c t : (PUT* * ASSERTIONS (OBJECT 0) ) N o t i c e t h a t as many tuplebases as d e s i r e d may be c r e a t e d i n t h i s manner. In order t o add a p a t t e r n a s s e r t i o n to t h i s t u p l e b a s e , the f o l l o w i n g form could be e v a l u a t e d : (PADD «<WOOF BE D 0 G > ASSERTIONS). F i n a l l y , to d e l e t e a s s e r t i o n s from t h i s t u p l e b a s e : (PREMOVE »<PUSHKIN HAS FLEAS> ASSERTIONS). 5.5 Top-down Methods Top-down search i n Maya i s based on the n o t i o n of generators which are f u n c t i o n s t h a t may be r e c a l l e d a number of times f o r a s i n g l e i n v o c a t i o n . A l t e r n a t i v e l y , generators may be thought of as f u n c t i o n s t h a t r e t a i n an i n t e r n a l s t a t e between c a l l s . There are f o u r types of generators i n Maya: 1. MATCH 2. QLAMBDA ex p r e s s i o n s and QEXPR f u n c t i o n s . 3. B1ST and D1 ST. 4. NEXT and FAIL. 5: Maya 133 The p a t t e r n matching f u n c t i o n , HATCH, has been already d e s c r i b e d . The second type of generator i s r e a l i z e d by combining the concept of QLAHBDA expre s s i o n s from QLISP (Davies, 1973) and Maya items. The mechanism i s a g e n e r a l i z a t i o n of the generators d e f i n e d i n CONNIVER (McDermott S Sussman, 1S73). Each QLAHBDA exp r e s s i o n has a t u p l e p a t t e r n as i t s argument l i s t . QLAHBDAs are invoked by matching a pa t t e r n i n the form of a t u p l e a g a i n s t e i t h e r the pa t t e r n argument of a s p e c i f i c QLAMEDA e x p r e s s i o n or against a tuplebase of Q LAMBDA ex p r e s s i o n s . QLAMBDAs always r e t u r n items as v a l u e s . fts i n MATCH, the item i s composed of the bindings of the p a t t e r n v a r i a b l e s assigned d u r i n g the p a t t e r n match p l u s a p o s s i b l e r e a c t i v a t i o n t a g f o r the generator. QLAMBDA expre s s i o n s may be given names by c r e a t i n g QEXPR type f u n c t i o n s with DEFON. QLAMBDAs and QEXPRs take o p t i o n a l l y one or two arguments: ((QLAHBDA <arg-patternXbody>) <pattern>[ <else> ]) or (<qexpr><arg-patt ern>[ <else> ]) . The f i r s t argument, <pattern>, must be a t u p l e and i s the p a t t e r n to be matched against the argument l i s t , <arg-pattern>. The second argument, <else>, i s evaluated i f the p a t t e r n match f a i l s or i f the QLAMBDA e x p r e s s i o n e v a l u a t e s a c a l l to FAIL. <Else> d e f a u l t s to NIL. Sin c e QLAHBDAs and QEXPRs are t r e a t e d by the i n t e r p r e t e r as any other f u n c t i o n , they may be a p p l i e d , mapped, and evaluated. QLAMBDA e x p r e s s i o n s may be s t o r e d i n t u p l e b a s e s by bi n d i n g them t o p a t t e r n s i d e n t i c a l t o t h e i r p a t t e r n arguments. A 5: Maya 134 mechanism i s thus r e a l i z e d f o r a s s o c i a t i n g top-down methods with p a t t e r n s . Methods are added to a method tuplebase as f o l l o w s : (PADD <arg-pattern><method-base><gxl>), where <arg-pattern> i s the p a t t e r n argument of the method, <qxl> i s e i t h e r a QEXPR name or a QLAMBDA e x p r e s s i o n , and <method-base> i s a tu p l e b a s e o f methods. Methods are d e l e t e d from t u p l e b a s e s i n a s i m i l a r f a s h i o n : (PBEMOVE <arg-pattern><method-base>). The t h i r d type of generator i s used t o access and then invoke QLAMBDA ex p r e s s i o n s i n tuplebases by matching t h e i r a s s o c i a t e d p a t t e r n s . Two d i f f e r e n t mechanisms are provided. D1ST searches a tu p l e b a s e o f QLAMBDA expressions i n d e p t h - f i r s t order. The form of c a l l s to t h i s f u n c t i o n a r e : (D1ST <pattern> <db> [ <else> T) . D1ST w i l l f e t c h from the tu p l e b a s e , <db>, a QLAMBDA exp r e s s i o n matching <pattern> and then invoke that f u n c t i o n . A s u c c e s s f u l value returned from the QLAMBDA w i l l a l s o be re t u r n e d from D1ST with the a d d i t i o n of a r e a c t i v a t i o n t a g . I f the tag i s l a t e r used to r e s t a r t the generator, D1 ST w i l l r e c a l l the QLAMBDA ex p r e s s i o n t o generate another item. D1ST w i l l continue to r e c a l l t h a t same QLAMBDA u n t i l i t f a i l s to generate any new items. Then D1ST w i l l r e t u r n to the tuplebase to search f o r another QLAMBDA exp r e s s i o n matching <pattern>. S i m i l a r l y , B1ST searches a tuplebase of QLAMBDA exp r e s s i o n s i n fcreadth-first order. The form of t h i s p r i m i t i v e i s : 5: Maya 135 (B 1ST <pattern> <db> [< e l s e > ] ) . B1ST w i l l invoke the f i r s t QLAMBDA e x p r e s s i o n i t f i n d s that matches <pattern>, and r e t u r n the item y i e l d e d by the QLAMBDA with the a d d i t i o n of a r e a c t i v a t i o n tag as i t s own value. However, when t h i s generator i s resumed a g a i n , E1ST w i l l attempt to f i n d a d i f f e r e n t matching QLAMBDA e x p r e s s i o n i n the tuplebase. Only a f t e r i t has invoked once a l l matching QLAMBDA methods w i l l i t r e c a l l each suspended QLAMBDA f o r a second time, and then each f o r a t h i r d time, and so f o r t h . The l a s t type of generator d e f i n e d i n Maya i n c l u d e s the c o n t r o l p r i m i t i v e s f o r r e s t a r t i n g generators frcm the r e a c t i v a t i o n tags r e t u r n e d i n t h e i r items. The f u n c t i o n s , NEXT and FAIL, are used f o r l o o p - d r i v e n and f a i l u r e - d r i v e n search r e s p e c t i v e l y . For a comparison of the two approaches, see Sussman and McDermott (1972). NEXT, which i s analogous t o Conniver's TRY-NEXT, i s a f u n c t i o n of two arguments: (NEXT <item> [<else>]). <Item> must be an item c r e a t e d by another generator. NEXT looks f o r a r e a c t i v a t i o n tag i n the item. I f i t f i n d s such a tag, the attached generator i s resumed. Otherwise, i f no tag i s found or the resumed generator f a i l s , NEXT e v a l u a t e s <else>, i t s o p t i o n a l f a i l u r e form. For example, t o f i n d i n a t u p l e b a s e , TOYS, the names of a l l boxes, the f o l l o w i n g expression c o u l d be used: (PROG (X) {SETQ X (MATCH »<BOX !:B> TOYS *(RETURN NIL))) 5: Maya 136 LOOP (SEND ?X (PRINT ?B) ) (SETQ X (NEXT ?X *(RETURN NIL))) (GO LOOP) ) F a i l u r e - d r i v e n search i s r e a l i z e d i n Maya by using the FAIL f u n c t i o n i n c o n j u n c t i o n with another p r i m i t i v e , ELSE. FAIL i s a f u n c t i o n of no arguments t h a t causes Maya to begin d i s c a r d i n g c o n t r o l frames from i t s processor stack u n t i l an item i s found on the stack c o n t a i n i n g a r e a c t i v a t i o n t a g . The generator attached to t h i s tag i s then r e s t a r t e d from t h a t f a i l p o i n t . The f u n c t i o n ELSE p r o v i d e s the necessary mechanism f o r c o n t r o l l i n g f a i l u r e - d r i v e n s e a r c h . I t i s a very simple f u n c t i o n of one argument which c r e a t e s an e x p l i c i t f a i l p o i n t with that unevaluated argument. ELSE r e t u r n s an item c o n t a i n i n g crdy a ta g bound to t h i s f a i l p o i n t . , When the tag i s reinvoked by FAIL, the argument i s f i n a l l y e v a l u a t e d , thereby p r o v i d i n g a mechanism f o r c a p t u r i n g f a i l u r e . The mechanism i s c a l l e d a f a i l u r e block and i s i l l u s t r a t e d i n the f o l l o w i n g example: (SEND (ELSE •(FAILURE-EXIT)) (MATCH »<BLOCK !:X> TOYS • (FAIL) ) (MATCH »<COLOUR ?X BLUE> TOYS » (FAIL)) (SUCCESS-EXIT)) T h i s program segment attempts to f i n d a blue block from the database of t o y s . I f i t i s s u c c e s s f u l , c o n t r o l passes through the block. Otherwise, a f a i l u r e e x i t i s taken. F a i l u r e blocks d e f i n e a l o c a l backtrack s e a r c h mechanism t h a t f o l l o w s separate c o n t r o l paths depending upon whether the l o c a l search succeeds 5: Maya 137 or f a i l s . 5.6 Ecttcm-up Methods Bottom-up search i s r e a l i z e d i n Maya v i a m u l t i p r o c e s s i n q . Processes c o n s i s t of semi-autonomous procedures. A number of processes may c o - e x i s t s i m u l t a n e o u s l y and may or may not be a s s o c i a t e d with p a r t i c u l a r schemata. Processes may be c r e a t e d , invoked, destroyed, and resumed by other processes. a process may terminate or suspend i t s e l f or i t may v i a the COMPLETE f u n c t i o n suspend i t s e l f and a l l other processes a s s o c i a t e d with a p a r t i c u l a r schema. The procedure body of each process c o n s i s t s of a QLAMBDA ex p r e s s i o n . When a process i s cr e a t e d , a s p e c i f i e d p a t t e r n i s matched a q a i n s t the p a t t e r n of the QLAMBDA e x p r e s s i o n . Processes may be suspended to p a t t e r n s i n a s p e c i f i e d tuplebase of processes. Suspended processes may be resumed by matchinq those p a t t e r n s . Processes are c r e a t e d i n Maya v i a the f u n c t i o n , PROCESS, which has the f o l l o w i n g form: (PROCESS <schema> <gl> <pattern> r < e l s e > 1 ) . <Pattern> i s matched aqainst the p a t t e r n argument of the QLAMBDA exp r e s s i o n . Should the match f a i l , <else> i s eval u a t e d i f present or d e f a u l t s to NIL. Otherwise, a new process i s cr e a t e d with the QLAMBDA exp r e s s i o n as the body of the process. The process i s a s s o c i a t e d with an o b j e c t , <schema>, or i f NIL i s 5: Maya 138 s p e c i f i e d , with no o b j e c t . The a s s o c i a t i o n of processes with schemata i s u t i l i z e d by the system f u n c t i o n , COMPLETE, which i s d e s c r i b e d l a t e r , Once a process i s c r e a t e d , i t s procedure body i s executed u n t i l i t terminates or i s suspended, A process l a y be terminated by exe c u t i n g the l a s t form i n i t s procedure body or by executing the EXIT or FAIL f u n c t i o n s . Processes may be suspended v i a the SUSPEND or COMPLETE f u n c t i o n s . SUSPEND i s a p r i m i t i v e of two arguments, a t u p l e , <pattern>, and a tuplebase, <db>, as i n d i c a t e d i n : (SUSPEND <pattern> <db>). . The c u r r e n t running process i s suspended t o the p a t t e r n and i s s t o r e d i n the s p e c i f i e d t u p l e b a s e . C o n t r o l r e t u r n s t o the process which invoked the now suspended process. Maya r e c o g n i z e s two types of processes i n t u p l e b a s e s ; suspended processes and named processes. A suspended process c o n s i s t s of the segment of the stack r e p r e s e n t i n g the c u r r e n t s t a t e o f e v a l u a t i o n o f the process plus an a s s o c i a t e d schema. A named process c o n s i s t s c f e i t h e r a QLAMBDA e x p r e s s i o n or a QEXPR name p l u s an a s s o c i a t e d schema. Suspended processes are added to a tuplebase v i a the SUSPEND f u n c t i o n . Named processes are added t o a tuplebase as f e l l o w s (PADD <patternXdb> (NAMED-PROCESS <glXschema>) ) . T h i s form adds t o the tuplebase, <db>, under the p a t t e r n , <pattern>, a named process whose procedure body, <gl>, i s a QLAMBDA expre s s i o n or a QEXPR name. <Pattern> and the pa t t e r n 5: Maya 139 argument of <ql> must be i d e n t i c a l . I f <schema> i s an o b j e c t , the process i s a s s o c i a t e d with the schema represented by the o b j e c t . I f <schema> i s NIL, the process i s not a s s o c i a t e d with any schema. The major d i f f e r e n c e s between named processes and suspended processes are the f o l l o w i n g . A suspended process may be resumed onl y once f o r each appearance i n a t u p l e b a s e . When i t i s invoked, the p a t t e r n t o which i t was bound i s d e l e t e d from the tuplebase. On the oth e r hand, a named process may be invoked m u l t i p l e times from the same p a t t e r n i n a t u p l e b a s e , each i n v o c a t i o n r e s u l t i n g i n the i m p l i c i t c r e a t i o n c f a new process, and the p a t t e r n i s not d e l e t e d from the tuplebase. Suspended and named processes are resumed by the BESUME f u n c t i o n which ta k e s t h r e e arguments: a p a t t e r n , <pattern>, a tuplefcase, <db>, and an o p t i o n a l f a i l u r e form, <else>: (RESUME <pattern> <db> [<else>]). <Pattern> i s matched a g a i n s t the tuplebase, <db>. I f the match f a i l s , <else> i s ev a l u a t e d . Otherwise, the process bound to the matched p a t t e r n i n the tuplebase i s resumed. I t w i l l be n o t i c e d t h a t a l l the top-down and bottcm-up c o n t r o l p r i m i t i v e s r e t u r n items as v a l u e s . T h e r e f o r e , f u n c t i o n s such as RESUME are a l s o generators. In the case cf process p r i m i t i v e s , they are bottom-up generators. The item returned as value from RESUME can be operated on by NEXT and FAIL t o s e q u e n t i a l l y generate and then t c resume every process matching p a t t e r n . 5: Maya 140 A schema may have more than one of i t s a s s o c i a t e d processes a c t i v e a t any one time. The s t a c k thus may c o n t a i n a number c f processes a s s o c i a t e d with the same schema. A l l of these processes have a common purpose, to whit, the r e c o g n i t i o n c f an i n s t a n c e of the schema's s t e r e o t y p e . When a schema i s s u c c e s s f u l i n i t s r e c o g n i t i o n , the e f f o r t s of a l l i t s processes need t o be suspended. T h i s i s c a l l e d completion i n the r e c o g n i t i o n model. The f o l l o w i n g f u n c t i o n , COMPLETE, provides a mechanism f o r suspending a l l the processes of a schema and resuming the process of another s p e c i f i e d schema or schemata; {COMPLETE <pattern> <db> C<else>]}. <Pattern> i s matched a g a i n s t the tuplebase of processes, <db>. On success, the c u r r e n t p r o c e s s , P1, i s suspended as d e s c r i b e d below t o a r e a c t i v a t i o n tag. COMPLETE then resumes the process matching <pattern>, P2. T h i s complex f u n c t i o n i s the main c o n t r o l s t r u c t u r e mechanism i n Maya f o r r e a l i z i n g the c o n t r o l aspects of the r e c o g n i t i o n model. COMPLETE supports supergoals, h e u r i s t i c method s c h e d u l i n g , and method h i e r a r c h i e s . The mechanism i s based on the assumption t h a t f o r machine p e r c e p t i o n t a s k s a l l top-down and bottom-up methods a s s o c i a t e d with a p a r t i c u l a r schema are concerned with the u l t i m a t e r e c o g n i t i o n c f t h a t schema i n s t a n c e . T h e r e f o r e , when a method a s s o c i a t e d with a p a r t i c u l a r schema has concluded t h a t the r e c o g n i t i o n of i t s i n s t a n c e i s complete, a l l c o n c u r r e n t l y a c t i v e methods a s s o c i a t e d with t h a t same schema are no longer needed. They must be 5: Maya 141 suspended. In order to achieve t h i s r e s u l t , COMPLETE searches the processor stack to f i n d every occurrence of processes a s s o c i a t e d with the same schema as the c u r r e n t process ( l a b e l l e d P1 above). Every such process and i t s sub-processes are then suspended. F i n a l l y , p2 i s resumed. 5.7 C o n c l u s i o n T h i s chapter has presented a b r i e f overview of a new a r t i f i c i a l i n t e l l i g e n c e programming language. The language was d i s c u s s e d from the p e r s p e c t i v e of r e a l i z i n g the p r o c e d u r a l mechanisms d e f i n e d i n the r e c o g n i t i o n model. although i t i s i m p o s s i b l e t o completely c h a r a c t e r i z e a h i g h - l e v e l programming language t h a t i n t r o d u c e s new complex c o n t r o l and data s t r u c t u r e s i n the space a v a i l a b l e here, a number of i t s s a l i e n t f e a t u r e s have been d i s c u s s e d . a t u t o r i a l on Maya, designed to augment the d e s c r i p t i o n s presented here and to supplement the language r e f e r e n c e appearing i n appendix-B, i s now i n p r e p a r a t i o n . 5: Maya 112 CHAPTER 6: RECOGNITION RJVISITEE 6.1 P e r s p e c t i v e In t h i s f i n a l c h apter, t h e author takes the op p o r t u n i t y to step back and re-examine the work of t h i s t h e s i s . A r e c a p i t u l a t i o n of the r e c o g n i t i o n model i s made from the p e r s p e c t i v e of i t s c o n t r i b u t i o n t o a theory of machine p e r c e p t i o n . F i n a l l y , a p p l i c a t i o n s f o r the model are d i s c u s s e d i n d i c a t i n g some promising d i r e c t i o n s f o r f u t u r e r e s e a r c h . 6.2 Recognition R e v i s i t e d P e r c e p t i o n has been c h a r a c t e r i z e d as an a c t i v e r e c o g n i t i o n t a s k . Such a view of p e r c e p t i o n i s held by Bobrow and Winograd (1977) : Reasoning i s dominated by a process of r e c o g n i t i o n i n which new o b j e c t s and events are compared to s t o r e d s e t s o f expected prototypes, and i n which s p e c i a l i z e d r e a s o n i n g s t r a t e g i e s are keyed to these prototypes (p.4). T h i s process i s more than a simple p a s s i v e r e t r i e v a l from memory of a s t o r e d d e s c r i p t i o n of the t h i n g p e r c e i v e d . Experience i s much too v a r i e d and complex t o depend on such a mechanism. We are c o n s t a n t l y e x p e r i e n c i n g new s i t u a t i o n s , 6: R e c o g n i t i o n R e v i s i t e d 143 s e e i n g new o b j e c t s , understanding new sentences. We probably never p e r c e i v e e x a c t l y the same experience i n the same s i t u a t i o n more than once. Thus, p e r c e p t i o n i s a g e n e r a t i v e process, composing new d e s c r i p t i o n s of experience i n terms of a s t o r e d f i n i t e knowledge of the world (Chomsky, 1957). Jaynes (1976) argues t h a t p e r c e i v i n g an experience i s a process of a r r i v i n g at a metaphor to d e s c r i b e t h a t experience. Generations ago we would understand thunderstorms perhaps as the r o a r i n g and rumbling about i n b a t t l e of superhuman gods. We would have reduced the r a c k e t that f o l l o w s the streak of l i g h t n i n g to f a m i l i a r b a t t l e sounds, f o r example. S i m i l a r l y today, we reduce the storm to v a r i o u s supposed experiences with f r i c t i o n , sparks, vacuums, and the imagination of bulgeous banks of b u r l y a i r smashing together to make the noise. None of these r e a l l y e x i s t as we p i c t u r e them. Our images of these events of p h y s i c s are as f a r from the a c t u a l i t y as f i g h t i n g gods. Yet they a c t as metaphor and they f e e l f a m i l i a r and so we say we understand the thunderstorm (p.52). Thus, d e s c r i p t i o n s of experience are m e t a p h o r i c a l . Se p e r c e i v e the sensory world i n terms of our s t o r e d d e s c r i p t i v e knowledge of that world. In order to develop a theory of machine p e r c e p t i o n , we must c h a r a c t e r i z e mechanisms f o r emulating t h i s g e n e r a t i v e p r o c e s s . The s p e c i f i c a t i o n of a theory f a c e s two major i s s u e s : r e p r e s e n t a t i o n and r e c o g n i t i o n . What i s the form and o r g a n i z a t i o n of memory and what types of p r o c e d u r a l mechanisms can perform r e c o g n i t i o n on that r e p r e s e n t a t i o n ? The p s y c h o l o g i c a l g u e s t i o n of memory o r g a n i z a t i o n i s f a r 6: R e c o g n i t i o n R e v i s i t e d 144 from r e s o l v e d . There i s experimental evidence s u p p o r t i n g both imagery and s t r u c t u r a l r e p r e s e n t a t i o n s ( Y u i l l e , 1976). However, Chase and Simon (1973) have shown t h a t chess masters arc much b e t t e r at remembering chess board p o s i t i o n s ficm a c t u a l chess games than from random board arrangements. The expert's a b i l i t y a t remembering random boards approaches t h a t of non-chess p l a y e r s , thus i n d i c a t i n g a d e f i n i t e dependence on s t r u c t u r a l d e s c r i p t i o n s . I t seems c l e a r t h a t h i g h - l e v e l reasoning depends predominantly on schematic mechanisms (Pylyshyn, 1976), although p e r c e p t i o n most c e r t a i n l y makes use o f both imagery and schemata. A major aspect of t h i s t h e s i s i s the c h a r a c t e r i z a t i o n of p e r c e p t i o n as an a c t i v e process t h a t e x p l o i t s h e u r i s t i c knowledge of the world. The value of a c t i v e h e u r i s t i c knowledge has been demonstrated by Einograd's (1973a) n a t u r a l language system, SHRDLU. His system was a s i g n i f i c a n t advance i n the s t a t e o f the a r t , i n c o r p o r a t i n g p r o c e d u r a l semantics i n a language understanding system. The apparent l e s s e n c f h i s r e s e a r c h was that p r o c e d u r a l semantics i s more powerful than d e c l a r a t i v e semantics f o r performance-based systems. A more i n s i g h t f u l l e s s o n i s t h a t p r o c e d u r a l semantics coupled with h y p o t h e s i s - d r i v e n search p r o v i d e s a mechanism f o r i n t r o d u c i n g h e u r i s t i c knowledge to guide the p e r c e p t i o n process. Procedures are only the v e h i c l e f o r the improvement i n performance, not the reason. The same c a p a b i l i t y can be obtained i n purely l o g i c a l systems, as Hayes (1973) has argued, by d e f i n i n g deductive 6; R e c o g n i t i o n R e v i s i t e d 145 c o n t r o l o p e r a t o r s w i t h i n the formal l o g i c system. Again, such mechanisms provide the v e h i c l e f c r i n t r o d u c i n g a c t i v e knowledge i n t o the p e r c e p t u a l process. U n f o r t u n a t e l y , the i n c o r p o r a t i o n of h e u r i s t i c guidance to h y p o t h e s i s - d r i v e n r e c o g n i t i o n has not been a s u f f i c i e n t l y powerful mechanism t o s c l v e the machine p e r c e p t i o n problem. Winograd {1973b) has noted t h e appearance of a "complexity b a r r i e r " t o the advancement of the a r t . The b a r r i e r a r i s e s £rem the dependence on top-down search mechanisms. Such methods r e q u i r e the system to hypothesize the c o r r e c t i n t e r p r e t a t i o n f o r some sensory i n p u t before i t can be found. The d e f i c i e n c y i s not h y p o t h e s i s - d r i v e n s e a r c h , but the f a c t t h a t a p a r t i c u l a r schema must be chosen as a p l a u s i b l e i n t e r p r e t a t i o n and attempted before any o f i t s h e u r i s t i c r e c o g n i t i o n knowledge becomes a v a i l a b l e to d i r e c t the search process. I t s e x p e r t i s e comes too l a t e ! H y p o t h e s i s - d r i v e n r e c o g n i t i o n has a l s o been proposed f o r schemata r e p r e s e n t a t i o n s (Minsky, 1975). The r e c o g n i t i o n model d e s c r i b e d by K u i p e r s (1975) i s probably the best known. As was pointed out, h i s model attempts t o avoid the i n a d e g u a c i e s of top-down search by a p p e a l i n g t o a f a i l u r e - d r i v e n s i m i l a r i t y network to recommend l i k e l y a l t e r n a t i v e hypotheses. T h i s mechanism does not c o n f r o n t the r e a l problem. Sensory data i s a h i g h l y ambiguous encoding of experience. The i n t e r p r e t a t i o n of sensory data r e q u i r e s a methodology that e x p l o i t s c o n t e x t s and can t o l e r a t e l a r g e degrees of non-determinism. The top-down 6: R e c o g n i t i o n R e v i s i t e d 146 model appeals i m p l i c i t l y to the " l i t t l e man i n the head" or tSJD.yiJSB.Iils. theory of p e r c e p t i o n (Pylyshyn, 1973). Consider the f o l l o w i n g v e r b a l example given by Kuipers (1975): A frame [schema] r e p r e s e n t s a c e r t a i n l i m i t e d domain, and hence a range of v a r i a t i o n f o r o b j e c t s which belong t o t h a t domain. As we saw i n the room s c e n a r i o , the f e a t u r e s o f a frame may be frames i n t h e i r own r i g h t , embodying ranges of v a r i a t i o n . Cn e n t e r i n g a room, you are prepared f o r c e r t a i n t y p i c a l p i e c e s of f u r n i t u r e . A park bench or diamond-encrusted throne would be o u t s i d e the p e r m i s s i b l e range of v a r i a t i o n i n t h i s frame. Such an anomaly may i n d i c a t e t o the c o r r e c t i o n mechanism t h a t another frame i s c a l l e d f o r (p. 159). In t h i s d e s c r i p t i o n , the p e r c e p t i o n problem has been f i n e s s e d by assuming t h a t i t i s e a s i e r t o r e c o g n i z e a park bench than a room. They a r e , i n f a c t , problems of the same order of complexity. Postponing the problem w i l l not s o l v e i t . R e l y i n g cn the e x p e c t a t i o n s c f the rccm schema to handle a l l or even most p o s s i b l e c o n t e n t s of a room abdicates the r e s p o n s i b i l i t y of the search process to f a i l u r e mechanisms. Upon e n t e r i n g a rccm c o n t a i n i n g an u n a n t i c i p a t e d o b j e c t , the search process w i l l b l i n d l y s e l e c t one bad hypothesis a f t e r another u n t i l an " a p p r o p r i a t e " schema i s found. Only then w i l l t h a t schema's d o m a i n - s p e c i f i c knowledge be a v a i l a b l e to guide the r e c o g n i t i o n . That knowledge was needed much e a r l i e r . One must conclude t h a t h y p o t h e s i s - d r i v e n r e c o g n i t i o n i s not the mechanism upon which to b u i l d machine p e r c e p t i o n r e g a r d l e s s of the type of a u x i l i a r y attachments added t o improve i t s performance. In order t o surmount t h i s complexity b a r r i e r , machine 6: Re c o g n i t i o n R e v i s i t e d 147 p e r c e p t i o n r e q u i r e s both hypothesis and d a t a - d r i v e n r e c o q n i t i o n . H y p o t h e s i s - d r i v e n search a p p l i e s h e u r i s t i c methods a s s o c i a t e d with the r e c o q n i t i o n of a p a r t i c u l a r schema once a commitment has been made to t h a t schema. Data-driven search provides the means to s e l e c t l i k e l y hypotheses based on the d i s c o v e r y of s u p p o r t i n q evidence and cues. Top-down and bottom-up search methods can be i n t e q r a t e d i n a s y n e r q i s t i c manner. Bottcm-up search d r i v e s the a c t i v a t i o n of p l a u s i b l e hiqher schemata as s u p e r q o a l s . A f t e r beinq e s t a b l i s h e d as l i k e l y hypotheses, these schemata attempt to confirm t h e i r r e c o q n i t i o n both by usinq top-down search v i a s u b q o a l i n q to sub-schemata and by observinq. cues i n the i n p u t data to d r i v e the bottom-up search f o r ether schemata. Recently, a number of other models have been proposed f o r p e r c e p t i o n . Mackworth (1977c) has o f f e r e d the c y c l i c model d e p i c t e d i n F i q u r e 6.1a which he a t t r i b u t e s to the o r i q i n a l work of Roberts (1965). In t h i s model, p e r c e p t i o n i s seen as an i t e r a t i v e process. The d i s c o v e r y of cues invoke a p p r o p r i a t e models. Models attempt to v e r i f y t h e i r hypotheses by o b s e r v a t i o n . S u c c e s s f u l l y r e c o q n i z e d hypotheses cause the e l a b o r a t i o n of the consequences of t h e i r models, r e s u l t i n q i n the d i s c o v e r y of new cues. Fiqure 6.1b i l l u s t r a t e s a s i m i l a r c y c l i c model of p e r c e p t i o n qiven by Neisser (1976). Schemata r e p r e s e n t e x p e c t a t i o n s which d i r e c t the e x p l o r a t i o n of the sensory world. E x p l o r a t i o n r e s u l t s i n o b s e r v a t i o n s which match these 6: S e c c q n i t i o n R e v i s i t e d 148 MODEL ELABORATION CUE DISCOVERY MODEL VERIFICATION MODEL INVOCATION Fi g u r e 6.1a OBJECT mod i f i e s samples SCHEMA d i r e c t s EXPLORATION Fi g u r e 6.1b FIGURE 6.1C 6: R e c o g n i t i o n R e v i s i t e d 149 e x p e c t a t i o n s thereby modifying the schemata and propagating the process. N e i s s e r uses t h i s model t o s t r e s s the i n h e r e n t l y s e g u e n t i a l nature of p e r c e p t i o n i n v o l v i n g the m o d i f i c a t i o n of schemata over time., Although each author al l o w s f o r the e x i s t e n c e of a cue/model h i e r a r c h y , i n n e i t h e r model i s a mechanism f o r the p e r c e p t i o n of cues as a b s t r a c t e n t i t i e s s u f f i c i e n t l y e l a b o r a t e d . F i g u r e 6,1c i l l u s t r a t e s the r e c u r s i v e model of p e r c e p t i o n presented i n t h i s t h e s i s . The model can be seen to g e n e r a l i z e the p u r e l y c y c l i c models of F i g u r e s 6.1a and 6.1b. As i n these models, r e c o g n i t i o n f o l l o w s a c y c l i c path of cue d i s c o v e r y and schemata i n v o c a t i o n . A p a r t i c u l a r schema may pass through t h i s c y c l e a number of times. However, when a schema's r e c o g n i t i o n i s completed, the r e c o g n i t i o n c y c l e ascends one l e v e l i n a h i e r a r c h y of cues and models. Schemata re c o g n i z e d at one l e v e l becomes cues i n the r e c o g n i t i o n at the next hig h e r l e v e l i n the h i e r a r c h y . Despite the f a c t t h a t the n e c e s s i t y of cue/model h i e r a r c h i e s i n the c y c l e o f p e r c e p t i o n has been c l e a r f o r seme time (Mackworth, 1976, 1977c), a mechanism f o r a c h i e v i n g t h i s g oal has not been s p e c i f i e d . The major c o n t r i b u t i o n c f t h i s t h e s i s i s the p r e c i s e c h a r a c t e r i z a t i o n of such a mechanism. The notion c f completion provides an e x p l i c i t mechanism f o r c a p t u r i n g the r e c u r s i v e nature of p e r c e p t i o n . when a schema has r e c o g n i z e d a f u l l y s p e c i f i e d i n s t a n c e of i t s s t e r e o t y p i c a l concept, i t must r e t u r n t h a t success to one or more higher 6: R e c o g n i t i o n R e v i s i t e d 150 schemata. I f the schema was a c t i v a t e d as a subgoal by a higher schema, i t must r e t u r n i t s completed d e s c r i p t i o n t o t h a t schema. Otherwise, the completed schema has been recognized using bottom-up methods and has nc e x p l i c i t c a l l e r . I t then e x i s t s as an a b s t r a c t cue which attempts to match the e x p e c t a t i o n s of higher schemata a c t i v a t i n g them as supergoals. Rumelhart and Ortony (1976) have addressed s i m i l a r c o n t r o l s t r u c t u r e i s s u e s f o r schemata. I t may be h e l p f u l t o t h i n k of these p r o c e s s i n g i s s u e s i n terms of a computer programming metaphor, f o r one can t h i n k of a schema as being a kind of procedure. Procedures have s u b r o u t i n e s and one can t h i n k of the a c t i v a t i o n of a schema as being l i k e the i n v o c a t i o n of a procedure. The v a r i a b l e s of a schema are thus analogous to the v a r i a b l e s of a procedure while the sub-schemata are analogous to the s u b r o u t i n e s which may be invoked frons w i t h i n i t . The a c t i v a t i o n of subschemata w i t h i n a schema i s l i k e the c a l l i n g - u p or i n v o c a t i o n of the s u b r o u t i n e s w i t h i n a procedure. T h i s i s the paradigm case of c o n c e p t u a l l y - d r i v e n p r o c e s s i n g . However, u n l i k e o r d i n a r y procedure c a l l s , i n which the flow of c o n t r o l i s o n l y from procedure to s u b r o u t i n e , the flow of c o n t r o l i n a schema system operates both ways. I t i s as though a given procedure not only could invoke those procedures i n which i t was i t s e l f a s u b r o u t i n e ( d a t a - d r i v e n processing}.. F i n a l l y , one must imagine these procedures as a l l o p e r a t i n g s i m u l t a n e o u s l y (p. 46). The r e a l i z a t i o n of t h i s programming metaphor as an o p e r a t i n g programming language i s the second major c o n t r i b u t i o n of t h i s t h e s i s . Maya d e f i n e s e x p l i c i t language p r i m i t i v e s f o r c r e a t i n g schemata and schemata networks, f o r a s s o c i a t i n g procedural methods with schemata, and f o r invoking those methods bcth as subgoals u s i n g c o n c e p t u a l l y - d r i v e n search and as supergoals 6: R e c o g n i t i o n R e v i s i t e d 151 u s i n g d a t a - d r i v e n techniques. As w e l l , Maya u t i l i z e s the completion aspect of the r e c o q n i t i o n model as a m u l t i p r o c e s s s c h e d u l i n g mechanism f o r s i m u l a t i n q the concurrent a p p l i c a t i o n of methods. 6.3 A p p l i c a t i o n s and Future Research The i s s u e s addressed i n t h i s t h e s i s are c u r r e n t l y of i n t e r e s t i n a number o f r e s e a r c h areas. For t h i s reason, the r e c o q n i t i o n model and i t s r e a l i z a t i o n as Maya should have qen e r a l a p p l i c a t i o n s i n such p e r c e p t i o n r e s e a r c h as machine v i s i o n , n a t u r a l language understanding, and episode understanding. Moreover, problems of c o n t r o l i n automatic deduction systems are s i m i l a r to the c o n t r o l s t r u c t u r e i s s u e s i n machine p e r c e p t i o n . Issues o f i n t e g r a t e d h y p o t h e s i s - d r i v e n and d a t a - d r i v e n r e c o q n i t i o n are analogous to s i m i l a r i s s u e s of backward and forward deduction. The ideas developed i n t h i s model c c n c e r n i n q a c t i v e h e u r i s t i c quidance and concurrent methods should a l s o have a p p l i c a t i o n t h e r e . Future r e s e a r c h w i l l focus on a s p e c i f i c task domain that e x h i b i t s the f o l l o w i n g four c r i t e r i a . F i r s t , the task must have a w e l l - d e f i n e d semantics, p r e f e r a b l y an e x p l i c i t c o n v e n t i o n a l semantic r e p r e s e n t a t i o n such as e x h i b i t e d by sketch maps (Mackworth, 1977a). Second, i n order t o e x p l o i t f u l l y the advantages of i n t e g r a t e d top-down and bottom-up r e c o g n i t i o n , the problem should have a h i g h l y ambiguous i n p u t data 6: R e c o g n i t i o n R e v i s i t e d 152 r e p r e s e n t a t i o n . T h i r d , the problem should i n h e r e n t l y have a h i e r a r c h i c a l knowledge r e p r e s e n t a t i o n i n order to demonstrate the advantages of r e c u r s i v e cue/model h i e r a r c h i e s i n machine p e r c e p t i o n . And f i n a l l y , the domain must be g e n e r a l l y accepted as a a p e r c e p t u a l task f o r which previous r e c o g n i t i o n mechanisms have been shown to be inadequate. P o s s i b l e r e s e a r c h tasks e x h i b i t i n g these c r i t e r i a i n c l u d e the i n t e r p r e t a t i o n of LANDSAT video images, the a n a l y s i s of e l e c t r o n i c c i r c u i t schematic diagrams (Stallman 6 Sussman, 1977), and the understanding of handwriting. 153 BIBLIOGRAPHY A HO A. 6 ULLMAN, J . (1972) The Theory of P a r s i n g , T r a n s l a t i o n , and Compiling, v o l 1, P r e n t i c e H a l l , Englewood C l i f f s , W7J . 7 ~P.32O7 BARTLETT, F.C. (1932) Remembering, Cambridge Oniv. P r e s s , Cambridge, England. BOBROW, D.G. 5 NORMAN, C. A. (1975) Some P r i n c i p l e s of Mencry Schemata, i n D.G.Borrow S A . C c l l i n s ( e d s . ) . R e p r e s e n t a t i o n and Understanding, Academic P r e s s , New York. BOEROH, E.G. 6 RAPHAEL, B. (1974) New Programming Languages f o r A. I, Research, Comp. Surveys, v o l 6 , pp. 1 5 3 - 1 7 4 . BOBROW, D.G. & WEGBREIT, B. (1973) A Model and Stack Implementation o f M u l t i p l e Environments, CACM, Oct. 1 9 7 3 , v o l 1 6 , #10, p.5 9 1 . BOBROW, D.G. & HINOGRAD, T. (1977) An Overview o f KRL: A Knowledge Representation Language, C o g n i t i v e S c i e n c e . v o l 1, #1, Jan 1 9 7 7 . CHARNIAK, E. (1975) O r g a n i z a t i o n and Inf e r e n c e i n a Frame-Like System of Common Knowledge, Proc. T h e o r e t i c a l Issues i n Natural Language P r o c e s s i n g , Cambridge, Mass., June 1 9 7 5 , p.46 . CHASE, W. G. & SIMON, H. (1973) P e r c e p t i o n i n Chess, C o g n i t i v e Psychology, #4, pp. 5 5 - 8 1 . CHOMSKY, N. (1957) S y n t a c t i c S t r u c t u r e s , The Hague: Moutcn and co. CLOWES, M.B. (1971) On Seeing Things, A r t i f i c i a l I n t e l l i g e n c e , v o l 2 , #1, pp.7 9 - 1 1 2 . COLLINS, A. & LOFTUS, E. (1975) A Spreading A c t i v a t i o n Theory of Semantic P r o c e s s i n g , P s y c h o l o g i c a l Review, v o l 8 2 , #5. COLLINS, A. & QUILLIAN, M.R. (1972) How to Make a Language User, i n O r g a n i z a t i o n of Memory. E . T u l v i n g S W.Donaldson (eds.)... Academic P r e s s , New York. DAHL, 0 . & NYGAARD, K. (1976) SIMDLA-An Algol-based S i m u l a t i o n Language, CACM, v o l 9 , Sept. 1 9 7 6 . 154 DAVIES, D. J . (1973) Pcpler-1.5 Reference Manual, TPU Report#1, School of A r t i f i c i a l I n t e l l i g e n c e , Dniv. Of Edinburgh, Edinburgh, S c o t l a n d . EARLEY, J. (1970) An E f f i c i e n t Context-Free P a r s i n g Algorithm, CACM, v o l 13, #2, Feb 1970, pp.94-102. FAHLMAN, S.E. {1975) T h e s i s Progress Report; A System f o r Representing and Using Real-World Knowledge, AIM-331, A.I. Lab, MIT, Cambridge, Mass. FEIGENBAUM, E.A. (1963) The Simulation of Verbal Learning Behavior, i n Computers and Thought, Feigenbaum, E.A. S Feldman, J . (eds . ) , McGraw-Hill, New York, p.297. FILLMORE, C. (1968) The Case f o r Case, i n E.Bach 6 R . I . H a r r i s (eds.), U n i v e r s a l s i n L i n g u i s t i c Theory, H o l t , Rhinehart S Winston, New York. FREUDER, E.C. (1976) A Computer System f o r V i s u a l R e c o g n i t i o n using A c t i v e Knowledge, Ph.D. T h e s i s , AI-TR-345, MIT AI Laboratory, Cambridge, Mass. GELERNTEH, H. (1963) R e a l i z a t i o n of a Geometry Theorem-Ercving Machine, i n E. A. Feigenbaum & J,Feldman (e d s . ) . Computers and Thought, McGraw-Hill, New York. GREEN, C. (1969) A p p l i c a t i o n o f Theorem-Proving to Problem S o l v i n g , Proc. IJCAI1, Washington, D.C, May 1969. GUZMAN, A. : (1968) Computer R e c o g n i t i o n of Three-Dimensional Objects i n a V i s u a l Scene, MAC-TR-59, P r o j e c t MAC, MIT, Cambridge, Mass. HAVENS, W. S. (1976) Can Frames Solve the Chicken and Egg Problem?, Proc. F i r s t CSCSI/SCEIO Nat. Conf., UBC, Vancouver, Canada, August 1976. HAYES, P. J . (1973) Computation and Deduction, Proc. 1973 MFCS Conf., C z e c h o s l c v a k i a n Academy of Sciences. HENDRIX, G. (1975) Expanding t h e U t i l i t y o f Semantic Networks through P a r t i t i o n i n g , Proc. IJCAI4, T b i l i s i , Georgia, USSR, Sept. 1975, pp. 115-121. HEWITT, C. (1972) D e s c r i p t i o n and T h e o r e t i c a l A n a l y s i s (using Schemata) of PLANNER: A Language for Proving Theorems and Manipulating Models i n a Robot, Ph.D. T h e s i s , A.I. Lab, MIT, Cambridge, Mass, 155 HEWITT, C , BISHOP, P., Z ST EI G EH, R. (1973) A U n i v e r s a l Modular ACTOR Formalism f o r A r t i f i c i a l I n t e l l i g e n c e , IJCAI3, S t a n f o r d Univ., S t a n f o r d , C a l i f . , August 1973. HUFFMAN, D. A. .. (1971) Impossible Objects as Nonsense Sentences, i n Machine I n t e l l i g e n c e 6, B.Meltzer S D,Michie ( e d s . ) , Edinburgh Univ. P r e s s , Edinburgh, S c o t l a n d . JAYNES, J. (1976) The O r i g i n of Consciousness i n the Breakdown c f the Bicameral Mind, H o u g h t o n - M i f f l i n , Eoston. KAFIAN, R. (1973) A General S y n t a c t i c Processor, i n R.Rustin (ed.), N a t u r a l Language P r o c e s s i n g , A l g o r i t h m i c Press, New York. KOWALSKI, R. A. (1974) P r e d i c a t e L o g i c as a Programming Language, Proc. IFIP74, North-Holland, pp.569-574. KUIPEBS, B.J. (1975) A Frame f o r Frames: Representing Knowledge f o r R e c o g n i t i o n , i n Representation and Understanding, D.G.Bobrow & A . C o l l i n s (eds.), Academic Press, New York. MACKWORTH, A.K. (1975) Consistency i n Networks of R e l a t i o n s , TR-75-3, Comp. Science Dept., Univ.of B r i t i s h Columbia, Vancouver, Canada, a l s o Art i f i c i a l I n t e l l i g e n c e , v o l 8, #1, pp.99-118. MACKWORTH, A.K. (1976) Model Driven I n t e r p r e t a t i o n i n I n t e l l i g e n t V i s i o n Systems, P e r c e p t i o n , v o l 5, pp.349-370. MACKWORTH, A.K. (1977a) On Reading Sketch Maps, TR-77-2, Dept.of Computer S c i e n c e , U n i v . o f B r i t i s h Columbia, Vancouver, Canada, a l s o Proc. IJCAI-77, MIT, Cambridge, Mass., August 1977, p.598. MACKWORTH, A.K. .(1977b) How to See a Simple World, i n Machine I n t e l l i g e n c e 8, E.W.Elcock S D .Michie ( e d s . ) , Halsted Press, New York. MACKWORTH, A.K. (1977c) V i s i o n Research S t r a t e g y : Black Maqic, Metaphors, Mechanisms, MiniworIds, and Maps, Proc. Workshop cn Comp. V i s i o n Systems, June 1977, U. Mass, Amherst, Mass. McCALLA, G. (1977) An Approach to t h e O r g a n i z a t i o n of Knowledge f o r the Mo d e l l i n g of Co n v e r s a t i o n , Ph.D. T h e s i s , Comp. Science Dept., Univ.of B r i t i s h Columbia, Vancouver, Canada. 156 MCCARTHY, J . S HAYES, P. {1969) Some P h i l o s o p h i c a l Problems from the Standpoint o f A r t i f i c i a l I n t e l l i g e n c e , i n Machine I n t e l l i g e n c e ft, B.Meltzer 6 D.Michie (ed s . ) , Edinburgh U n i v e r s i t y P r e s s , Edinburgh, S c o t l a n d . McDERMOTT, D.V. & SUSSMAN, G. (1973) Son o f CONNIVER: The CONNIVER Reference Manual, MIT AI Lab, Cambridge, Mass. McDERMOTT, D. V. {1975) Very Large P l a n n e r - L i k e Databases, MIT AI Lab, Memo 339, Cambridge, Mass., Sept. 1975. MINKER, J . & VANDENBRUG, G.J. (1973) The B a r l e y Algorithm as a Problem R e p r e s e n t a t i o n , Tech. Report TR-247, Comp. Science Center, Univ.of Maryland, C o l l e g e Park, Maryland. MINSKY, M. (1975) A Framework f o r R e p r e s e n t i r g Knowledge, i n The Psychology cf Computer V i s i o n . P.Winston (ed.), McGraw-hill, New York. NEISSER, U. (1976) C o g n i t i o n and Reality., W. H. Freeman S co., San F r a n c i s c o . NEWELL, A. & SIMON, H. (1963) GPS: A Program t h a t Simulates Human Thought, i n Computers and Thought. E.A.Feigenbaum S J.Feldman (eds.), McGraw-Hill, New York, p.279. NEWELL, A. S SIMON, H. (1972) Human Problem S o l v i n g . P r e n t i c e - H a l l , E n g l e w o o d - C l i f f s , New J e r s e y . NILSSON, N. (1971) Problem SojLving Methods i n A r t i f i c i a l l£tellicence, McGraw-Hill, New York. NORMAN, D.A., RUMELHART, D.E., e t . a l . (1975) E x p l o r a t i o n s i n C o g n i t i o n , W.H.Freeman & Co., San F r a n c i s c o , PYIYSHYN, Z. W. (1973) What the Mind's Eye T e l l s the Mind's B r a i n : a C r i t i q u e of Mental Imagery, P s v c p i o g i c a 1 B u l l e t i n . 1973, #80, pp. 1-24. PYIYSHYN, Z. W. (1976) Imagery and A r t i f i c i a l I n t e l l i g e n c e , i n W.Savage (ed.), Minnesota S t u d i e s i n the Philosophy of Science, v o l IX, U n i v e r s i t y o f Minnesota Press, Minneapolis., QUILLIAN, M.R. (1968) Semantic Memory, i n Semantic In f o r m a t i o n P r o c e s s i n g , M.Minsky (ed.), MIT P r e s s , Cambridge, Mass., p.227. RAPOPOBT, A. (1963) T e c h n o l o g i c a l Models o f the Nervous System, i n K.fi.Sayre & F.J.Crosson ( e d s . ) . The Mode l l i n g of J i n d , Simon & Schust e r , New York, p.25. 157 REBCH, E. & SACERDOTI, E. (1973) A P r e l i m i n a r y QLISP Manual, S t a n f o r d Research I n s t i t u t e AI Lab, Tech Note #81, august 1973. REITER, R. (1973) S e m a n t i c a l l y Guided Deductive System f o r automatic Theorem P r o v i n g , Proc. IJCai3 , Stanford Univ., S t a n f o r d , C a l i f . , Aug. 1973, p.41. RIEGER, C. (1974) Conceptual Memory: A Theory and Computer Program f o r P r o c e s s i n g the Meaning Content of Na t u r a l Language U t t e r a n c e s , Ph.D. T h e s i s , AIM-233, S t a n f o r d Univ., S t a n f o r d , C a l f . ROBERTS, L.G. (1965) Machine P e r c e p t i o n of Three-Dimensicnal Objects, i n O p t i c a l and E l e c t r o - O p t i c a l I n formation 2lP££Ssinc[, J.T.Tippet e t . a l . (eds.) , MIT Pre s s , Cambridge, Mass.,~pp.159-197. ROBINSON, J.A. (1965) a Machine-Oriented L o g i c Based on the Re s o l u t i o n P r i n c i p l e , JACM, v o l 12, #1, pp.23-41. RUMELHART, D. & NORMAN, D. (1973) A c t i v e Semantic Networks as a Model of Human Memory, Proc. IJCAI3, Stanford Univ., S t a n f o r d , C a l i f . , Aug. 1973, p.450. RUMELHART, D.E. & ORTONY, A. (1976) The Representation of Knowledge i n Memory, Tech. Report #55, Center f o r Human Inf o . P r o c e s s i n g , Dept.of Psychology, Univ.of C a l i f . At San Diego, La J o l l a , C a l i f . SAMUEL, A. L. (1963) Some St u d i e s i n Machine L e a r n i n g Using the Game of Checkers, i n E.A.Eeigenbaum & J,Feldman (eds.). Computers and Thought. McGraw-Hill, New York. SCHANK, R. (1975) Using Knowledge t o Understand, Proc. T h e o r e t i c a l Issues i n N a t u r a l Language P r o c e s s i n g , MIT, Cambridge, Mass., June 1975, p. 131. SCHANK, R. & ABELSON, R. (1975) S c r i p t s , Plans and Knowledge, Proc. IJCAI4, T b i l i s i , Georgia, USSR, Sept. 1975, pp. 151-157. SCHUBERT, L. (1975) Extending the Expressive Power of Semantic Networks, Proc. IJCAI4, T b i l i s i , Georgia, USSR, Sept. 1975, p.158. SLAGLE, J . R. (1971) a r t i f i c i a l I n t e l l i g e n c e : The H e u r i s t i c Programming Approach, Mc-Graw-Hill, New York. 158 STALLMAN, R. M. 5 SUSSHAN, G. J . (1977) Forward Reasoning and Dependency-Directed Backtracking i n a System f o r Computer-Aided C i r c u i t A n a l y s i s , A r t i f i c i a l I n t e l l i g e n c e , v o l 9, #2, Oct. 1977, p.135. SUSSHAN, G. S KcDERMOTT, D. (1972) Shy Conniving i s Bet t e r than P l a n n i n g , AIM-255A, A.I. Lab, MIT, Cambridge, Mass. SDSSMAN, G.J., WINOGRAD, T., S CHARNIAK, E. (1973) MICRO-PLANNER Reference Manual, AI Lab memo #203A, MIT, Cambridge, Mass. TEITELMAN, W. (1974) INTERLISP Reference Manual, Xerox Palo A l t o Research Center, P a l o A l t o , C a l f . Van EMDEN, H. .H. .(1977) Programming with R e s o l u t i o n L o g i c , i n Machine I n t e l l i g e n c e 8, E.W.Elcock 8 D. Michie ( e d s . ) , Halsted Press, New York, pp.266-299. WALTZ, D. L. (1972) Generating Semantic D e s c r i p t i o n s from Drawings of Scenes with Shadows, Ph.D. T h e s i s , AI-TR-271, MIT, Cambridge, Mass. WINOGRAD, T. (1973a) U n der s t an ding N a t u r a l Lanquaqe. Academic Press, New York. WINOGRAD, T. (1973b) Breakinq the Complexity B a r r i e r (Aqain), Proc. ACM SIGIR-SIGPLAN I n t e r f a c e Meetinq, Nov. 1973. WINOGRAD, T. (1975) Frame Representations and the P r o c e d u r a l - D e c l a r a t i v e Contraversy, i n Re p r e s e n t a t i o n and finderstanding, D.G.Bobrow 8 A . C o l l i n s ( e d s . ) . Academic P r e s s , New York, pp.185-210. . WINSTON, P. fi. (1975) -Learning S t r u c t u r a l D e s c r i p t i o n s from Examples, i n The Psychology of Computer V i s i o n , P.H.Winston (ed.), McGraw-Hill, New York. WINSTON, P. H. (1977) A r t i f i c i a l I n t e l l i g e n c e , Addison-Wesley, Beadinq, Mass. WOODS, w.A. (1970) T r a n s i t i o n Network Grammars f o r Natural Lanquaqe A n a l y s i s , CACM, v o l 13, #10, pp.591-606. WOODS, W.A. (1974) p e c u r s i v e T r a n s i t i o n Networks and the Earl e y R e c o q n i t i o n Alqorithm, unpublished workinq paper. B o l t , Beranek, S Newman, Cambridqe, Mass. WOODS, W.A. (1975) Whats i n a Link, i n Represent ation and Understanding, D.G.Bobrow 5 A . C o l l i n s (eds.), Academic Pre s s , New York, pp.35-82. YOII.LE, J . C. (1977) The Role of Imagery i n Models C o g n i t i o n , J o u r n a l of Mental Imagery, 1977, #1. 160 AFP EN DIX A EAgLEYlS FAJSING ILGOBITHJ The f o l l o w i n g p r e s e n t a t i o n of E a r l e y ' s a l g o r i t h m i s intended to supplement the i n f o r m a l d i s c u s s i o n of Chapter 3. A s t i l l more formal treatment i s provided by Aho and Oilman (1972). l e are given a c o n t e x t - f r e e grammar, G=(P,N,K,S), where P i s a set of production r u l e s , N i s the s e t of non-terminal symbols, K i s the s e t o f t e r m i n a l symbols, and S i s the s t a r t symbol which i s a d i s t i n g u i s h e d symbol i n N. The a l g o r i t h m operates on an i n p u t sentence, w=a(1)a(2) . . . a (n) and determines whether w i s contained i n 1(G), the language generated by G. Upper case l e t t e r s are used to represent: non-terminal symbols, the lower case l e t t e r s , " i " , " j " , "k", and "n" r e p r e s e n t i n d i c e s , and a ( i ) i s used to represent the i ' t h symbol i n the input sentence. Other lower case l e t t e r s r e p r e s e n t s e n t e n t i a l forms composed of both t e r m i n a l and non-terminal symbols. . • f o r 0<j<n, the a l g o r i t h m c o n s t r u c t s parse l i s t s of items. An item, [A->m.q,i] 0<i<j, i s an element of the parse l i s t I ( j ) i f and only i f a s e n t e n t i a l form, rAu, with r=a(1)a{2) . . . a ( i ) can be derived from S and a ( i * 1 ) . . . a{j) can be d e r i v e d from m. That i s , i through j Appendix-A: E a r l e y ' s P a r s i n g Algorithm 161 bracket the p o r t i o n of w d e r i v a b l e from m, and the production r u l e , A->mq, can be used i n the generation of w up to p o s i t i o n j . A l l items i n a parse l i s t , I { j ) , r e p r e s e n t d e r i v a t i o n s which agree with w up to p o s i t i o n j . The items i n a given parse l i s t , I ( j ) , can be viewed as independent p a r s e r s , each attempting to recog n i z e an i n s t a n c e of i t s own production r u l e from the input sentence. The a l g o r i t h m i s i n i t i a l i z e d by forming a parse l i s t 1(0) c o n t a i n i n g the s i n g l e seed item fS->.w,0]. As each new i n p u t symbol a (j + 1) of w i s read, the al g o r i t h m generates a new parse l i s t I (j + 1) from 1(0) . . I (j) . T h i s process c o n t i n u e s u n t i l the l a s t symbol a(n) i n w i s read and I (n) generated, or u n t i l no new parse l i s t can be generated, i n d i c a t i n g w i s not contained i n the language of G. I f , at the end of t h i s process, an item, [S->m.,0], i s contained i n I ( n ) , then w i s i n L(G). The a l g o r i t h m proceeds by the c y c l i c a p p l i c a t i o n of three f u n c t i o n s , c a l l e d the p r e d i c t o r , the scanner, and the completer, u n t i l the l a s t symbol i s read from w or u n t i l some I ( j ) i s found to be empty. F i r s t , the p r e d i c t o r computes from the r u l e s of G and the d e r i v a t i o n found to date what d e r i v a t i o n s may p o s s i b l y f o l l o w . I t spawns new p a r s e r s t o look f o r these d e r i v a t i o n s . I f fA->m.Bq,i] i s an element o f parse l i s t I ( j ) , and B-»r i s a r u l e i n P, then [ B - > . r , j ] i s added to I ( j ) . The index, j , i n the item i n d i c a t e s at what p o s i t i o n , j , i n the parse a new pa r s e r was cre a t e d to l o c k f o r the r i g h t - h a n d - s i d e of the r u l e , B->r. See F i g u r e A.I. Appendix-A: E a r l e y ^ P a r s i n g Algorithm 162 m • r a-; F i g u r e A.1: The P r e d i c t o r Function F i g u r e A.2: The Scanner Function • A • A _ a i ai+l an F i g u r e A,3: The Completer Function Appendix-A: E a r l e y ' s P a r s i n g Algorithm 163 Next, the scanner f u n c t i o n , by r e a d i n g the next symbol. M l * - ' ) * from w generates a seed item f o r the next parse l i s t , I<J + '')« F o r each [B->m.ag,i] t h a t i s contained i n I (j) and w=a(1) . . a ( j ) a . . a (n) then fB->ma.g,i] i s added t o I (j+1). The scanner propagates a l l p a r s e r s i n to the next parse l i s t t h a t were expecting a (j+1) t o appear next i n the input sentence. As i s i l l u s t r a t e d i n F i g u r e A.2, the scanner increments the i n t e r n a l s t a t e of an item by moving the parsing dot cne t e r m i n a l symbol to the r i g h t . The completer f u n c t i o n performs bottom-up r e d u c t i o n s of s e n t e n t i a l forms that appear as r i g h t - h a n d - s i d e s of production r u l e s i n P to t h e i r non-terminal l e f t - h a n d - s i d e s . I f f A - ^ r , , i l i s an element of I ( j ) , then the non-terminal symbol. A, has been re c o g n i z e d i n w. From I ( i ) , the g e n e r a t i n g item, [B->m.Ag,k] i s found and [B->mA.g,k] i s added to I ( j+ 1) . The completer a c t s as a scanner f o r non-terminal symbols, as i s shown i n F i g u r e A.3. Appendix-A: E a r l e y ' s P a r s i n g Algorithm 1 6 4 APPENDIX B MAYA LANGUAGE REJERENCE MANUAL Th i s manual i s a d e s c r i p t i o n of an A r t i f i c i a l I n t e l l i g e n c e programming language c a l l e d MAYA. Included i n t h i s language are f a c i l i t i e s f o r performing p a t t e r n matching, p r i m i t i v e s f o r c o n s t r u c t i n g semantic networks and schemata, p r i m i t i v e s f o r c r e a t i n g and manipulating processes, and c o n t r o l s t r u c t u r e s f o r i n t e g r a t i n g top-down and bottom-up search techniques. The language i s designed as a d i a l e c t of LISP having a number of exten s i o n s and a few r e s t r i c t i o n s . , The extensions w i l l be de s c r i b e d i n d e t a i l i n the f o l l o w i n g pages and the r e s t r i c t i o n s w i l l be noted as w e l l . B.1 R e l a t i n g to MAYA This s e c t i o n e x p l a i n s the o p e r a t i o n of the i n t e r p r e t e r . Since t h i s language i s experi m e n t a l , i t i s s u b j e c t t o o c c a s i o n a l changes i n behaviour. Most changes w i l l be upwardly compatible and t h i s document w i l l be promptly e d i t e d to r e f l e c t those changes. To run MAYA under MTS: $RUN CSrLISP SCARDS=CS:LGADER+*SOORCE* {RESTORE MAYA:SYSGEN) MAYA w i l l be s t a r t e d i n a t o p - l e v e l EAR and the c r e a t i o n date f o r the c u r r e n t v e r s i o n o f the i n t e r p r e t e r w i l l be p r i n t e d . The f o l l o w i n g l i s t of f u n c t i o n s are the b a s i c mechanisms f o r c o n t r o l l i n g the i n t e r p r e t e r . The form o f each f u n c t i o n c a l l i s given f o l l o w e d by the type of the f u n c t i o n . EXPR, NEXPB, and FEXPR type f u n c t i o n s can be used from both MAYA and LISP. Sguare brack e t s i n d i c a t e o p t i o n a l arguments, and the a s t e r i s k i s used as the Kleene s t a r i n d i c a t i n g -zero or more r e p e t i t i o n s . MAYA Language Reference 165 1. (MAYA) {EXPB} Executed from LISP. I n i t i a l i z e s the processor and e n t e r s a a t o p - l e v e l EAR. 2. (HALT [<fora>]) {SFSUBB} The value of <form> i s returned t o LISP. I f no argument i s s u p p l i e d , NIL i s r e t u r n e d . HALT l e a v e s the c u r r e n t i n v o c a t i o n o f the proce s s o r i n t a c t . 3. (RESTART <form>) (NEXPB} Executed from LISP. R e s t a r t s the i n t e r p r e t e r from the previous HALT. Computation proceeds with <form> s u b s t i t u t e d f o r the c a l l to HALT. RESTART and HALT can be used as a c o - r o u t i n e mechanism between HAYA and LISP. HALT r e t u r n s a value to LISP at the p o i n t the i n t e r p r e t e r was c a l l e d , l e a v i n g the process i n t a c t . RESTART r e t u r n s a value t o MAYA at the point that the process was p r e v i o u s l y h a l t e d . 4. (SINIT) {EXPB} R e i n i t i a l i z e s the p r o c e s s o r . Meaningful o n l y from LISP. I f e valuated from MAYA, a warning i s given and NIL i s ret u r n e d . 5. (EAR) {SSOBR} Ent e r s a READ-EVAL-PRINT l o o p . Since MAYA permits m u l t i p l e c o - e x i s t a n t processes, t h i s f u n c t i o n permits the user t o c r e a t e m u l t i p l e READ-EVAL-PRINT loop s . Reads forms from each < f i l e > . Each form i s MAYA EVALed. 6. (INPILE <file>*) ( a S O E R } T h i s f u n c t i o n i s analogous to DISKIN i n LISP. There i s however no DISROOT analogue because MAYA f u n c t i o n d e f i n i t i o n s may be l o c a l t o o b j e c t s i n the data base. Since MAYA makes use of both read and p r i n t macro c h a r a c t e r s , i t i s unwise f o r the user t o p r e f i x h i s own atoms with these c h a r a c t e r s . The c h a r a c t e r s r e s e r v e d by MAYA ar€: «?", »!", and "S". The "3" i s not a c t u a l l y a macro c h a r a c t e r but a l l MAYA i n t e r n a l names begin with t h i s c h a r a c t e r . I f i t i s i n c o n v e n i e n t tc abide MAYA language Reference 166 by these conventions, then the f o l l o w i n g two f u n c t i o n s nay be used. 7. (30FF-STAT0S) {EXPB} Turns o f f read macro p r o c e s s i n g . 8. (3ON-STAT0S) {EXPB} Turns on read macro p r o c e s s i n g . To f a c i l i t a t e communication between LISP and MAYA, two p r e f i x e s are provided. From LISP, «:<form> w i l l r e t u r n the MAYA value of <form>. From MAYA, $<form> w i l l r e t u r n the LISP value of <form>. For example, from LISP, t$t$t$t$\t$ (FOO) w i l l r e t u r n the LISP value of (FOO). Note t h a t (MAYA) i s (SINIT) f o l l o w e d by ^ (EAE). B.2 The Database Many of the p r i m i t i v e f u n c t i o n s d e f i n e d i n MAYA are concerned with c r e a t i n g o b j e c t s , forming semantic networks from o b j e c t s , s e a r c h i n g a r c paths through these networks, and i n t e r p r e t i n g o b j e c t s as schemata. These f u n c t i o n s c r e a t e and manipulate o b j e c t s and the schemata and nodes t h a t can be cr e a t e d from o b j e c t s . 9. (OBJECT <type><pair>*) {3FSUBR S FEZPB) Each <pair> i s of the form, <nameXform>. OBJECT c r e a t e s a new o b j e c t of the user type, <type>, having f o r each <pair> a b i n d i n g d e f i n e d between the name, <name>, and i t s d e f i n i t i o n , <form>. OBJECT ev a l u a t e s i t s odd arguments, and i t s even arguments must be <ATOM>s. Note t h a t both a MAYA and LISP v e r s i o n o f t h i s f u n c t i o n are i n c l u d e d i n the system. Example: (OBJECT 'NODE CLASS 'TABLE HAS-AS-PARTS (LIST 'LEGS «TOP)) ! (30BJECT9 NODE CLASS TABLE HAS-AS-PARTS (LEGS TOP) ) 10. (NEW <object> <pair>*) J8FS0EB S FEXPR} I f <object> i s not an o b j e c t , an e r r o r occurs. NEW c r e a t e s a new i n s t a n c e o f <object> of type, SINSTARCES. MAYA Language Reference 167 The new o b j e c t c o n s i s t s of the b i n d i n g s of <rair>s concatenated with <object>. The new i n s t a n c e i s cf the form: (S0BJECT3 3INSTANCE3 <pair>*) II <object>, where f J i n d i c a t e s l i s t c o n c a t e n a t i o n . Note t h a t both a MAYA and LISP v e r s i o n of t h i s f u n c t i o n are i n c l u d e d . Example: (POT* 'DOG (OBJECT 'GENERIC NAME 'DOG CLASS 'MAMMALIA)) « (30BJECT3 GENERIC NAME BOG CLASS MAMMALIA) _ (NEW DOG NAME •FLOYD OWNEB 'BILL) ! (30BJECT3 ^INSTANCES NAME FLOYD OHNEB BILL 30BJECTS ! GENERIC NAME DOG CLASS MAMMALIA) 11. (OBJECTP <thing>) {EXPB} I f <thing> i s an o b j e c t , i t s type i s re t u r n e d . Else NIL i s r e t u r n e d . 12. . (STEREO <object>) { 2 S 0 E R} I f <object> i s an i n s t a n c e , i t s st e r e o t y p e o b j e c t i s returned. I f <cbject> i s o b j e c t but not an i n s t a n c e of some other o b j e c t , <object> i t s e l f i s returned.. E l s e NIL i s returned. 13. (GET* <name> [<else>]) {8SUER E EXPB} Fetches the d e f i n i t i o n o f <name> from w i t h i n the e n c l o s i n g o b j e c t . Both a MAYA and a LISP v e r s i o n are provided. I f th e r e i s no <name> d e f i n e d i n t h e e n c l o s i n g o b j e c t , <else> i s e v a l u a t e d . I f <else> i s not gi v e n , NIL i s retu r n e d . I f t h e r e i s no e n c l o s i n g o b j e c t on the s t a c k , the g l o b a l o b j e c t i s taken to be the e n c l o s i n g o b j e c t . Examples: (GET* 'CONS) ! (30BJECT3 3PLIST3 SO BR *) (GET* * DFDFDGGGG "ELSE) ! NIL _ ;NOTE: GLOBAL OBJECT HAS EVERY NAME DEFINED. Z (SEND (OBJECT 'TYPE A • ADEF) (GET* »A)) T ADEF (SEND (OBJECT 'TYPE A 'ADEF) (GET* 'B " E L S E ) ) I ELSE MAYA Language Reference 168 14. (PUT* <name><form>) {EXPB} Puts w i t h i n the e n c l o s i n g o b j e c t the b i n d i n g of <name> to i t s new d e f i n i t i o n , <form>. <Name> must be atomic. I f a pre v i o u s d e f i n i t i o n e x i s t e d , i t i s re p l a c e d . I f no e n c l o s i n g o b j e c t e x i s t s on the st a c k , the b i n d i n g i s added to the g l o b a l o b j e c t , i . e . , the CDS of <rarae> i s s e t to <form>. I f the e n c l o s i n g o b j e c t i s an i n s t a n c e of some parent s t e r o t y p e o b j e c t , the stereotype o b j e c t i s guaranteed to remain u n a l t e r e d . PUT* r e t u r n s <form>. Examples: (PUT* • A * ADEF) ADEF A ADEF (CDE ' A) ADEF (: (PUT* •B (OBJECT * N O D E ) ) (PUT* «C »CDEF) (SELF) ) ! (iOBJECTS NODE C »CDEF) 8 7 (aoBjECTa N O D E C « C D E F ) 15. (BEH* <name>) (3SUBR) Removes the d e f i n i t i o n c f <name> from the e n c l o s i n g o b j e c t . I f t h e r e i s no e n c l o s i n g o b j e c t on the st a c k , the CDR of the atom, <name>, i s set to NIL. I f the e n c l o s i n g o b j e c t i s an i n s t a n c e , i t s s t e r e o t y p e o b j e c t remains u n a l t e r e d . REM r e t u r n s the bin d i n g of <name>. I f the bi n d i n g o f <name> i s not d e f i n e d i n t h i s o b j e c t or within t h i s i n s t a n c e , NIL i s r e t u r n e d . Examples: B T (©OBJECTS NODE C * CDEF) (SEND B (REM* »C) ) 7 NIL B ! {^OBJECTS NODE) (REM* »B) ! NIL B ! NIL MAYA Language Reference 169 1 6 . {SELF) {SSOBB} Returns the c u r r e n t e n c l o s i n g object from the stack. I f t h e r e i s no e n c l o s i n g o b j e c t , an e r r o r occurs. Examples; <:• {OBJECT * TYPE A • ADEF) (PUT* *A *NE0-ADEF) ~_ (SELF) ) ! (30BJECT3) TYPE A NEW-ADEF) (SELF) = EBEOR: NO ENCLOSING OBJECT ON THE STACK 17 . (ITEM <pair>*) {3S0BR} Each p a i r i s o f the form, <name><value>. ITEM c r e a t e s a new item c o n t a i n i n g a new i n s t a n c e s of each v a r i a b l e , <name>, having v a l u e , <value>. ITEM e v a l u a t e s i t s even arguments, and i t s even arguments must be atoms. The new item i s r e t u r n e d as value. Example: (ITEM X »XVAL Y ! (3ITEMS NIL X (SETQ X »XVAL) ! X7AL (: (ITEM X »ZZZ I (PRINT ?Y) ?X) ! X7AL ! ZZZ (LIST * Y YY) ) XVAL Y (YYY) ) Y ?X) 18 . (SET <pair>*) fSSOBR} Each <pair> i s of the form, <nameXvalue>. SET binds each v a r i a b l e name, <name>, t o i t s new v a l u e , <value>. SET e v a l u a t e s a l l i t s arguments and i t s odd arguments must ev a l u a t e t o atoms. SET r e t u r n s the value of the l a s t <pair>. 19 . (SETQ <pair>*) {SFSUER} Each <pair> i s o f the form, <name><value>. SETQ behaves as SET except i t e v a l u a t e s o n l y i t s even arguments. Both SET and SETQ search the stack l o o k i n g f o r the f i r s t MAYA Language Reference 170 occurrence of the v a r i a b l e , <name>. I f no v a r i a b l e e x i s t s on the stack having name, <name>, the LISP value of the atcm, <name>, i s changed t o <value>. Note t h a t o n l y the v a r i a b l e , <name>, i s changed and not the d e f i n i t i o n c f the atcm, <name>. SET and SETQ bind v a l u e s whereas POT* binds d e f i n i t i o n s . 20. (DEFUN <defn>) fFEXPR} DEFUN has been extended t o permit the d e f i n i t i o n of 3EXPR, 3NEXPR, 3FEXPR, and QEXPR type f u n c t i o n s . DEFUN may be used from e i t h e r HAY A or LISP to d e f i n e any of the f u n c t i o n types from both languages. DEFUN always adds i t s d e f i n i t i o n , <defn>, to the e n c l o s i n g o b j e c t and may t h e r e f o r e be used t o provide f u n c t i o n d e f i n i t i o n s l o c a l to s p e c f i c o b j e c t s . DEFUN honors i n s t a n c e boundaries. Examples: (DEFUN TEST NIL (PRINT 'OUTSIDE) T) 7 TEST (SEND (OBJECT * CONTEXT) (DEFUN TEST NIL (PRINT 'INSIDE) NIL) (TEST)) T INSIDE ! NIL (TEST) ! OUTSIDE ! T 21. (S P1 P2 . . . Pn) fSFSUBB S FEXPR} The t u p l e e v a l u a t o r . The value of a t u p l e i s a new t u p l e of the values o f i t s elements, P1, P2, . . . Pn. The t u p l e e v a l u a t o r uses i n v e r s e gupte mode during e v a l u a t i o n . Atoms and matcher v a r i a b l e s are t r e a t e d as consta n t s , i . e . , they e v a l u a t e to themselves. A l l other forms are EVALed, note t h a t (3 P1 P2 . . . Pn) can be abb r e v i a t e d using angle b r a c k e t s as <P1 P2 . . . Pn>. Both a HA YA and a LISP v e r s i o n are i n c l u d e d . Note a l s o t h a t angle b r a c k e t s cannot be used as LISP super-parentheses. Examples: <A B C> T <A B C> _ <*A (LIST 'B »C)> ! <A (B C) > _ (SETQ Y 'YVAL) T YVAL <A <B !:X> ?Y> HAYA Language Reference 171 i <A <B !:X> YVAL> 22. (TUPLEP <thing>) {EXPB} Returns T i f <thing> i s a t u p l e , e l s e r e t u r n s N i l . 23. (VABP <thing>) {EXPB} Returns the name of <thing> i f i t i s a MAYA v a r i a b l e , e l s e n i l . P a t t e r n v a r i a b l e s r e t u r n NIL. Returns T i f <thing> i s an item, e l s e NIL. E.3 E v a l u a t i o n The f o l l o w i n g paragraphs d e s c r i b e the f u n c t i o n types i n c l u d e d i n MAYA. V a l i d LISP f u n c t i o n s are accept a b l e and are executed d i r e c t l y by LISP f o r MAYA. In a d d i t i o n to LISP'S f u n c t i o n types, the i n t e r p r e t e r a l s o r e c o g n i z e s the f o l l o w i n g t y p e s : I f d e s i r e d , the i n t e r p r e t e r may be extended t o i n c l u d e ether f u n c t i o n types as w e l l . Please see me f o r d e t a i l s . iSUBR's and SFSOBR's are the system s u p p l i e d f u n c t i o n s of MAYA. SSOBRs e v a l u a t e t h e i r arguments but aFSOBRs bin d the l i s t of unevaluated arguments to t h e i r s i n g l e parameter, as expected. SEXPR, 3NEXPR, and SFEXPR are MAYA's user d e f i n e d f u n c t i o n types t h a t are analogous to t h e i r LISP c o u n t e r p a r t s . QEXPB type f u n c t i o n s are somewhat analogous to the Q-type f u n c t i o n s of QLISP tReboh, 1973). QEXPRs are implemented v i a QLAMBDA ex p r e s s i o n s and take a s i n g l e t u p l e as argument. They r e t u r n as value an item r e p r e s e n t i n g the r e s u l t of a p a t t e r n match between the t u p l e argument and the t u p l e p a t t e r n of the QLAMBDA exp r e s s i o n . P l e a s e see the s e c t i o n s on p a t t e r n matching, Generators, and Recognizers. , The i n t e r p r e t e r uses the f o l l o w i n g a l g o r i t h m when a p p l y i n g a f u n c t i o n t o i t s arguments: • I f the f u n c t i o n i s an 3SUBB or an 3EXPB, i t s arguments are ev a l u a t e d and the f u n c t i o n i s a p p l i e d t o 21. (ITEMP <thing>) {EXPR} SSBBR, 3FSUBR, a EXPR, 3NEXPR, 3FEXPR, and QEXPR. MAY A language Reference 172 t h e i r v a l u e s . * I f the f u n c t i o n i s an SFSOBR or an SFEXPR, then the f u n c t i o n i s a p p l i e d to the l i s t of unevaluated arguments. •» I f the f u n c t i o n i s an 3NEXPR, i t i s a p p l i e d t o the unevaluated arguments. * I f the f u n c t i o n i s a QEXPR, the t u p l e argument i s eva l u a t e d and t h e p a t t e r n matcher c a l l e d on the value. I f the match succeeds, the f u n c t i o n i s a p p l i e d t o the r e s u l t . * E l s e the f u n c t i o n i s a LISP form. I f i t i s a SUES or EXPR, the arguments are evaluated and the f u n c t i o n i s LISP APPLYed t o the r e s u l t . I f the f u n c t i o n i s an N EX PR, FEXPR, NSDBR, or FSUER, then the form i s LISP EVALed. Functions which make no use of the p a r a l l e l i s m , c o n t r o l s t r u c t u r e s , or data s t r u c t u r e s of HAYA can be w r i t t e n i n LISP and executed from MAYA thereby g a i n i n g a c o n s i d e r a b l e i n c r e a s e i n e f f i c i e n c y . While i n LISP, any forms d e f i n e d w i t h i n MAYA can be evaluated v i a the nHn p r e f i x and r e f e r e n c e s t o MAYA v a r i a b l e s can fee fetched v i a the n ? " p r e f i x . 25. (AVAL <form>) (3SUBR) MAYA e v a l u a t e s i t s argument, <form>. I f <form> i s a l i s t whose CAR i s an atom, AVAL f e t c h e s the MAYA f u n c t i o n from the f i r s t d e f i n i t i o n o f the atom on the st a c k . I f there i s no f u n c t i o n d e f i n i t i o n w i t h i n the f i r s t occurrence of the atom on the s t a c k , an e r r o r o c c u r s . 26. (EVAL <form>) {SSUER} MAYA e v a l u a t e s i t s argument, <form>. I f <form> i s a l i s t whose CAR i s an atom, EVAL f e t c h e s the f u n c t i o n d e f i n i t i o n from w i t h i n the g l o b a l o b j e c t . That i s , EVAL f e t c h e s f u n c t i o n d e f i n i t i o n from the PLIST of the atom. EVAL i s t h e r e f o r e f a s t e r than AVAL, but does not r e c c g n i z e f u n c t i o n d e f i n i t i o n s l o c a l t o e n c l o s i n g o b j e c t s . MAYA f u n c t i o n s use EVAL f o r e v a l u a t i o n unless otherwise noted. 27. (SEND <A1XA2> . . . <An>) fSFSOBE} SEND AVALuates each element i n the seguence, <A1XA2> . . <An>, i n a l e f t - t o - r i g h t order. I f the value returned from <Ai> i s an o b j e c t or an item, then i t i s MAYA language Reference 173 pushed onto t h e s t a c k . Next, <Ai+1> i s evaluated i n t h i s new environment. The f i n a l value r e t u r n e d from SEND i s the value of <An>. SEND may be abbreviated by a s i n g l e c o l o n , ":". Examples: (SEND PBINT) ! ( a o B J E C T a a p i i s i a SUBB *) (: PBINT SOBB) 7 * (SETQ NET (OBJECT 'NODE)) {: ?NET (POT* *A (OBJECT ' NODE) ) ~ (POT* ' B (OBJECT 'NODE)) ~ (POT* 'C *CDEF)) T CDEE (SEND ?NET (PBINT A) (PRINT B) (PBINT C) ) ! (aOBJECT® NODE B (©OBJECTS NODE C CDEF)) ! (30BJECT3 NODE C CDEF) ! CDEF ! CDEF B.4 E r r o r C o n d i t i o n s and the DEBUG System There are two c l a s s e s of e r r o r s t h a t can occur during the execution of MAYA. They are e r r o r s trapped by MAYA and e r r o r s trapped by LISP. E r r o r s trapped by MAYA cause an " a p p r o p r i a t e " e r r o r message t o be p r i n t e d and MAYA's DEBOG System to be c a l l e d on the form c a u s i n g the e r r o r . T h i s form i s c a l l e d the Breakform. Note t h a t t h e r e i s one e x c e p t i o n . I f the e r r o r detected by MAY A i s an undefined name or an undefined v a r i a b l e o c c u r i n g a t the t o p - l e v e l of an EAB, then the e r r o r message i s p r i n t e d but an immediate r e t u r n i s made to the EAB. In t h i s case, t h e r e i s no form to BREAK cn. The second c l a s s o f e r r o r s cause a LISP BREAK t o be entered f o r one of the f o l l o w i n g reasons: • A LISP e r r o r o c c u r r e d i n a user's LISP f u n c t i o n . • An unexpected c o n d i t i o n occurred w i t h i n the i n t e r p r e t e r causing i t to abnormally terminate. • An e r r o r o c c u r r e d w i t h i n a MAYA EXPR, NEXPR, or FEXPR type f u n c t i o n . I f a LISP BREAK i s entered f o r one of the above reasons, and the user d e s i r e s t o be i n s t e a d i n a MAYA BBEAK, a t r a n s f e r may be made using the f u n c t i o n , OOPS, d e s c r i b e d below. MAYA language Reference 174 The DEBUG System provided i n MAYA i s modelled a f t e r the LISP/MTS DEBUG Package. Most of the f a c i l i t i e s i n c l u d e d i n the LISP system are provided i n MAYA and a f a m i l i a r i t y with the LISP DEBUG Package i s assumed here. MAYA's DEBUG System can be c a l l e d i n a number o f ways. I t can be c a l l e d e x p l i c i t l y on a f e r n v i a the f u n c t i o n s , DEBUG and BREAK, The system may be c a l l e d i m p l i c i t l y on the body o f a f u n c t i o n v i a s e t t i n g a Breakpoint i n t h a t f u n c t i o n . And l a s t l y , the DEBUG System i s c a l l e d by the i n t e r p r e t e r whenever a MAYA e r r o r o c c u r s . The LISP BREAK f u n c t i o n s , BREflKF, UNBREAKF, and UNSET, have been modified to work with 9EXPR, and QEXPR type f u n c t i o n s as w e l l as EXPRs. As i n LISP/MTS, Ereakpoints can s e t on an e n t i r e f u n c t i o n , or a form w i t h i n a f u n c t i o n . Both types may have an o p t i o n a l p r e d i c a t e which determines whether the break i s acknowledged when encountered. However, care must be taken with the LISP g l o b a l atoms, "?BREAKSw", "? DEBUG", and "7BRQKEN". I f they are t o be a l t e r e d or examined, they must be enclosed i n double quotes to prevent them from being t r e a t e d as v a r i a b l e s by MAY fl or a l t e r n a t i v e l y , read macro pr o c e s s i n g can be d i s a b l e d v i a 80FF-STATUS. . Care must a l s o be taken with l o c a l f u n c t i o n d e f i n i t i o n s . To s e t a Breakpoint on FOO w i t h i n some o b j e c t , FR1: (: FR1 (BREAKF FOG)). To negate the Breakpoint, you must again "GOTO" that o b j e c t : (: FR1 (UNBREAKF FOO)) or (: FR1 (UNSET)). 28. (DEBUG <form>) {iFSUBF} C a l l s the DEBUG System e x p l i c i t l y on <form>. 29. (BREAK <message>*) (3SUBR} EBEAK i s provided as a user e r r r o r handler. I t p r i n t s each <message> on SERROUT then c a l l s the DEBUG System on the c u r r e n t form being evaluated, i . e . , i n most cases BREAK i t s e l f . , 30. (OOPS) fEXPR) A very u s e f u l f u n c t i o n ! OOPS allows the user to recover from a c a t a s t r o p h i c e r r o r t h a t has caused a LISP break to be entered. OOPS w i l l r e t u r n c e n t r e ! to MAYA'S Ereak MAYA Language Reference 175 package with the form that was being evaluated i n MAY.fi at the time of the e r r o r as the Breakform. OOPS may a l s o be used t o Break on MAYA 3SUBBS and 3FS0EES by s e t t i n g a LISP Breakpoint on the i n t e r n a l MAYA r o u t i n e . When the LISP Break i s acknowledged, t y p i n g (OOPS) w i l l t r a n s f e r c o n t r o l back t o MAYA's Debug System with the MAYA 3S0EB or aFSOER as the Breakform. 31. (©BK) {EXPR} P r i n t s a p o s s i b l y long backtrace of the s t a c k . 32. {©TRACE) {EXPB} Begins the p r i n t i n g of a t r a c e o f the e v a l u a t i o n o f each non-atomic form. The form i s p r i n t e d before i t s body i s entered. 33. (3UNTRACE) {EXPB} Turns o f f t r a c i n g . A summary of the commands recognized by the DEBOG System f o l l o w s : BK {n ] A b b r e v i a t i o n : none P r i n t s a backtrace o f the stack s t a r t i n g a t the s t a c k - p o i n t e r f o r l e n g t h Mn'» which d e f a u l t s to 10. BKO [ n ] A b b r e v i a t i o n : none P r i n t s a backtrace of a l l o b j e c t s and items on the stack s t a r t i n g at the s t a c k p c i n t e r f o r a le n g t h of "n" which d e f a u l t s to 10. BKE [ n ] A b b r e v i a t i o n : none P r i n t s a backtrace o f a l l MAYA forms on the stack s t a r t i n g from s t a c k p o i n t e r . "n" d e f a u l t s to 10. * A b b r e v i a t i o n : none P r i n t s the Breakform. Note t h a t i n MAYA, the Breakform i s never on top of the stack a t the time the BREAK i s entered. PP A b b r e v i a t i o n : none P r e t t y - p r i n t s the form where the s t a c k - p o i n t e r p c i n t s . PP* A b b r e v i a t i o n : none P r e t t y - p r i n t s the Breakform. MAYA Language Reference 176 PRINT A b b r e v i a t i o n : P P r i n t s the form where the s t a c k p o i n t e r p o i n t s . TOP A b b r e v i a t i o n : none Besets the s t a o k p o i n t e r to the top of the s t a c k . Note that s i n c e Breakform has not been pushed onto the stack at the time the BREAK occurs, the top c f the stack and Breakform do not c o i n c i d e . The top of the stack i s always the form t h a t c a l l e d Breakform. FIND <loc>* A b b r e v i a t i o n : F Finds a form on the s t a c k and s e t s the s t a c k - p o i n t e r t o t h a t p o i n t . Each <lcc> i s e i t h e r a number of forms to move the s t a c k p o i n t e r down the stack or the name of a f u n c t i o n on the stack. GO [<loc>*3 A b b r e v i a t i o n : G Finds a form on the stack as i n the FIND command, then r e s t a r t s computation BREAKing on t h a t form. <Loc> may be ommitted. RETURN <form> A b b r e v i a t i o n : BET Evaluates <form> and r e t u r n s i t as the value cf the Breakform. ,. RESTART [<form>] A b b r e v i a t i o n : RES R e s t a r t s computation from where the s t a c k p o i n t e r p o i n t s u s i n g <form>. I f <form> i s net coded, computation i s r e s t a r t e d using the p r e v i o u s form on the s t a c k . CONTINUE A b b r e v i a t i o n : C CO Continues with Breakform. I f Breakform has been p r e v i o u s l y e v a l u a t e d v i a the EVAL command, i t w i l l not be r e - e v a l u a t e d . STEP [ n ] A b b r e v i a t i o n : S Steps through the e v a l u a t i o n of the next "n" forms and generates a new BREAK. "n" d e f a u l t s t o 1. NEXT A b b r e v i a t i o n : N NX Evaluates Breakform and breaks on the next form. I f Breakform has been p r e v i o u s l y evaluated v i a the EVAL command, i t w i l l not be r e - e v a l u a t e d , EVAL A b b r e v i a t i o n : E Evaluates Breakform and p r i n t s i t s value. Note t h a t Breakform i s AVALUATEd. OP A b b r e v i a t i o n : J Causes the DEBUG System to ascend one l e v e l . I f there MAYA Language Reference 177 i s no higher EREflR l e v e l , c o n t r o l i s returned to t o p - l e v e l . STOP a b b r e v i a t i o n : NIL || Causes a r e t u r n t o t o p - l e v e l . EDIT [<loc>*] a b b r e v i a t i o n : ED C a l l s EDITE on the form where the s t a c k p o i n t e r p o i n t s . I f <loc>* i s coded, an i m p l i c i t FIND command i s ^executed. Any form typed at DEBUG other than the above commands or there a b b r e v i a t i o n s w i l l be aVALed and i t s value p r i n t e d . Note t h a t the DEBUG System always uses AVAL f o r a l l e v a l u a t i o n s , i . e . , a l l f u n c t i o n d e f i n i t i o n s are f e t c h e d from the f i r s t d e f i n i t i o n found on the s t a c k . B.5 Input/Output When MAYA i s r u n n i n g , a l l I/O i s performed through b u f f e r s s eparate from the ones used by HTS/LISP. Reading i s performed through 3LISPIN with the f i l e p r e f i x c h a r a c t e r M _ M . W r i t i n g i s performed through 3LISP0UT with the f i l e p r e f i x c h a r a c t e r **!". a l l I/O f u n c t i o n s behave, except f o r the c h o i c e of I/O b u f f e r s , as they do i n LISP. 34. (TPRIN1 <form> f<IO-atom>]) {EXPR} PRINTs <form> i n a t e r s e mode, p r i n t i n g descends c n l y a s e t number of l e v e l s i n t o the given s t r u c t u r e , any non-atomic s t r u c t u r e s g r e a t e r than t h i s l e v e l are represented by an "S". I f the second argument, <IO-atcm>, i s given, <form> i s w r i t t e n i n i t s b u f f e r . E l s e <fcrm> i s w r i t t e n i n 3LISP0UT. TPRIN1 r e t u r n s T. 35. (TPRINT <form> [<IO-atom>]) {EXPR} Same as TPRIN1 except t h a t the b u f f e r i s emptied both before and a f t e r <form> i s w r i t t e n . 36. (TPRINT-LEVEL <n>) {NEXPR} Sets the l e v e l to which TPBIN1 and TPRINT w i l l descend. D e f a u l t i s (TPRINT-LEVEL 2). H a Y a Language Reference 178 B.6 P a t t e r n Matching T h i s s e c t i o n d e s c r i b e s the p a t t e r n matching f u n c t i o n s and pa t t e r n element d e f i n i t i o n s provided i n MAYA. <pattern> must be a t u p l e . <Db> must e v a l u a t e to e i t h e r a t u p l e or an o b j e c t r e p r e s e n t i n g a tu p l e database. See below. The <pattern> i s matched a g a i n s t the <db>. I f a match can be found, MATCH r e t u r n s an item c o n t a i n i n g the bi n d i n g s of any p a t t e r n v a r i a b l e s contained i n the <pattern> plus a r e a c t i v a t i o n TAG. Th i s TAG i s an stack segment which permits the matcher to be r e c a l l e d again from the point of i t s l a s t s u c c e s s f u l match. I f <db> i s a tup l e b a s e , the value a s s o c i a t e d with the matching datum i s bound to the v a r i a b l e , '•*««, i n the r e t u r n e d item. I f <db> i s a t u p l e , " ? * " d e f a u l t s to T. I f MATCH f a i l s t o f i n d a match between <pattern> and <db>, <else> i s evaluated. <Else> d e f a u l t s t o NIL. Examples: _ (MATCH «<A B C> »<A B O ) ! (3ITEM3 NIL * T STAGS .....) (MATCH »<A B C> »<A B>) ! NIL A t u p l e data base, c a l l e d a tuplebase, i s the a s s o c i a t i v e data base mechanism i n MAYA. Each tuplebase i s composed of an o b j e c t having a type i n d i c a t o r of e i t h e r "3INDEX3 H or some p o s i t i v e i n t e g e r number. Tuplebases are operated cn by the system f u n c t i o n s : MATCH, NEXT, PADD, PREMOVE, PDELETE, E 1ST, D1ST, SUSPEND, BESUME, COMPLETE, e t c . The user may as w e l l operate on tuplebases by t r e a t i n g them as o r d i n a r y o b j e c t s . Hhen MAYA i s loaded three empty tup l e b a s e s are c r e a t e d w i t h i n the g l o b a l o b j e c t . By convention, t h e i r names and purposes a r e : To c r e a t e a new, empty tupleb a s e w i t h i n some e n c l o s i n g o b j e c t under the name, <name>, one may w r i t e : 37. (MATCH <pattern><db>[<else>1) {3S0BB} (MATCH *<A B C> »<A B> * (LIST «A)) (A) 3TUFLE3 3METH0D3 3PB0C3 f o r d e c l a r a t i v e p a t t e r n s , f o r generator methods, and f o r suspended processes. MAYA Language Reference 179 (PUT* <name> (OBJECT 0 ) ) . 38. (PADD <datumXdb>|[<form> ]) (3SUBR} The <datum>, which must be a t u p l e , i s added to the t u p l e database, <db>. A s s o c i a t e d with <datum> i n the database i s the value of <form>. I f <form> i s not coded, <datum> i s given the value, T. I f <datum> i s al r e a d y present i n the <db> i t s value i s r e p l a c e d with <form>. PADD r e t u r n s the value of <form>. I f <db> i s not a t u p l e b a s e , an e r r o r o c c u r s . Examples: (PADD »<A B C> 3TUPLE3) ! T (HATCH »<A B C> 3TUPLE3) ! (SITEHS NIL * T STAG® ...-..) (PADD '<A B C> 3TUPLE3 » FFF) ! FFF (MATCH «<A B C> 3TUPLE3) ! (3ITEM3 NIL * FFF STAGS- . . . ) 39. (PREMOVE <datumXdb>) {3SUBR} Bemoves <datum> from the t u p l e database, <db>. <Datum> must be a t u p l e and <db> must be a t u p l e b a s e . PEEMOVE r e t u r n s <datum> i f i t was present i n the t u p l e database. I f i t was not present NIL i s retu r n e d . Examples: (PADD *<S D> 3TUPLE3) ! <S D> (PBEHOVE »<S D> 3TUPLE3) T <S D> (HATCH »<S D> 3TDPLE3) ! NIL (PBEMOVE »<S D> 3TUPLE3) ! NIL 40. (PDELETE <pattern><db>[<else> ]) {3SUBB} Hatches <pattern> a g a i n s t <db>. I f the match succeeds, PDELETE d e l e t e s the matching datum from the tuplebase, <db>, and r e t u r n s an item c o n t a i n i n g the b i n d i n g s of <pattern>, the v a r i a b l e , bound t o the value a s s o c i a t e d MAYA Language Reference 180 with the matched datum, and a r e a c t i v a t i o n tag f o r PDELETE. I f the match f a i l s , <else> i s evaluated which d e f a u l t s t c NIL. Note t h a t PREMOVE does not c a l l the p a t t e r n matcher. The datum i n the tuplebase t h a t e x a c t l y matches <pattern> s y n t a c t i c a l l y , i s removed. PDELETE on the other hand d e l e t e s the f i r s t datum which matches <pattern> and i t r e t u r n s a tag f o r subsequent d e l e t i o n s . 41. (PDUMP <db>) fSSDBR} P r i n t s a dump of the p a t t e r n s and t h e i r a s s o c i a t e d values from the t u p l e b a s e , <db>. Example: (PADD »<A B C> STUPLES) ! T (PADD »<A B> ©TUPLES) I T _ (PADD »<HOOF> ©TUPLES »FLOYD) ! FLOYD (PDUMP ©TUPLE©) T <A B> = T ! <A B C> = T ! <W0CF> = FLOYD ! NIL Pat t e r n s i n MAYA are r e p r e s e n t e d as t u p l e s . Each t u p l e i s composed of p a t t e r n elements c a l l e d P a t e l s . There are three types of P a t e l s : 1. P a t e l s t h a t match v a l u e s , 2. P a t e l s t h a t y i e l d values t o be matched, 3. P a t e l s t h a t are r e c u r s i v e l y s u b - p a t t e r n s , i . e . , t u p l e s . The f o l l o w i n g paragraphs w i l l e x p l a i n i n some d e t a i l the d i f f e r e n t p a t t e r n elements t h a t are defined i n MAYA. Because the type-2 P a t e l s are somewhat more s t r a i g h t f o r w a r d than the o t h e r s , they w i l l be e x p l a i n e d f i r s t . Type-2 P a t e l s are p a t t e r n elements t h a t y i e l d values t c be matched. Type-2 P a t e l s can match Type-1 P a t e l s . They can a l s o match type-3 P a t e l s and other type-2 P a t e l s on EQUAL, The f o l l o w i n g forms are i n c l u d e d as type-2 P a t e l s : MAYA Language Reference 181 <ATOM> <LIST> ?<var> !?<var> !-.<var> Note t h a t some of the P a t e l s have p r e f i x e s . These p r e f i x e s determine the manner i n which the P a t e l s y i e l d t h e i r values. The semantics o f Type - 2 P a t e l s are presented below: <ATCM> or <LIST> Atoms and l i s t s are co n s i d e r e d constants i n MAYA pa t t e r n s . T h e i r values are themselves. This format i s sometimes c a l l e d " i n v e r s e quote mode". They y i e l d t h e i r values immediately. Examples: (MATCH «<A (B I (3ITEMS NIL (MATCH «<A (B ! NIL C)> «<A (B C}>) * T STAGS . . . ) C) > »<A <B C » ) ?<var> Y i e l d s the c u r r e n t MAYA val u e o f <var>. Matches whatever i t s value w i l l match as a co n s t a n t . I f <var> i s not bound, an e r r o r o c c u r s . Examples: (SETQ Y »B) ! B _ (MATCH »<A B> *<A ?Y>) ! (SITEMS NIL * T STAGS . . . ) (MATCH »<A ?Y> «<A C>) T NIL (MATCH »<B ?Y> «<?Y ?Y>) ! (SITEMS NIL * T STAGS . . . ) !?<var> Matches the cu r r e n t matcher value of <var> from the same s i d e of the match. I f <var> has not been bound on the same s i d e of the match, the c u r r e n t match f a i l s . Examples: (MATCH '<!:X !?X> «<A A>) ! (SITEMS NIL * T X B STAGS . . .. ,) (MATCH »<A !?X> »<A A>) ! NIL (HATCH »<!?X »:X> «<A A>) MAYA Language eeference 182 ! NIL !-<<var> T h i s p a t e l i s v a l i d only on the <db> s i d e of the match or as a P a t e l i n a QLAMBDA e x p r e s s i o n . I t does not y i e l d a value immediately but o n l y at the time the match succeeds. I t t h e r e f o r e can be used as a mechanism f o r r e t u r n i n g a r e s u l t from a method or the datum sid e of a match. T h i s p a t e l can only match type-1 P a t e l s . Examples: (MATCH «<!:X B> '<!-«Z !:Z>) ! {©ITEMS NIL * T X B STAGS . . . ) (MATCH «<!:X B> «<!--Z B>) ! NIL (MATCH »<A B> ><!-.Z !:Z>) T NIL Type 1 p a t e l s i n c l u d e a l l of the p a t t e r n v a r i a b l e s d e f i n e d i n MAYA. They match values y i e l d e d by the other two p a t e l types and bind t h e i r v a r i a b l e names to those v a l u e s . I f the matcher succeeds, the b i n d i n g s of a l l Type 1 p a t e l s on the p a t t e r n s i d e of the match are composed i n t o t h e item returned from the match. MAYA permits p a t t e r n a c t o r s (Hewitt, 1S72) t o a c t as p r e d i c a t e s on Type 1 p a t e l s . Each p a t t e r n v a r i a b l e i s c f the form: <var-prefix><atom> or <var-pref ix> (<atcmXpred>*) where <atom> i s the name of the p a t t e r n v a r i a b l e , <var-prefix> r e s t r i c t s the types c f v a l u e s t h a t the p a t t e r n v a r i a b l e can match, and <pred>* i s zero or more forms whose e v a l u a t i o n must be non-NIL f o r the match to succeed. The p r e d i c a t e s are e v a l u a t e d i n a l e f t - t o - r i g h t o rder. I f one of the p r e d i c a t e s f a i l s , the remainder are not e v a l u a t e d and the matcher attempts a d i f f e r e n t match. <Atcm> i s bound to i t s matching value before the p r e d i c a t e s are e v a l u a t e d and each <pred> may r e f e r e n c e <atom> as a f r e e v a r i a b l e , e.g., !: (X (PRINT ?X) (F00 ?X ?Y) ) . The f o l l o w i n g p a t t e r n v a r i a b l e s are c u r r e n t l y i n c l u d e d i n MAYA: !:<var> or !: (<varXpred>*) MAYA Language Reference 183 !*<var> or ! * (<varXpred>*) !:<var> Hatches a s i n g l e p a t t e r n element which must be e i t h e r a Type-2 p a t e l or a Type-3 p a t e l c o n t a i n i n g no p a t t e r n v a r i a b l e s . Examples: (HATCH «<!:X !:Y> *<A <B C » ) ! (SITEMS NIL * T X A Y <B C> STAGS . . . ) (SETQ Y *YVAL) T YVAL (MATCH *<!:X B> » « A ?Y> !:Z>) T (SITEMS NIL * T X »<A YVAL> STAGS . . . ) _ (MATCH »<!:X B> » « A !:Z> B>) ! NIL !*<var> Matches a segment cf p a t e l s of l e n g t h zero or l o n g e r . The segment must c o n t a i n no Type-1 p a t e l s . <Var> i s bound to a copy of the segment. Examples: (HATCH «<A !*X> »<A B C>) ! (SITEHS NIL * T X <B C> STAGS . .-...) (HATCH »<A !*X B> »<A B>) ! (SITEMS NIL * T X <> STAGS . ... . ) (MATCH «<A !*X> '<A <B ?Y> C>) I (SITEMS NIL * T X « B YVAL> C> STAGS . . . ) (MATCH »<A !*X> '<A !:Y B>) T NIL (MATCH »<A !*X> »<A !*Y B>) ! (SITEMS NIL * T X <B> STAGS . . . ) Type-3 p a t e l s are t u p l e s , t h a t i s , r e c u r s i v e sub-patterns. Each p a t e l i n a sub-pattern may be e i t h e r a Type-1, Type-2, or Type-3 p a t e l . B.7 Generators 42. (E1ST <pattern><db>[<else> ]) {SSUBR} Generates items i n d e p t h - f i r s t order, i . e . , i n a tuplebase of QLAMBDA methods, D1ST w i l l r e c a l l the same QIAMBBA generator r e p e a t e d l y u n t i l i t f a i l s to r e t u r n a next item. MAYA Language Reference 184 D1ST w i l l then attempt t o match another QLAMBDA ex p r e s s i o n i n the tup l e b a s e . <Pattern> i s matched a g a i n s t <db>, <Pattern> must be a t u p l e and <db> must be a tuplebase of QLAMBDA e x p r e s s i o n s cr QEXPR names. I f the match f a i l s , <else> i s eval u a t e d which d e f a u l t s t o MIL. I f the match succeeds, the matched QLAMBDA ex p r e s s i o n i s evaluated using the item from the datum s i d e of the p a t t e r n match as the a c t u a l arguments to the f u n c t i o n . I f the QLAMBDA s u c c e s s f u l l y t e r m i n a t e s , D1ST r e t u r n s an item from the match p l u s a r e a c t i v a t i o n tag f o r the generator. I f however, the QLAMBDA terminates u n s u c c e s s f u l l y by exec u t i n g the FAIL f u n c t i o n , D 1ST w i l l attempt to f i n d another match i n <db>. Example: (DEFUN GENA QEXPR <A !-X> ~ (SETQ X *A1) ~ (POST) ~ (SETQ X 'A 2)) ! GENA (PADD *<A !->X> 3METH0D3 *GEN A) T GENA (PADD *<B !-»Y> 3METH0D3 ~ » (QLAMBDA <B ! V j f > Z (PROG (N) (SETQ N 0) LOOP (SETQ N (ADD1 ?N) Y (MKATOM « B ?N) ) ~ (AND (EQ ?N 3)(EXIT)) (POST) ~ (GO LOOP) ) ) ) t (QLAMBDA »<B !-Y> . .-...) (D1ST »<!:AB !:V> SMETH0D3) ! (3ITEMS NIL AB A V A1 5TAG3 . . .) {: (ELSE *(RETURN * DONE •:)) ~ (D1ST *<!:AB !:V> 3METHOD3 ' (FAIL)) (PRINT ?V) Z (FAIL)) ! A1 ! A2 ! B1 ! B2 ! B3 ! DONE MAYA Language Reference 185 43. (B1ST <pattern><db>[<else>]) {SSUEE} Generates items i n b r e a d t h - f i r s t order. The arguments and behavior c f B1ST are i d e n t i c a l to D 1ST except t h a t B1ST c a l l s only once each generator i n the s p e c i f i e d tuplebase, <db>, t h a t matches the p a t t e r n , <pattern>. Only a f t e r i t has c a l l e d a l l p o s s i b l e matching QLAMBDAs w i l l i t r e c a l l each suspended generator f o r the second time, then each f o r the t h i r d time, e t c . Example: ;FROM THE TUPLEBASE OF METHODS DEFINED ABOVE (B1ST »<!:AB !:V> SMETHODS) T (SITEMS NIL AB A V A1 STAGS . . .) (: (ELSE *(RETURN 'DONE 1 :)) ~ (B1ST *<!:AB !:V> SMETBODS '(FAIL)) (PRINT ?V) I (FAIL)) ! A1 ! B1 ! A2 ! B2 ! B3 ! DONE 44. (EXIT) {SSUBR} Terminates immediately the c u r r e n t e n c l o s i n g generator or process. The e x i t e d generator or process r e t u r n s an item from the previous i n v o k i n g p a t t e r n match. I f i t i s a process a s s o c i a t e d with a schema, then the h i g h e s t process on the stack a s s o c i a t e d with t h a t schema i s e x i t e d . 45. (POST) {SSUER} Returns an item from a generator. POST i s analogous to the AU-REVOIR f u n c t i o n of CONNIVER. POST causes the f i r s t e n c l o s i n g generator to r e t u r n an item r e p r e s e n t i n g the match t h a t invoked the generator plus a r e a c t i v a t i o n tag. When the generator i s resumed, POST retur n s NIL. Example: See D1ST. The l a s t generator type i s used f o r r e - i n v c k i n g a generator from a r e a c t i v a t i o n tag and f o r implementing a r e s t r i c t e d automatic b a c k t r a c k i n g c a p a b i l i t y . MAYA Language Reference 186 46. (NEXT <item>r <else> ]) {BSUBfi} <Item> must be an item c o n t a i n i n g a r e a c t i v a t i o n tag. NEXT uses the tag i n the item to resume the generator i n order to seek a new match. I f the generator succeeds a g a i n , NEXT r e t u r n s the new item c o n t a i n i n g the new b i n d i n g s of the p a t t e r n v a r i a b l e s from the p a t t e r n s i d e plus a new r e a c t i v a t i o n TAG. I f the generator f a i l s , NEXT r e t u r n s the e v a l u a t i o n of <else> which d e f a u l t s to NIL. 47. (FAIL) {aSOBE} Provides a simple mechanism f o r r e a l i z i n g backtrack search. FAIL l o c a t e s the f i r s t item on the stack c o n t a i n i n g a r e a c t i v a t i o n t a g . The stack i s t r u n c a t e d j u s t past the item and the f u n c t i o n which c r e a t e d the item i s resumed. I f the resumed f u n c t i o n r e t u r n s a new item, computation proceeds forward again. I f however, the f u n c t i o n r e t u r n s f a i l u r e , FAIL evaluates i t s e l f r e c u r s i v e l y , i . e . , i t c o n t i n u e s f a i l i n g up the s t a c k . I f FAIL encounters a generator or process marker cn the s t a c k , the generator or process immediately r e t u r n s NIL. 48. (ELSE <form>) {3S0BB} Creates an e x p l i c i t f a i l p o i n t . ELSE r e t u r n s an item c o n t a i n i n g a s i n g l e b i n d i n g , a r e a c t i v a t i o n t a g bound to <form>. I f NEXT i s a p p l i e d to the item c r i f the item i s encountered on the stack by FAIL, <form> i s e v a l u a t e d . B.8 Processes and Recognizers 49. (PROCESS <schema><gl><pattern>r<else>]) {3SUER} Creates a new process and begins i t s e x e c u t i o n . <Q1> must be e i t h e r a QLAMBDA ex p r e s s i o n or the name of QEXPR f u n c t i o n . The p a t t e r n c f QLAMBDA e x p r e s s i o n i s matched a g a i n s t <pattern> which must be a t u p l e . I f the natch succeeds, a new process i s c r e a t e d and a s s o c i a t e d with <schema> which must be e i t h e r an o b j e c t or NIL. I f NIL i s s p e c i f i e d , the process i s not a s s o c i a t e d with any schema. C o n t r o l i s passed to the body of the QLAMBDA exp r e s s i o n which i s used as the body of the process. I f the match f a i l s , <else> i s e v a l u a t e d . <Else> d e f a u l t s to NIL. When the process terminates or i s suspended, PROCESS r e t u r n s an item from the match of <pattern>. MAYA language Reference 187 50. . (SUSPEND <patternXdb>) {3SUBR} The c u r r e n t p r o c e s s , P1, i s suspended to <pattern> i n the tuplebase, <db>. <Pattern> must be a t u p l e and <db> a tuplebase of processes. C o n t r o l r e t u r n s t o P2, the process which invoked P1. When resumed, SUSPEND r e t u r n s an item r e p r e s e n t i n g t h e match t o <pattern>, 51. (RESUME <patfern><db>[<else>]) {SSUBB} Resumes suspended processes and c r e a t e s new named processes. <Pattern>, which must be a t u p l e , i s matched a g a i n s t <db> which must be a tuplebase of processes. I f the match f a i l s , <else> i s evaluated which d e f a u l t s to NIL. I f the match succeeds, the Batched process i s resumed i f i t i s a suspended process or a new process i s c r e a t e d and begun i f i t i s a named process. When the process r e t u r n s , RESUME r e t u r n s an item r e p r e s e n t i n g the match to <pattern> plu s a r e a c t i v a t i o n tag f o r RESUME. 52. (COMPLETE <pattern><db>[ <else> ]) f SSUER} Suspends a l l a c t i v e processes a s s o c i a t e d with the same schema as the c u r r e n t process, P1, to a r e a c t i v a t i o n tag, then resumes a s p e c i f i e d process, P2. I f P1 i s not a s s o c i a t e d with any schema, only P1 i s suspended. <Pattern>, which must be a t u p l e , i s matched a g a i n s t <db>, which must be a tu p l e b a s e of processes. I f the match f a i l s , <else> i s evaluated which d e f a u l t s to NIL. I f the match succeeds, P1 i s suspended to a r e a c t i v a t i o n tag. P2 i s resumed i f i t was a suspended process or c r e a t e d i f i t was a named process., Included i n the item r e t u r n e d to the i n v o c a t i o n of P2 i s the r e a c t i v a t i o n f o r P1. I f P2 termina t e s v i a any f u n c t i o n except EXIT, P1 w i l l be resumed from the COMPLETE f u n c t i o n . COMPLETE r e t u r n s an item r e p r e s e n t i n g the match of <pattern> plu s a r e a c t i v a t i o n tag f o r subsequent i n v o c a t i o n s of the f u n c t i o n . MaYA Language Reference 188 APPENDIX C IIAMPLE f l S G J A J LISTING ;*** A POLYHEDRAL BLOCKS RECOGNIZER *** ; H. S. HAVENS, UBC, VANCOUVER, CANADA, MAY 1977. ;TOP-IEVEL CALL. ; (DEEUN RECOGNIZE 3EXPR NIL (: SCENE ; CREATE A TOP-LEVEL PROCESS. (PROCESS (SELF) ' (QLAHBDA < !-»DESCBIPTION> (COMMENTARY •"METHOD: TOP-LEVEL RECR EXHAUSTIVE!Y OBSERVES EACH VERTEX") ;EXHAUSTIVELY OBSERVE EACH VERTEX. (MAPC • (LAM EDA (V) (: ;SIND THIS VERTEX. (AVAL ?V) (COMMENTARY '"SCENE RECR OBSERVES" ?V) ;A MESSAGE TO COMPLETE. (RESUME '<OBSEBVE-VERTEX> PROC))) ?VERTEX-LIST) ;A SCENE HAS NOT BEEN FOUND. (PRINT * FAILURE) (FAIL)) •<l:DESCRIPTION> '(RETURN NIL 'RECOGNIZE)) ;SUCCESS! (BREAK •"** SUCCESS! **" 7DESCRIPTION))) ; CREATE GENERIC SCHEMATA (: (PUT* 'SCENE (OBJECT •SCHEHA NAME 'SCENE COMPOSITION 'POLYHEDRON PROC (OBJECT 0))) ;SCENE COMPLETION PROCESS. (PADD *<SCENE-RECR !:POLY> PROC (NAMED—PROCESS 'SCENE-COMPLETE (SELF) ) ) ;SCENE COMPLETION PROCESS. (DEFUN SCENE-CGMPLETE QEXPR <SCENE-RECR !:FCLY> (COMMENTARY •"SCENE RECOGNIZER HAS FOUND A SCENE COMPOSED OF" (: ?POLY NAME) ) (SETQ DESCRIPTION ?P0LY) (EXIT)) ) ;END OF SCENE SCHEMA. Appendix-C: Example Program L i s t i n g 189 (PUT* 'LINE (OBJECT •SCHEMA NAME 'LINE)) {: (PUT* ' VERTEX (OBJECT * SCHEMA PROC (OBJECT 0 ) ) ) ;VERTEX COMPLETION PROCESS. (PADD »<OBSERVE-VERTEX> PROC (NAMED-PROCESS 'OBSERVE-VERTEX)) ;OBSERVATION OF A VERTEX ;DEFAULT IS 3-LINE VERTICES {DEFUN OBSERVE-VERTEX QEXPR <OBSERVE-VERTEX> (: ;SAVE POINTER TO THIS VERTEX. (ITEM SELF (SELF)) (ELSE '(RETURN NIL ':)) ;FOR EACH SECTOR OF THIS VERTEX... (GEN-SECTORS '<?SELF !:L-LINE !:R-LINE !:ANGLE !:SECTOE> (FAIL)) ;IF ALREADY OBSERVED THEN FAIL { AND (GET* ?SECTOR) (FAIL) ) (COMMENTARY •"FOR" 7 S E C T O B »"OF n (: ?SELF NAME)) ;GOTO FACE FACE ;EITHER MATCH THIS SECTOR TO AN EXISTING FACE RECR... (OR ;FOR EACH FACE RECR... (MAPC • (LAMBDA (RECR) {: ?R ECR ;MATCH IT CWISE OR CCWISE (COMMENTARY '"ATTEMPT TO MATCH THE EXPECTATIONS OF" (: ?RECR NAME)) (OR (COMPLETE »<FACE-RECB CWISE 7R-LINE !:(FV {NEQ ?FV ?SELF)) ?SELF ?L-LINE ?ANGLE ?SECTOR> CONSTRAINTS) (COMPLETE «<FACE-RECR CCWISE 7 L-LINE !:(FV (NEQ ?FV ?SEIF)) 7 S E L F 7 R - L I N E 7 A N G L E ?SECTOR> CONSTRAINTS) (RETUBN NIL 'LAMBDA) ) ; MATCH SUCCEEDED. Appendix-C: Example Proqram L i s t i n g 190 (RET0BN »T 'MAPC) )) DUET) ;OR A NEW ONE. (: {NEW-FACE-RECR *<?SELF ?L-LINE 7R-IINE 7ANGLE ?SECTOB») ) ;8ETURN FOB NEXT SECTOR. (FAIL))) ) ;END OF VERTEX. ; DEFINE VERTEX TYPES. {POT* 'ARROW-VERTEX (NEW VERTEX TYPE 'ARROW)} (PUT* 'FORK-VERTEX (NEW VERTEX TYPE 'FORK)) (POT* • T-VERT EX (NEW VERTEX TYPE 'T) ) (POT* 'L-VERTEX (NEW VERTEX TYPE *L) ) (: VERTEX (POT* 'INSTANCES {LIST ARROW-VEBTEX FOBK-VEBTEX T-VERTEX L-VERTEX))) ; DEFINE FACE SCHEMA {: (POT* 'FACE (OBJECT 'SCHEMA NAME 'FACE COMPOSITION • (VEBTEX LINE) DNET NIL NRECRS 0)) ;NEW FACE RECOGNIZER (DEFON NEW-F ACE—.RECR QEXPR <!: FIRST-VERTEX !:L-EDGE !:R-EDGE !:ANGLE !:SECTOR> {: ;CREATE AN INITIAL CORNER FOR THIS FACE (ITEM CORNER (OEJ1CT ' SN ET VERTEX (: ? FIRS T-VERTEX NAME) L-EDGE 7L-EDGE R-EDGE ?R-EDGE ANGLE 7ANGLE) ) ;VERTEX SECTOR IS THIS NEW CORNER. {: 7FIRST-VERTEX (POT* 7SECTOR 7CORNER) T) ;CREATE A NEW FACE RECOGNIZER {NEW FACE NAME (MKATOM '"FACE-" (ADD1 {: FACE NBECRS) )) CONSTRAINTS (OBJECT 0) CORNERS (LIST 7CCHNER) EDGES NIL CCW-CORNER 7COENEB CW-COBNER 7COBNER) (ITEM SELF (SELF)) (COMMENTARY *"CREATE A NEW BECB:» NAME *"CONTAINING Appendix-C: Example Program L i s t i n g 191 A CORNER FOR" (: ?FIEST-VERTEX NAME)) {: 7CCBNEB (PUT* • PABT-O E 7SELE) T) ;CREATE 2 PROCESSES TO EXPECT VERTICES CWISE AND CCWISE ; ABOUND THIS FACE. (COMMENTARY »"CREATE TWO PROCESSES BOUND TO EXPECTATIONS FOR" 7L-EDGE '"AND" 7R-EDGE) (PROCESS 7SELF * CW-FACE-BICR '<?L-EDGE ?FIRST-VERTEX>) (PROCESS 7SELF 'CCW-FACE-RECR '< 7R-EDGE 7FIRST-VERTEX>) ;BECORD THIS RECB INSTANCE IN THE GENERIC FACE SCHEMA FACE (PUT* ' NRECRS (ADD1 NRECBS) ) (PUT* • DNET (CONS 7SELF DNET) ) ) ) (DEFUN CW-FACE-RECR QEXPR <!:EXPECT !:FIR ST-VERTEX> {: ;GET THIS SCHEMA. (ITEM SELF (SELF) ) ;SUSPEND THIS PROCESS TO CWISE EXPECTATIONS (SUSPEND <FACE-RECR CWISE ? EXPECT ?FIRST-VERTEX ! : VERT EX !:NEXT-EXPECT !:ANGLE !:SECTOR> CONSTRAINTS) (COMMENTARY (: ?SELF NAME) '"HAS BEEN MATCHED EY" (: ?VERTEX NAME)) ;CREATE A NEW CORNER FOR THIS VERTEX. (ITEM CORNER (OEJICT * SNET PART-OF 7SELF VERTEX {: ?VERTEX NAME) R-EDGE ?EXPECT L-EDGE 7NEXT-EXPECT ANGLE ? ANGLE NEXT-CCW CW-CORNER) ) ;VERTEX SECTOR COMPRISES THIS NEW CORNER. (: 7VERTEX (PUT* 7SECT0R ?CORNER) T) ;ADD TO LIST OF CORNERS FOR THIS FACE 7SELF (PUT* *CORNERS (CONS 7CGRNER CORNERS)) ;UPDATE LIST OF EDGES FOR THIS FACE. (PUT* * EDGES (CONS 7EXPECT EDGES) ) ;EXCHANGE CWISE AND CCWISE POINTERS. (: CW-COBNER (PUT* •NEXT-CW 7CORNER) T) (: 7CORNER (PUT* 'NEXT-CCW CW-CORNER) T) ;UPDATE CW-CORNER (: (PUT* 'CW-CORNER 7C0RNER) T) ;VERIFY THIS FACE USING TOP-DOWN SEARCH (COMMENTARY '"VERIFY" {: 7SELF NAME) ' "USING TOP-DOWN SEARCH") Appendix-C: Example Program L i s t i n g 192 (VER IFY-PACE 7SELF (ADD (: CW-COBNER ANGLE) <: CCW-CORNER A N G L E ) ) ) ) ) (DEFUN CCH-FACE-RECR QEXPR < ! : EXPECT ! : F I R S T - V E R T E X > {: ;GET THIS SCHEMA. ( ITEM S E L F (SELF) ) ^SUSPEND THIS PROCESS TO CCWISE EXPECTATIONS. (SUSPEND <FACE-R ECR CCWISE ? EXPECT ?F IRST-VERTEX ! :VERTEX ! : N E X T - E X P E C T ! : A N G L E ! : S E C T O R > CONSTRAINTS) (COMMENTARY (: ? SELF NAME) * "HAS BEEN MATCHED EY" {: ?V EBTEX NAME)) ;CREATE A NEW CORNER FOR THIS F A C E . ( ITEM COBNER (OBJECT 1 S N E T PART-OF ?SELF VERTEX (: ?VERTEX NAME) R-EDGE ?N EXT-EXPECT L-EDGE 7EXPECT ANGLE ?ANGLE NEXT-CW CCW-CORNER) ) ;VERTEX SECTOR COMPRISES THIS NEW COBNER. {: 7VERTEX (POT* 7SECTOR 7CORNER) T) ;ADD TO L I S T OF CORNERS FOR THIS F A C E . ? S ELF (POT* 'CORNERS (CONS 7C0RNER CORNERS) ) ;UPDATE L I ST OF EDGES FOB THIS F A C E . (POT* * EDGES (CONS 7EXPECT EDGES)) ;EXCHANGE CWISE AND CCWISE POINTERS. (: CC1-CCBNEB (POT* 'NEXT-CCW 7CORNER) T) (: ?CORNER (PUT* 'NEXT-CW CCW-CORNER) T) ;UPDATE CCWISE CORNER. C (PUT* 'CCW-CORNER 7CORNER) T) ;VER IFY THIS FACE; USING TOP-DOWN SEARCB. (COMMENTARY * "METHOD: VER I FY " (: 7SELF NAME) ' " U S I N G TOP-DOWN SEARCH") (VER IFY-FACE ? SELF (ADD {: CW-CORNER ANGLE) {: CCW-CORNER ANGLE ) ) ) ) ) ;SEARCH TOP-DOWN FOR THE REMAINDER OF THIS FACE . (DEFUN VEB I FY-FACE SEXPB (TH IS-FACE EX-ANGLE) (: ;GET NEIGHBORING CWISE VERTEX. ( ITEM NEIGHBOfi-VERT EX (: 7TH IS-FACE CW-CORNER (NEIGHBOR-VEBTEX L-EDGE VERTEX) ) ) (COMMENTARY ' " G E T NEXT CLOCKWISE NEIGH EOS V E R T E X : " Appendix-C: Example Program L i s t i n g 193 {: ?NEIGHBOR-VERTEX NAME) •"FROM" (: ?THIS-FACE CW-CORNER L-EDGE) ) ;GET FACE RECR THAT THIS CWISE SECTOR IS PART OF. ; ELSE NIL. (ITEM OTHER-FACE (: ?T HIS-FACE CW-CGRNER ?NEIGHBOR-VERTEX (GET* (: (CWISE-SECTOR L-EDGE)) *(RETURN NIL »:)) PART-OF)) (COND ;IS THIS VERTEX PART OF THIS FACE RECR? ((EQ ?THIS-FACE ?OTHER-FACE) (COMMENTARY '"THIS VERTEX IS ALREADY CONTAINED IN" (: 7THIS-FACE NAME) ) (: ;COMPLETE THE DESCRIPTION OF THIS FACE. ?THIS-FACE ;UPDATE LIST OF EDGES. (PUT* 'EDGES (CONS (: CW-CORNER L-EDGE) EDGES) ) ;MAKE CWISE AND CCWISE RINGS. (: CW-CORNER (PUT* 'NEXT-CW CCW-CORNER) T) (: CCW-CORNER (PUT* 'NEXT-CCW CW-CORNER) T) ;TEST THE COMPLETED FACE. (COMMENTARY '"COMPARE" (: ?THIS-FACE NAME) '"TO POLYGON MODEL") (TEST-COMPLETED-FACE ?THIS-FACE ?EX-ANGLE) ;MATCH THIS FACE TO POLYHEDRON SUPERGOALS. (COMPLETE-FACE ?THIS-FACE) ) ) ;IS THIS SECTOR PART OF SOME OTHER RECR? (?OTHER-FACE (COMMENTARY '"ITS CWISE SECTOR IS ALREADY PART OF A CORNER OF" (: ?OTHER-FACE NAME)) ;DELETE THE OTHER FACE FROM DNET OF GENERIC FACE. (: FACE (PUT* 'DNET (DELQ ?OTHER-FACE DNET)) T) INCORPORATE ITS CORNERS INTO THIS FACE. ;EXCHANGE CWISE AND CCWISE POINTERS. (: 70THER-FACE CCW-CORNER (POT* * NEXT-CCW (: ?THIS-FACE CW-CCRNEB) ) ) {: ?THIS-FACE CW-CORNER (PUT* 'NEXT-CW (: ?OTHER-FACE CCW-CORNER))) ;FOLLOW THE EDGES OF THE OTHER FACE CWISE. (COMMENTARY *"INCORPORATE THE CORNERS OF" {: ?GTHER-FACE NAME) *"INTO" (: ?THIS-FACE NAME)) (:(FOLLOW-FACE ?THIS-FACE ?EX-ANGLE))) ;EL SE THIS VERTEX HAS NOT BEEN OBSERVED EEFORE. (T (COMMENTARY •"INCORPORATE THIS VERTEX INTO A NEW CORNER OF" (: ?THIS-FACE NAME) ) (: ;CREATE A NEW CORNER FOR THIS VERTEX. ?THIS-FACE Appendix-C: Example Program L i s t i n g 194 7NEIGHB0B-VERTEX (ITEM COENEB (OBJECT * SNET PART-OF 7THIS-FACE VEBTEX NAME L-EDGE (: CW-CORNER (CW-LINE L-EDGE) ) B-EDGE L-EDGE ANGLE (: CW-CORNER (CW-ANGLE L-EDGE)))) ;MAKE VERTEX POINT TO CORNER. (POT* {:(CWISE-SECTOR (: CW-CORNER L-EDGE})) 7CCRNEB) ; ADD TO THIS FACE. 7THIS-FACE (PUT* • CORNERS (CONS 7CORNER CORNERS)) ;UPDATE LIST OF EDGES FOB THIS FACE. (PUT* * EDGES (CONS (: CW-CORNER L-EDGE) EDGES)) ;EXCHANGE CWISE AND CCWISE POINTERS. {: CW-CORNER (PUT* * NEXT-CW 7C0BNEB) T) (: 7C0RNER (PUT* ' NEXT-CCW CW-CORNER) T) ;UPDATE CWISE COBNER (: (PUT* * CW—CORNER 7CORNER) T) ;RECURSE ON THE NEXT CWISE VERTEX. (VERIFY-FACE ?THIS-FACE (ADD ?EX-ANGLE (: 7CORNEB ANGLE)))))))) ;INCOBPOBATE THE NEW COR NEBS INTO THIS FACE. (DEFUN FOLLOW-FACE SEXPR (7THIS-FACE ?EX-ANGLE) (: ;GOTO CWISE CORNER OF THIS FACE. 7THIS-FACE CW-CGRNER (COND ;IS THERE A NEXT CWISE CCRNER? ({GET* • NEXT-CW) (COMMENTARY '"INCLUDE THE CORNER FOR" {: NEXT-CW VERTEX)) ;INCLUDI IN CORNERS LIST. (: 7THIS-FACE (PUT* * CORNERS (CONS NEXT-CW COBNEBS) ) {PUT* ' EDGES (CONS L-EDGE EDGES))) iADVANCE POINTEB TO THE NEXT CWISE CORNER. (: 7THIS-FACE (PUT* 'CW-CORNEB NEXT-CW)) ; MAKE THIS COBNER POINT TO THIS FACE. (: CW-CORNER (PUT* 'PART-OF ? THIS-FACE)) ;RECURSE ON THE NEXT CORNER. (: (FOLLOW-FACB 'THIS-FACE (ADD ANGLE ? EX- ANGLE) )} ) ;VERIFY EACH CWISE VERTEX. (T(COMMENTARY '"ALL CORNERS HAVE BEEN INCLUDED") (:(VERIFY-FACE 7THIS-FACE (ADD ANGLE ?EX-ANGLE))))))) Appendix-C: Example Program L i s t i n g 195 ; TEST THIS FACE AND ASSIGN ITS TYPE. {DEFUN TEST-CO MPLETED-FACE 3 EXPR (FACE EX-ANGLE) {: ?FACE ;CHECK THE SUM OF THE FACE'S EXTERIOR ANGLES. (COND ({EPSILON 10 360 ?EX-ANGLE) (PUT* 'TYPE * INSIDE-CLOSURE)) ( (EPSILON 10 -360 ?EX-ANGLE) ;DECIDE FACE'S TYPE. (SELECTQ (LENGTH EDGES) (3 (PUT* 'TYPE 'TRIANGLE)) (4 (COND ;IS FACE A PARALLELGGBAM? ({AND (EPSILON 10 (MINUS (: CW-COBNER ANGLE)) (: CCW-CCRNER NEXT-CW ANGLE) ) (EPSILON 10 (MINUS (: CCW-COBNEB ANGLE) ) (: CW-CORNER NEXT-CCW ANGLE))) (PUT* 'TYPE 'PARALLELGGBAM)) (T(PUT* 'TYPE 'QUADRALATERAL)))) (POT* 'TYPE * MULTILATERAL))) ) (COMMENTARY »"COMPLETED" NAME '"IS A" TYPE))) ;MATCH THIS FACE TO POLYHEDRON RECRS. (DEFUN COMPLETE-FACE SEXPR (THIS-FACE) ;DELETE THIS RECR FROM DNET OF FACE RECRS. (: FACE (PUT* 'DNET (DELQ ?THIS-FACE DNET))) (COMMENTARY '"MATCH THIS FACE TO THE EXPECTATIONS OF POLYHEDRON RECOGNIZERS") {: POLYHEDRON (OR ;MATCH "CONNECT" EXPECTATIONS OF SOME POLYHEDRON RECR. (MAPC »(LAMBDA (RECR) (COMMENTARY '"MATCH THE CONNECT EXPECTATIONS OF" (: ?RECR NAME) ) (: ?RECR (ELSE • (RETURN NIL * :) ) ;GENERATE ALL CONNECT EDGES FOR THIS FACE. (GEN-EDGES '<?THIS-FACE !:EXPECT !:EDGE-TYPE> ' (FAIL) ) (OR (EQ ?EDGE-TYPE * CONNECT) (FAIL) ) (COMMENTARY '"TRY" ?EXPECT) ;MATCH THIS RECR'S EXPECTATIONS. (COMPLETE »<POLYHEDRON-RECR CONNECT ? EXPECT !:NODE ?THIS-FACE> CONSTRAINTS *(FAIL)) -.DONE. (RETURN T 'MAPC) ) ) Appendix-C: Example Program L i s t i n g 196 RECRS) ;ELSE MATCH "MAYBE-CONNECT" EXPECTATIONS OF A l l RECRS. (PROGN <MAPC * (LAMBDA (RECR) (COMMENTARY »"MATCH THE MAYBE-CONNECT EXPECTATIONS OF" (: ?HECR NAME) ) C ?RECR (ELSE * (RETURN NIL ':)) ;GENERATE MAYBE CONNECT EXPECTATIONS. (GEN-EDGES •<?THIS-FACE !:EXPECT !:EDGE-TYPE> ' (FAIL) ) (OR (EQ ?EDGE-T¥PE •MAYBE-CONNECT)(FAIL)) (COMMENTARY •"TRY" ?EXPECT) ;MATCH THIS RECR'S EXPECTATIONS. (COMPLETE » <POLYHEDRCN-RECR MAYBE-CONNECT ?EXPECT !:NODE ?THIS-FACE> CONSTRAINTS »(FAIL)) ;DONE WITH THIS RECR. (RETURN NIL ':))) BECRS) ;AND CREATE A NEW RECR FOR THIS FACE. (: (NEW-POLYEEDBGN-EECR 7THIS-FACE) )) ) ) ) ;GENERATES THE EDGES AND EDGE TYPES FOR A GIVEN FACE. (DEFUN GEN-EDGES QEXPR <!:FACI !-EDGE !-EDGE-TYPE> (: ?FACE ;FOR EACH EDGE IN THIS FACE... (MAPC • (LAMBDA {E) (: (AVAL ?E) (COND ( (OR (: (AVAL V1)(AND (EQ TYPE • ARROW) {EQ L 2 ?E)}) (: (AVAL 7 2 ) (AND (EQ TYPE »ABBOW) (EQ L 2 ? E ) ) ) ) ;THEN EDGE IS CONNECT. (SETQ EDGE ?E EDGE-TYPE 'CONNECT)) (T ;ELSE EDGE IS MAYBE-CONNECT. (SETQ EDGE ?E EDGE-TYPE •MAYBE-CGNNECT)) EDGES) {FAIL))) (POST))) ) ;EfiD OF FACE Appendix-C: Example Program L i s t i n g 197 {: (PUT* ' POLYHEDRON (OBJECT * SCHEMA NAME 'POLYHEDBON COMPOSITION * FACE RECRS NIL NBECRS 0)) ;CREATES A NEW POLYHEDEON RECR. (DEFUN NEW-POLYHEDRON-RECR 3EXPR (FACE1) ;IS THIS FIRST FACE COMPATIBLE WITH THIS BECR'S MODEL ; OF POLYHEDRA? (OR {: POLYHEDRON (TEST-FACE-TYPE 7FACE1)) (RETURN NIL 'NEW-POLYHEDRON-RECR) ) (: ;CREATE A CONNECT NODE TC REPRESENT THIS FACE., (ITEM NODE (OBJECT 'SN ET NFACE ?FACE1 CONNECT NIL)) ;CBEATE A POLYHEDBON SCHEMA INSTANCE. (NEW POLYHEDBON NAME (MKATOM '"POLYHEDRON-" {: POLYHEDRON {A ED 1 NBECRS))) CONSTRAINTS (OBJECT 0) NODES (LIST ?NODE) HAYBE-NODES NIL) ; SAVE POINTER TO THIS BECB. (ITEM RECR (SELF) ) (COMMENTARY '"CREATE A NEW RECR:" NAME '"CCNTAINING" (: ?FACE1 NAME) ) (COMMENTARY *"COMPUTE EXPECTATIONS ABOUT OTHER FACES OF" NAME) ;RECORD IN THE GENERIC POLYHEDRON SCHEMA. (: POLYHEDRON (PUT* 'RECRS (CONS ?RECR RECRS) ) (PUT* • NRECRS (ADD1 NBECRS) )) ;CREATE A PROCESS BOUND TO AN EXPECTATION FOR EACH EDGE ; IN THIS FACE. (: (ELSE ' (RETURN NIL •:)) ;GENERATE EACH EDGE OF THIS FACE AND ITS TYPE. (: FACE (GEN-EDGES »<?FACE1 !:EDGE !:EDGE-TYPE> '(FAIL))) (COMMENTARY '"FOR" 7EDGE '"OF" (: ?FACE1 NAME) ) ;EITHER A CONNECT OR MAYBE-CONNECT PROCESS. (COND {(EQ ? EDGE-TYPE 'CONNECT) (PROCESS ?RECR 'ACCEPT-CONNECT-FACE »<?RECR ?EDGE ? N O D E » ) ({PROCESS ?RECR 'ACCEPT-MAYBE-CONNECT-FACE •<?BECR ?EDGE ?NODE>})) ;GO BACK FOR NEXT EDGE. (FAIL) ) ;SEARCH FOR OTHEB FACES OF THIS POLYHEDBON BY OBSERVING ; 3-LINE VERTICES OF THIS FACE. Appendix-C: Example Program L i s t i n g 1 9 8 (COMMENTARY '"METHOD: SEARCH EOR OTHER FACES OF" C ?RECR NAME) '"BY OBSERVING VERTICES OF") (COMMENTARY •« " {: ?FACE1 NAME) "•THAT MAY BE PART OF MORE THAN ONE FACE") 7FACE1 (MAPC ' (LAMBDA (CORNER) (: ?COR NER (AVAL VERTEX) (COND ( (MEMQ TYPE ' (ARROW FORK T) ) (COMMENTARY (: ?RECB NAME) '"OBSERVES" NAME) (RESUME '<OBSERVE-VERTEX> PROC))))) CORNERS) )) ;ACCEPTS MATCHING CONNECT FACE INTO THIS POLYHEDRAL DESCRIPTION. (DEFUN ACCEPT-CONNECT-IACE QEXPR <!:RECR !:EXPECT !:EXPECT-NODE> (COMMENTARY *"CREATE A PROCESS BOUND TO THE CONNECT EXPECTATION:" ?EXPECT) {: ?R ECR ;SUSPEND THIS PROCESS TO THIS EXPECTATION. (SUSPEND <POLYHEBRON-RECR CONNECT 7EXPECT 7EXPECT-NODE !:FACE> CONSTRAINTS) (COMMENTARY '"A CONNECT EXPECTATION OF" {: ?RECR NAME) *"HAS BEEN MATCHED BY" {: ?FACE NAME)} ;IS NEW FACE COMPATIBLE WITH THIS MODEL OF POLYHEBBA? (OR {: (TEST-FACE-TYPE ?FACE) ) ( FAIL) ) ;CREATE A NODE IN THIS RECB'S DESCRIPTION FOR THIS FACE. (ITEM NODE (OBJECT 'SNET NFACE 7FACE MAYBE-CONNECT NIL CONNECT (LIST 7EXPECT-NGD1) ) ) (PUT* 'NODES (CONS 7N0DE NODES)) (: 7EXPECT-NODE (PUT* 'CONNECT (CONS 7NODE CONNECT))) -.COMPUTE TRANSITIVE CLOSURE OF EDGES FOR THIS FACE. (COMMENTARY '"COMPUTE TRANSITIVE EDGE CLOSURE FOR THIS FACE") (: (ELSE * (RETURN NIL ':)) ;FOR EACH OTHER EDGE IN THIS FACE... (: FACE (GEN-EDGES '<?FACE !:EDGE !:EDG E-TYPE> '(FAIL))) ;IS IT THE PREVIOUS EXPECTATION? (AND (EQ ?EDGE ?EXPECT)(FAIL)) (COMMENTARY • "FOR" ?EDGE »"GF" ' {: ?FACE NAME) ) ;ELSE COMPUTE CLOSURE FOR THIS EDGE. (EDGE-CLOSURE 7RECR ?EDGE ?EDGE-TYPE ?NODE) ;GET NEXT EDGE. (FAIL) ) ;MATCH MAYBE CONNECT FACES TO THESE NEH EXPECTATIONS. (MAPC * (LAMBDA (MNODE) (: (ITEM MFACE {: 7MNODE NFACE) ) (COMMENTARY *"ATTEMPT TO MATCH MAYBE-CCNNECT FACE:" (: 7MFACE NAME) '"TO THESE NEW EXPECTATIONS") Appendix-C: Example Proqram L i s t i n g 199 (ELSE '(RETURN NIL ':)) ;FOB ANY CONNECT EDGE IN THIS FACE... {: FACE {GEN-EDGES '<?MFACI !:EDGE !:EDGE-TYPE> 1 (FAIL))) (OR {EQ ?EDGE-TYPE 'CONNECT) (FAIL) ) (COMMENTARY '"TRY" ? EDGE) ;IS THIS EDGE NOW CONNECT KITH THIS RECR? (MATCH '<POLYHEDRON-RECR CONNECT ?EDGE !:EXPECT-NODE XX> CONSTRAINTS » (FAIL) ) (COMMENTARY (: ?MFACE NAME) '"IS CONNECT WITH" (: ?RECR NAME) ) ;THEN MOVE THIS NODE TO CONNECT LIST. (PUT* 'NODES (CONS ?HNODE NODES)) (POT* 'MAYBE-NODES (DELQ ?MNODE MAYBE-NODES)) ;ADD CONNECT LINK TO PREVIOUS MAYBE CONNECT. (: ?EXPECT-NODE (PUT* 'CONNECT (CONS ?MNODE CONNECT) ) ) ;COMPDTE TRANSITIVE CLOSURE FOR EDGES ; OF THIS NODE. (COMMENTARY * "COMPUTE TRANSITIVE EDGE CLOSURE FOR" (: ?MFACE NAME)) (: (ELSE • (RETURN NIL ':)) ;FOR EACH EDGE IN THIS FACE... (: FACE (GEN-EDGES »<?MFACE !;EDGE !:EDGE-TY PE> * (FAIL))) ;EXCEPT EDGE OF PREVIOUS MAYBE-CONNECT? (AND (EQ ? E DGE (: ?MNODE MEDGE) ) (FAIL) ) (COMMENTARY '"FOR" ?EDGE '"OF THIS FACE") ;COMPUTE CLOSURE FOR THIS EDGE. (EDGE-CLOSURE ?BECB ?EDGE ?EDGE-TYPE ?MNODE) ;GET NEXT EDGE. (FAIL)) ;FINISHED WITH THIS NODE. (RETURN NIL 'LAMBDA))) MAYBE-NODES) (COND ;DOES DESCRIPTION SATISFY POLYHEDRON MODEL? ((:(TEST-POLY ?RECB))(:(COMPLETE-POLYHEDRON ?RECR))) ;ELSE SEARCH FOR OTHER FACES OF THIS VERTEX BY ; OBSERVING 3-LINE VERTICES THAT ARE AT THE ; PERIPHERY OF THIS INCOMPLETE POLYHEDRON. (T(COMMENTARY «"METHOD: OBSERVE VERTICES THAT WILL DRIVE THE RECOGNITION OF NEIGHBORING FACES") {: (ELSE ' (RETURN NIL ':)) ;FOR EACH EXPECTATION IN THIS RECR... Appendix-C: Example Program L i s t i n g 200 (MATCH »<POLYHEBRON-RECR !:EDGE-TYPE !:EDGE ! :EXPECT-NODE XX> CONSTRAINTS ' (FAIL) ) (AVAL ?EBGE) ;OBSERVE EITHER VEBTEX OF EDGE IF A 3-LINE VERT C (AVAL V1) (COND { (MEMQ TYPE « (ARROW FORK T) ) {COMMENTARY {: ?R ECR NAME) '"OBSERVES" NAME) (RESUME •<OBSEBVE-VEETEX> PROC)))) {: (AVAL V2) (COND ( (MEMQ TYPE ' (ARROW FORK T) ) (COMMENTARY (: ?RECR NAME) '"OBSEBVES" NAME) (RESUME »<OBSEBVE-VEBTEX> PROC)))) ;GO BACK FOR NEXT EXPECTATION. (F A I L ) ) ) ) ) ) ; ACCEPTS MAYBE-CONNECT FACES INTO THIS RECR. {DEFUN ACCEPT-MAY8E-C0NNECT-FACE QEXPR <!:RECR !:EXPECT !:EXPECT-NODE> (COMMENTARY '"CREATE A PROCESS BOUND TO THE MAYBE-CONSECT EXPECTATION:" ?EXPECT) (: ?RECR ;SUSPEND THIS PROCESS TO THIS EXPECTATION. (SUSPEND <POLYHEDRON—RECR MAYBE-CONNECT 7EXPECT ? EX P ECT-NO D E !:FACE> CONSTRAINTS) (COMMENTARY »"A MAYBE-CGNNECT EXPECTATION OF" {: ?BECB NAME) '"HAS BEEN MATCHED EY" (: ?FACE NAME)) ;IS NEW NODE COMPATIBLE WITH MODEL OF POLYHEDRA? (OR (: {TEST-FACE-TYPE ?FACE) ) (FAIL)) ;CREATE A NEW NODE FOR THIS FACE. (ITEM NODE (OBJECT * SNET NFACE ?FACE HEDGE ?EXPECT CONNECT (LIST ?EXPECT-NODE) ) ) INCORPORATE THIS NODE INTO THIS POLYHEDRON DESCRIPTION. (PUT* * MAYBE-NODES (CONS ?NODE MAYBE-NODES)))) ;COMPUTES THE TBANSITIVE CLOSURE OF CONNECT EDGES. (DEFUN EDGE-CLOSURE 3JEXPR (THIS-RECB EDGE EDGE-TYPE NEW-NODE) (: ?THIS-BECB Appendix-C: Example Program L i s t i n g 201 (COND ;DOES EDGE MATCH EXPECTATIONS OF THIS RECR? ( ( : (PDELETE »<PGLYHEDRON-RECR 7EDGE-TYPE ?EDGE !:THIS-NODE XX> CONSTRAINTS ' (RETURN NIL » :) ) (COMMENTARY ?EDGE '"MATCHES A" 7EDGE-TYPE '"EXPECTATION OF" {: 7THIS-RECR NAME}) ;EXCHANGE CONNECT LINKS BETWEEN NODES. 7THIS-N0DE (PUT* 'CONNECT (CONS 7NEW-N0DE CONNECT) ) 7NEW-NODE (PUT* * CONNECT (CONS 7THIS-NODE CONNECT)))) ; ELSE CREATE A CONNECT OR MAYBE-CONNECT PROCESS. ((EQ ?EDGE-TYPE 'CONNECT) (PROCESS 7THIS-8ECR •ACCEPT-CONNECT-FACE '<?THIS-RECR ? EDGE ?NEW-NODE>)) {(PROCESS 7THIS-RECR •ACCEPT-MAYBE-CONNECT-FACE '<?THIS-RECR ?EDGE ?NEW-NODE>)}))) ; MATCH COMPLETED POLYHEDRON TO EXPECTATIONS OF SCENE SCHEMA. (DEFUN COMPLETE-POLYHEDRON SEXPR (RECR) (COMMENTARY '"MATCH COMPLETED" (: ?RECR NAME) ' "TO THE EXPECTATIONS OF THE SCENE RECR") {: SCENE (COMPLETE «<SCENE-RECR ?RECR> PBGC • (FAIL))) ) ;TFST FOR COMPLETED POLYHEDRON. (DEFUN TEST-POLY SEXPR (RECR) (COMMENTARY '"DOES DESCRIPTION OF" {: 7RECR NAME) '"SATISFY THE CRITERIA FOR A COMPLETE POLYHEDRAL OBJECT?") (: ?RECR ;ARE THERE NO MORE CONNECT EXPECTATIONS FOB THIS POLYHEDRON? (COND ((MATCH «<POLYHEDRON-RECR CONNECT !:XX !:XX XX> CONSTRAINTS) (COMMENTARY »"NO") NIL) { (PBOG (NTBI) (SETQ NTBI 0) (MAPC « (LAMBDA (NODE) {: ?NODE NFACE (AND (EQ TYPE 'TRIANGLE) (SETQ NTRI (ADD1 ?NTRI) ) ) ) ) NODES) (SELECTQ ?NTRI (0 (PUT* 'TYPE 'CUBE)) (1 (PUT* 'TYPE 'WEDGE)) Appendix-C: Example Program L i s t i n g 202 (POT* 'TYPE 'PYRAMID)) (COMMENTARY '"YES:" NAME '"IS A" TYPE) T))))) ;IS PROPOSED FACE COMPATIBLE WITH MODEL OF ECLYHEDR A? (DEFDN TEST-FACE-TYPE 2EXPB (FACE) (COMMENTARY '"IS" {: ?FACE NAME) *"COMPATIBLE WITH THIS CLASS OF POLYHEDRA?") (COND ((MEMQ {: ?FACE TYPE) '{TRIANGLE PARALLELOGRAM)) (COMMENTARY »"YES") T) (T(COMMENTARY '"NO: REJECT THIS FACE") NIL))) ) ;END OF POLYHEDRON. ; AUXILIARY FUNCTIONS. (: VERTEX GENERATES SECTORS OF A 3-LINE VERTEX. (DEFUN GEN-SECTORS QEXPR <!: VERTEX I-.L-LINE I-.R-LINE ! -vANGLE !-SECTOR> (: 7VERTEX (SETQ L-LINE L2 R-LINE L1 ANGLE (SUB 180 ANGLE-L1-L2) SECTOR 'SECTOR-L1-L2) (POST) (SETQ L-LINE L3 R-LINE L2 ANGLE (SUB 180 ANGLE-L2-L3) SECTOR * SECTOR-L2-L 3) (POST) (SETQ L-LINE L1 R-LINE L3 ANGLE (SUB (ADD ANGLE-LV-L2 ANGLE-L2-L3) 180) SECTOR * SECTOR-L3-L1) ) ) ;RETURNS THE CWISE SECTOR NAME OF THE ENCLOSING VERTEX ; WHOSE R-LINE IS ?LINE. ;DEFAULT IS FOR 3-LINE VERTICES. (DEFUN CWISE-SECTOR SEXPR (LINE) (COND {(EQ ?LINE L1) »SECTOR-LI-L2) ({EQ ?LINE L2) ' S ECTOR-L2-L3) ( (EQ ?LINE L3) * SECTOR-L3-L 1} {(BREAK ERROR: LINE IS NOT FART OF THIS VERTEX" ?LINE) ) ) ) ;RETURNS THE CCWISE SECTOR NAME WHOSE L-LINE IS ?LINE OF Appendix-C: Example Program L i s t i n g 2 0 3 ; T H E E N C L O S I N G V E R T E X . ( D E F U N C C W I S E - S E C T O R 9 E X P R ( L I N E ) ( C O N D { { E Q ? L I N E L 1 ) ' S E C T O B - L 3 - L 1 ) { { E Q ? L I N E L 2 ) » S E C T O B - L 1 - L 2 ) ( ( E Q ? L I N E L 3 ) ' S E C T O R - L 2 - L 3) { { B R E A K » " * * * E R R O R : L I N E I S N O T P A R T O F T H I S V E R T E X " ? L I N E ) ) ) ) ; R E T U R N S T H E C C W N E X T L I N E O F A N E N C L O S I N G 3 - L I N E V E R T E X . ( D E F U N C C W - L I N E S E X P R ( L I N E ) ( C O N D ( { E Q ? L I N E L 1 ) 1 3 ) ( ( E Q ? L I N E L 2 ) L I ) ( ( E Q ? L I N E L 3 ) 1 2 ) { ( B R E A K » « * * * L I N E I S N O T P A R T O F T H I S V E R T E X " ? L I N E ) ) ) ) ; R E T U R N S T H E C W N E X T L I N E O F A N E N C L O S I N G 3 - L I N E V E R T E X . ( D E F U N C W - I I N E S E X P R ( L I N E ) ( C O N D { { E Q ? L I N E 1 1 ) L 2 ) ( ( E Q ? L I N E L 2 ) L 3 ) ( ( E Q ? L I N E 1 3 ) I I ) { ( B R E A K » « * * * U N E I S N O T P A R T O F T H I S V E R T E X " ? L I N E ) ) ) ) ( D E F U N C I - A N G L E S E X P R ( L I N E ) { C O N D { ( E Q ? L I N E L 1 ) ( S U B 1 8 0 A N G L E - L 1 - L 2 ) ) ( ( E Q 7 L I N E L 2 ) ( S U B 1 8 0 A N G L E - L 2 - L 3 ) } { ( E Q ? L I N E L 3 ) ( S U B ( A D D A N G L E - L 1 - L 2 A N G L E - L 2 - L 3 ) 1 8 0 ) ) { ( B R E A K • « * * * L I N E I S N O T P A R T O F T H I S V E R T E X " ? L I N E ) ) ) ) ( D E F U N C C H - A N G L E S E X P R ( L I N E ) ( C O N D ( ( E Q ? L I N E L 3 ) ( S U B 1 8 0 A N G L E - L 2 - L 3 ) ) ( ( E Q ? L I N E 1 2 ) ( S U B 1 8 0 A N G L E - L 1 - L 2 ) ) ( ( E Q ? L I N E L 1 ) ( S U B { A D D A N G L E - L 2 - L 3 A N G 1 E - I 1 - L 2 ) 1 8 0 ) ) { ( B R E A K ' " * * * L I N E I S N O T P A R T O F T H I S V E R T E X " ? I I N E ) ) ) ) ; E N D O F V E R T E X I - V E R T E X ; G E N E R A T E S S E C T O R S O F A 2 - L I N E V E R T E X . ( D E F U N G E N - S E C T O R S Q E X P R < ! : V E R T E X ! - T L - L I N E I - R - L I N E ! - « A N G 1 E ! - . S E C T O R > ( : 7 V E R T E X { S E T Q 1 - I I N E 1 2 R - I I N E 1 1 A N G L E ( S U B 1 8 0 A N G L E - L 1 - L 2 ) S E C T O R ' S E C T O R - L 1 - L 2 ) ( P O S T ) ( S E T Q L - L I N E L 1 Appendix-C: Example Program L i s t i n g 204 R-IINE L2 ANGLE (SUB ANGLE-L1-L2 180) SECTOR *SECTOR-L2-L1) ) ) ; RETURNS THE CWISE SECTOR NAME WHOSE R-LINE IS 7LINE OF THE ; ENCLOSING VERTEX. ;FOR 2-LINE VERTICES. (DEFUN CWISE-SECTOR SEXPR (LINE) (COND ( (EQ 7LINE L1) »SECTOB-L1-L 2) ( (EQ 7LINE L2) •SECTOB-L2-L1) {(BREAK »"*** EBBOB: LINE IS NOT PABT OF THIS VERTEX" 7LINE) ) ) ) ;RETURNS THE CCWISE SECTOR NAME WHOSE L-LINE IS 7LINE ; OF THE ENCLOSING VERTEX. ;FOR 2-LINE VERTICES. (DEFUN CCWISE-SECTOR 3EXPB (LINE) (COND ((EQ 7LINE L1) »SECTOR-L2-L1) {(EQ 7LINE L2) 'SECTOB-L1-L2) {(BREAK »"*** EBBOR: LINE IS NOT PABT OF THIS VERTEX" 7LINE) ) ) ) ;EETUBNS THE CCW OR CW NEXT LINE OF AN ENCLOSING 2-LINE VERTEX. (DEFUN CW-LINE 3EXPR (LINE) (COND ((EQ 7LINE L1) L2) {(EQ 7LINE L2) L1) {(BBEAK ««*** LINE IS NOT PABT OF THIS VEBTEX" ?LINE)))) {: (PUT* 'CCW-LINE CW-LINE) T) (DEFUN CW—ANGLE 3EXPR (LINE) (COND {(EQ 7LINE L1) (SUB 180 ANGLE-L1-L2) ) {(EQ 7LINE L2) (SUB ANGLE-L1-L2 180)) {(BREAK »"*** LINE IS NOT PART OF THIS VERTEX" 7IINE)))) (DEFUN CCW-ANGLE 3EXPR (LINE) (COND ((EQ 7LINE L2)(SUB 180 ANGLE-L1-L2)) ({EQ 7LINE LI) (SUB ANGLE-L 1-L2 180)) {(BREAK ««*** LINE IS NOT PABT OF THIS VERTEX" 71INE) ) ) ) ) ;END OF L-VERTEX. ; CREATE GIVEN NETWORK OF VERTICES AND LINES. : DEFINES VERTEX OBJECTS AND BINDS THEM TO THEIE NAMES. ; CALLS ARE OF THE FORM: (DEFINE-VEBTEX <NAME> <TYPE> <PAIB>*) (DEFUN DEFINE-VERTEX 3FEXPB (L) {: (PUT* (CAR ?L) (APPLY 'NEW (CDR ?L))) Appendix-C: Example Program L i s t i n g 205 (POT* • NAME (CAR ?L) ) ) (SETQ VERTEX-LIST (NCONC 7VERTEX-LIST (LIST (CAR ? L ) ) ) ) (CAR ?L)) (SETQ VERTEX-LIST NIL) ; DEFINES LINE OBJECTS AND BINDS THEM TO THEIR NAMES. ; CALLS ARE OF THE FORM: (DEFINE-LINE <NAME> <PaiR>*) (DEFUN DEFINE-LINE SFEXPR (L) {• (PUT* (CAR ?L) (aPPLY ' NEW (APPEND* * (LINE) (CDR ?L) ) ) ) (PUT* • NAME (CAR ?L) ) ) (SETQ LINE-LIST (NCONC 7LINE-LIST (LIST (CAR ?L) ) ) ) { CAR ?!))• (SETQ LINE-LIST NIL) ;GENERATES ITEMS FROM A LIST. (DEFUN LGEN QEXPR <!:LIST !-.EL> (MAPC * (LAMBDA (N) (SETQ EL ?N) (POST)) ?LIST) (FAIL)) ; RETURNS THE NEIGHBOR VERTEX OF SOME VERTEX NAME GIVEN A LINE. (DEFUN NEIGHBOR-VERTEX SEXPR (LINE ME) (: (AVAL 7LINE) (COND {(EQ V1 ?ME) (AVAL V2)) ( (EQ V2 ?ME) (AVAL V1) ) ((BREAK *"***ERROR: LINE DOES NOT CONTAIN THIS VERTEX" 7ME)) ) ) ) ; RETURNS EPSILON IF THE ABSOLUTE SUM OF ITS 1ST ARG IS LESS THAN ; ITS 2ND THRU LAST ARG ELSE IT RETURNS NIL. ; CALLS ARE OF THE FORM: (EPSILON <EPS> <NUM>*) (DEFUN EPSILON N (PROG (TALLY) (SETQ TALLY 0) LOOP (COND ( (NEQ N 1) (SETQ TALLY (ADD TALLY (ARG N) ) N (SUB 1 N) ) (GO LOOP)) ({LESSP (ABS TALLY) (ARG 1)) TALLY)))) ;PRINTS COMMENTARY. (DEFUN COMMENTARY 8FEXPR (LCOM) (OR 7CGMMENTARY-SWITCH (RETURN NIL * COMMENTARY)) (TERPRI) (MAPC * (LAMEDA (COM){PRIN1 (AVAL ?COM) ) ) 7LCOM) (TERPRI)) (SETQ COMMENTARY-SWITCH T) Appendix-C: Example Program L i s t i n g 206 ; DATA FOE THIS PROBLEM: {DEFINE-VERTEX VERTEX-1 AEROl-VERTIX L1 'LINE-1-5 12 •LINE-1-6 L3 'LINE- 1-2 ANGLE-L1-L2 60 ANGLE-L2-L3 45) {DEFINE-VEBTEX VERTEX-2 L-VEBTEX L1 'LIflE-1-2 L2 *LINE-2-3 ANGLE-11-L2 135) {DEFINE-VERTEX VERTEX-3 ARROW-VERTEX 11 «LINE-2-3 L2 *LINE-3-6 13 'LINE-3-4 ANGLE-L1-L2 45 ANGLE-L2-L3 30) (DEFINE-VERTEX VERTEX-4 ARROW-VERTEX L1 'LINE-3-4 12 'LINE-4-6 L3 'LINE-4-5 ANGLE-L1-L2 40 ANGLE-L2—L3 60) (DEFINE-VERTEX VERTEX-5 L-VERTEX 11 'LINE-4-5 12 'LINE-1-5 ANGLE-11-L2 120) (DEFINE-VEBTEX VEBTEX-6 FORK-VERTEX 11 'LINE-1-6 L2 'LINE-4-6 L3 'LINE-3-6 ANGLE-L1-L2 120 A NGLE-L2-L3 110) {DEFINE-LINE LINE-1-5 V1 * VERTEX-1 V2 'VERTEX-5 LENGTH 28) Appendix-C: Example Program L i s t i n g 207 <DEFINE-LINE LINE-1-2 V1 'VERTEX-1 V2 'VERTEX-2 LENGTH 35) (DEFINE-LINE LINE-2-3 V1 •VEETEX-2 V2 'VERTEX-3 LENGTH 26) (DEFINE-IINE LINE-3-4 V1 'VERTEX-3 V2 'VERTEX-4 LENGTH 52) (DEFINE-LINE LINE-4-5 V1 'VERTEX-4 V2 * VERTEX-5 LENGTH 25) (DEFINE-LINE LINE-4-6 V1 'VERTEX-4 V2 •VERTEX-6 LENGTH 28) (DEFINE-LINE LINE-3-6 V1 'VERTEX-3 V2 'VEETEX-6 LENGTH 35) (DEFINE-LINE LINE-1-6 V1 'VERTEX-1 V2 'VERTEX-6 LENGTH 25) ; END OF DATA. Appendix-C: Example Program L i s t i n 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-0051790/manifest

Comment

Related Items