Professional Documents
Culture Documents
Planner
Planner
Carl Hewitt
P r o j e c t MAC - Massachuse s I n s t i t u t e o f T e c h n o l o g y
Summary
PLANNER i s a l a n g u a g e f o r p r o v i n g t h e o r e m s
and m a n i p u l a t i n g m o d e l s i n a r o b o t .
The
l a n g u a g e i s b u i l t o u t o f a number o f p r o b l e m
solving p r i m i t i v e s together with a h i e r a r c h i c a l
control structure.
S t a t e m e n t s can b e a s s e r t e d
and p e r h a p s l a t e r w i t h d r a w n a s t h e s t a t e o f t h e
w o r l d changes.
C o n c l u s i o n s can be drawn f r o m
t h e s e v a r i o u s changes i n s t a t e .
G o a l s can b e
e s t a b l i s h e d and d i s m i s s e d when t h e y a r e
satisfied.
The d e d u c t i v e s y s t e m o f PLANNER i s
subordinate to the h i e r a r c h i c a l c o n t r o l
s t r u c t u r e i n o r d e r t o make t h e l a n g u a g e
efficient.
The use o f a g e n e r a l p u r p o s e m a t c h i n g
l a n g u a g e makes t h e d e d u c t i v e system more p o w e r f u l .
Preface
PLANNER i s a l a n g u a g e f o r p r o v i n g t h e o r e m s
and m a n i p u l a t i n g m o d e l s i n a r o b o t .
Although
we say t h a t PLANNER is a p r o g r a m m i n g l a n g u a g e ,
w e d o n o t mean t o i m p l y t h a t i t i s a p u r e l y
p r o c e d u r a l l a n g u a g e l i k e t h e lambda c a l c u l u s i n
pure LISP.
PLANNER i s d i f f e r e n t f r o m p u r e L I S P
i n t h a t f u n c t i o n c a l l s can b e made i n d i r e c t l y
t h r o u g h recommendations s p e c i f y i n g t h e form o f
t h e d a t a o n w h i c h t h e f u n c t i o n i s supposed t o
work.
I n such a c a l l t h e a c t u a l name o f t h e
c a l l e d f u n c t i o n i s u s u a l l y unknown.
Many o f
t h e p r i m i t i v e s i n PLANNER a r e c o n c e r n e d w i t h
m a n i p u l a t i n g a data base.
The l a n g u a g e w i l l
be explained by g i v i n g an o v e r - s i m p l i f i e d p i c t u r e and t h e n a t t e m p t i n g t o c o r r e c t any
m i s a p p r e h e n s i o n s t h a t t h e r e a d e r m i g h t have
gathered from the rough o u t l i n e .
The b a s i c
i d e a behind the language is a d u a l i t y t h a t we
f i n d b e t w e e n c e r t a i n i m p e r a t i v e and d e c l a r a t i v e
sentences.
F o r example c o n s i d e r t h e s t a t e m e n t
(implies a b).
As it stands the statement is
a p e r f e c t l y good d e c l a r a t i v e s t a t e m e n t .
It
a l s o has c e r t a i n i m p e r a t i v e uses f o r PLANNER.
F o r example i t says t h a t w e s h o u l d s e t u p a
procedure w h i c h w i l l n o t e whether a i s ever
a s s e r t e d and i f s o t o c o n s i d e r w h e t h e r b s h o u l d
then be asserted.
F u r t h e r m o r e i t says t h a t
we should set up a procedure t h a t w i l l watch
t o see i f i t e v e r i s o u r g o a l t o t r y t o deduce
b and i f s o w h e t h e r i t i s w i s e t o make a s u b g o a l
t o deduce a .
S i m i l a r o b s e r v a t i o n s c a n b e made
about the c o n t r a p o s i t i v e of the statement
(implies a b).
Statements w i t h u n i v e r s a l
quantifiers, conjunctions, disjunctions, etc.
a l s o h a v e b o t h d e c l a r a t i v e and i m p e r a t i v e u s e s .
O f c o u r s e i f what w e have d e s c r i b e d t h u s f a r
w e r e a l l t h e r e was t o t h e l a n g u a g e , t h e n t h e r e
would be no p o i n t .
From t h e above o b s e r v a t i o n s ,
we have c o n s t r u c t e d a language t h a t p e r m i t s
b o t h t h e i m p e r a t i v e and d e c l a r a t i v e a s p e c t s o f
statements to be e a s i l y manipulated.
PLANNER uses a p a t t e r n d i r e c t e d i n f o r m a t i o n
r e t r i e v a l s y s t e m t h a t i s more p o w e r f u l t h a n a
r e t r i e v a l s y s t e m based d i r e c t l y o n a s s o c i a t i o n
lists.
The l a n g u a g e p e r m i t s u s t o s e t u p
p r o c e d u r e s w h i c h w i l l make a s s e r t i o n s and
a u t o m a t i c a l l y draw c o n c l u s i o n s f r o m o t h e r
assertions.
P r o c e d u r e s can make r e c o m m e n d a t i o n s
a s t o w h i c h t h e o r e m s s h o u l d b e used i n t r y i n g
t o draw c o n c l u s i o n s f r o m a n a s s e r t i o n , and
t h e y c a n recommend t h e o r d e r i n w h i c h t h e
theorems should be a p p l i e d .
Goals can be
c r e a t e d and a u t o m a t i c a l l y d i s m i s s e d when t h e y
are s a t i s f i e d .
O b j e c t s can b e f o u n d f r o m
schematic o r p a r t i a l d e s c r i p t i o n s .
Properly
f o r m u l a t e d d e s c r i p t i o n s have t h e i r own
i m p e r a t i v e uses f o r t h e l a n g u a g e .
Provision
i s made f o r t h e f a c t t h a t s t a t e m e n t s t h a t w e r e
once t r u e i n a model may n o l o n g e r b e t r u e a t
some l a t e r t i m e and t h a t consequences must b e
d r a w n f r o m t h e f a c t t h a t t h e s t a t e o f t h e model
has c h a n g e d .
A s s e r t i o n s and g o a l s c r e a t e d
w i t h i n a p r o c e d u r e can b e d y n a m i c a l l y p r o t e c t e d
a g a i n s t i n t e r f e r e n c e from other procedures.
Procedures w r i t t e n i n t h e language a r e e x t e n d a b l e
i n t h a t t h e y can make use o f new k n o w l e d g e
whether i t b e p r i m a r i l y d e c l a r a t i v e o r i m p e r a t i v e
in nature.
The l o g i c a l d e d u c t i v e system used
b y PLANNER i s s u b o r d i n a t e t o t h e h i e r a r c h i c a l
c o n t r o l s t r u c t u r e of the language.
PLANNER has
a s o p h i s t i c a t e d d e d u c t i v e system i n o r d e r t o
g i v e u s g r e a t e r power o v e r t h e d i r e c t i o n o f
the computation.
In several respects the
d e d u c t i v e system i s more p o w e r f u l t h a n t h e
q u a n t i f i c a t i o n a l c a l c u l u s o f o r d e r omega.
Our
c r i t e r i a f o r a n i d e a l d e d u c t i v e system c o n t r a s t
w i t h t h o s e t h a t a r e used t o j u s t i f y r e s o l u t i o n
based s y s t e m s .
Having only a s i n g l e r u l e of
inference, resolution provides a very
parsimonious l o g i c a l system.
W o r k e r s who b u i l d
r e s o l u t i o n systems hope t h a t t h e i r systems can
b e made e f f i c i e n t t h r o u g h a c u t e m a t h e m a t i c a l
a n a l y s i s o f the simple s t r u c t u r e o f t h e i r
d e d u c t i v e system.
We have t r i e d to d e s i g n a
s o p h i s t i c a t e d d e d u c t i v e system t o g e t h e r w i t h
an elaborate c o n t r o l s t r u c t u r e so that lengthy
c o m p u t a t i o n s can b e c a r r i e d o u t w i t h o u t b l o w i n g
up.
O f c o u r s e t h e c o n t r o l s t r u c t u r e can s t i l l
b e used when w e l i m i t o u r s e l v e s t o u s i n g r e s o l u t i o n as the sole r u l e of i n f e r e n c e .
Indeed,
R . B u r s t a l l has s u g g e s t e d t h a t w e m i g h t t r y t o
i m p l e m e n t some o f t h e w e l l known r e s o l u t i o n
s t r a t e g i e s i n PLANNER.
Because o f i t s e x t r e m e
h i e r a r c h i c a l c o n t r o l and i t s a b i l i t y t o make use
o f new i m p e r a t i v e a s w e l l a s d e c l a r a t i v e
knowledge, i t i s f e a s i b l e t o c a r r y out very long
c h a i n s o f i n f e r e n c e i n PLANNER.
MATCHLESS
MATCHLESS i s a p a t t e r n d i r e c t e d p r o g r a m m i n g
l a n g u a g e t h a t i s used i n t h e i m p l e m e n t a t i o n o f
PLANNER.
MATCHLESS i s used b o t h i n t h e i n t e r n a l
w o r k i n g s o f PLANNER and a s a t o o l i n t h e
d e d u c t i v e system i t s e l f .
The most i m p o r t a n t
f u n c t i o n i n MATCHLESS i s a s s i g n ? w h i c h m a t c h e s
i t s f i r s t argument w h i c h i s t r e a t e d a s a p a t t e r n
t o i t s second a r g u m e n t .
The r e a s o n why t h e
a s s i g n m e n t f u n c t i o n i n MATCHLESS i s c a l l e d
a s s i g n ? w i l l b e e x p l a i n e d l a t e r when w e d i s c u s s
f u n c t i o n s t h a t have v a l u e s .
The p r e f i x
operator $_ indicates that the v a r i a b l e which
follows it is to be assigned a value.
The
v a r i o u s t y p e s f o r v a r i a b l e s and t h e i r a b b r e viations are;
p t r f o r p o i n t e r , atom f o r a t o m ,
seg f o r s e g m e n t , f i x f o r f i x e d p o i n t n u m b e r ,
f l o a t f o r f l o a t i n g p o i n t n u m b e r , and e x p r f o r
s-expression.
A segment v a r i a b l e i s a l w a y s
assigned the smallest p o s s i b l e leftmost segment.
B e l o w w e g i v e some e x a m p l e s o f t h e
values o f p a t t e r n v a r i a b l e s a f t e r assignment
s t a t e m e n t s have been e x e c u t e d .
We use t h e
c h a r a c t e r - to d e l i m i t segments.
The c h a r a c t e r s
{ and } a r e u s e d t o d e l i m i t f u n c t i o n c a l l s .
{ p r o g ( ( a p t r ) ( h atom) ( c seg))
{ a s s i g n ? ( $ _ a k $_h $_c) ( ( 1 ) k b 1 a ) } }
a gets the value (1)
h gets the value b
c gets the value -1 a-
f a i l s because
(a^>J)}}
{ p r o g ( ( x seg) ( c s e g ) )
{assign? ($_x<disj(3) (2)>$_c) (a,1,2,3,}}
x gets the value -a 1c gets the value - 3 -
there
{prog ((x p t r ) )
{ a s s i g n ? ( < s t a r a > $_x)
x gets the value a
(1 2)
(a a a a ) } ]
P a t t e r n f u n c t i o n s d o not produce v a l u e s .
It
does n o t make any sense t o e v a l u a t e
{ a s s i g n ? < d i s j ( 3 ) ( 2 ) > ( 2 ) } s i n c e a segment
l i k e < d s j (3) (2) > i s never allowed t o stand
alone.
There is a l i b r a r y of p a t t e r n f u n c t i o n s
already defined in the language.
For example
" is quote.
Thus { " s s a ] w i l l o n l y m a t c h $ $ a .
a palindrome is defined to be a l i s t t h a t reads
t h e same b a c k w a r d s and f o r w a r d s .
Thus
(a ( b ) ( b ) a ) , ( ) , and ( ( a b ) (a b ) ) a r e
palindromes.
More f o r m a l l y i n MATCHLESS, a
palindrome can be d e f i n e d as a p a t t e r n f u n c t i o n
of no arguments:
An expression t h a t c o n s i s t s of the p r e f i x
operator $$ followed by a v a r i a b l e w i l l only
match an o b j e c t equal to t h e v a l u e of t h e
variable.
{prog ( ( a seg))
{ a s s i g n ? ($_a$$a) (1,2,3,1,2,3)}}
a gets the value - 1 2 3{ p r o g ( ( a seg) ( b
[ a s s i g n ? ($_a x
a gets the value
b gets the value
{prog ( ( ( a 5) p t r ) )
{ a s s i g n ? $?a 4 ) )
a is i n i t i a l i z e d to 5 on entrance to the
prog.
Consequently t h e assignment statement
fails.
{ p r o g ( ( f i r s t p t r ) ( m i d d l e seg) ( l a s t p t r ) )
{ a s s i g n ? ( $ _ f i r s t $ _ m i d d l e $ _ l a s t ) (1,2,3,4)}}
f i r s t gets the value 1
middle gets the value -2 3last gets the value 4
{prog ((a p t r ) )
{ a s s i g n ? $?a 3 } ]
a gets the value 3
Examples o f p a t t e r n f u n c t i o n s a r e d i s j
d i s j u n c t i o n , neg f o r n e g a t i o n , c o n j f o r
c o n j u n c t i o n , and s t a r f o r K l e e n e s t a r i n
general regular expressions.
We use t h e
c h a r a c t e r s < and > t o d e l i m i t p a t t e r n
expressions t h a t are to be i n t e r p r e t e d as
segments.
{ p r o g ( ( c seg) ( h a t o m ) ( a p t r ) )
{ a s s i g n ? ( $ _ c $_h k $_a) ( a l b k q ) ) )
c gets the value -a 1h gets the value b
a gets the value q
{prog ((a p t r ) (b p t r ) )
{ a s s i g n ? ($_^$_b) (d) } } f a i l s because
i s o n l y one e l e m e n t i n ( d ) .
seg))
$$a $ - b ) ( a b x d x a b x d q ) } }
-a b x d-q-
-296-
(def palindrome
(kappa ( ( ) )
{disj
{block ( ( x p t r ) )
($_x<palindrome>$$x)}]))
(UJ
{block ( ( f i r s t - o f - x p t r ) ( r e s t - o f - x seg))
{assign? ( $ _ f i r s t - o f - x $ r e s t - o f - x ) $ $ x }
(reverse ($$rest-of-x)>$$first-of-x) ]) }))
-297-
{ { " temporary-assert}
$_statement
{recommendation}) i s l i k e assert except t h a t
$$statement w i l l b e withdrawn i f e v e r y t h i n g
works o u t .
In other words, $$statement is a
temporary r e s u l t t h a t w i l l go away a f t e r we
solve our c u r r e n t problem.
{recommendation})
where
(def recommendation
(disj
(kappa ( ( ) )
0
?
{ { " f o r - p r o v e d } $ _ d e c l a r a t i o n $__pattern
$__body) where body is of type seg w i l l attempt
to excecute $$body once f o r every proved s t a t e ment t h a t matches the p a t t e r n $ p a t t e r n .
{ { " proveable} $_pattern { g o a l recommendation}} w i l l r e t u r n a s i t s value a l i s t
whose f i r s t element is the number of remaining
elements in the l i s t and such t h a t the remaining
elements of the l i s t are the proveable statements
t h a t match the p a t t e r n $$pattern and can be
proved using the recommendation.
Note t h a t if
t h e r e are an i n f i n i t e number of proveable s t a t e ments t h a t match the p a t t e r n $ $ p a t t e r n then the
-298-
{ { " t h f i n a l i z e } } causes a l l a c t i o n s t h a t
have been taken in the current theorem to be
finalized.
A goal-recommendation of ( f i r s t $_theoremlist)
means t h a t the theorems on $$theoremlist are the
f i r s t to be used to t r y to achieve the goal which
is the value of $$statement. On the other hand
a goal recommendation of (only $_theoremlist)
means t h a t the theorems on $$theoremlist in the
order given are the only ones to be used to t r y
to achieve the g o a l . The f i r s t t h i n g t h a t the
f u n c t i o n goal does is to evaluate {proved?
$$statement}.
If the e v a l u a t i o n produces a
f a i l u r e then the goal recommendation is followed
to t r y to f i n d a theorem t h a t can e s t a b l i s h
$$statement.
{ { " t h o r } $ _ d i s j u n c t s } where d i s j u n c t s i s
of type seg is l i k e the LISP f u n c t i o n o r .
(subset a b)
(subset a d)
(subset b c)
( d e f t h backward
(consequent ( ( ( x p t r ) ( z p t r ) ) )
(subset $?x $?z)
{thprog ( ( y p t r ) )
{ g o a l (subset $?x $?y) ( f i r s t backward)}
{goal (subset $$y $?z) (only backward)}
{aasert-consequent}}))
b),
(x y z)
(subset
to
give
fail.
f o l l o w i n g theorem:
(consequent ( ( ( a p t r ) ( c p t r ) ) )
subset $?a $?c)
thprog ( ( b p t r ) )
goal (subset $?a $?b))
goal (subset $$b $?c)J
{assert-consequent ? } } )
The above theorem is the c o n s t r u c t i v e analogue
f o r ( f o r - a l l (a b c) ( i m p l i e s (and (subset a b)
(subset b e ) ) (subset a c ) ) . One way in which
the theorem can be e s t a b l i s h e d is by showing
t h a t the e v a l u a t i o n o f the f o l l o w i n g expression
w i l l not r e s u l t i n a f a i l u r e :
{thprog
(((a {arbitrary}) ptr)
((b { a r b i t r a r y ] ) ptr)
((c {arbitrary}) ptr)
a s s e r t (subset $$a $$b)}
a s s e r t (subset $$b $$c)}
{ g o a l (subset $$a $$c)}J
The above example shows how it is sometimes
convenient f o r PLANNER to regard the statement
of a theorem simply as an a b b r e v i a t i o n f o r the
proof of the theorem. We would l i k e to be able
to prove PLANNER theorems w i t h loops in them.
I n order t o d o t h i s i t i s necessary t o know
the i n t e n t i o n s o f the i n t e r n a l s t r u c t u r e o f the
theorem.
Conclusion
Acknowledgements
-301-