You are on page 1of 8

345

A PROGRAMMING LANGUAGE

Kenneth E. Iverson
Research Division, IBM Corporation
Yorktown Heights, New York

The p a p e r d e s c r i b e s a succinct p r o b l e m - o r i e n t e d p r o g r a m m i n g language.


The language is b r o a d in scope, having been developed for, and applied
6j.j.sctrvsly m, suc.n d i v e r s e a r e a s as m i c r o p r o g r a m m i n g , s w i t c u m g t n e o r y ,
o p e r a t i o n s r e s e a r c h , information r e t r i e v a l , s o r t i n g t h e o r y , s t r u c t u r e of
c o m p i l e r s , s e a r c h p r o c e d u r e s , and language t r a n s l a t i o n . The language
p e r m i t s a high d e g r e e of useful f o r m a l i s m . It r e l i e s heavily on a s y s t e -
m a t i c extension of a s m a l l set of b a s i c o p e r a t i o n s to v e c t o r s , m a t r i c e s ,
and t r e e s , and on a family of flexible s e l e c t i o n o p e r a t i o n s c o n t r o l l e d by
logical v e c t o r s . I l l u s t r a t i o n s a r e d r a w n from a v a r i e t y of a p p l i c a t i o n s .

The p r o g r a m m i n g language outlined h e r e entities ( e . g . , n u m e r a l s , alphabetic l i t e r a l s , o r


has been designed for the succinct d e s c r i p t i o n of logical v a r i a b l e s ) and R is any r e l a t i o n defined
a l g o r i t h m s . The intended range of a l g o r i t h m s is upon t h e m , then ( x R y ) is equal to 1 o r 0 a c -
b r o a d ; effective applications include m i c r o p r o - cording to w h e t h e r the r e l a t i o n R does o r does not
g r a m m i n g , switching t h e o r y , o p e r a t i o n s r e s e a r c h hold between x and y. Thus ( i = j) is the f a m i l i a r
information r e t r i e v a l , s o r t i n g t h e o r y , s t r u c t u r e K r o n e c k e r delta 6jj, (u/v) is the exclusive or
of c o m p i l e r s , s e a r c h p r o c e d u r e s , and language function of the logical v a r i a b l e s u and v, and
t r a n s l a t i o n . The symbols used have been c h o s e n
sgn x = (x > 0) - (x < 0)
so as to be concise and m n e m o n i c , and t h e i r
choice has not been r e s t r i c t e d to the c h a r a c t e r is the f a m i l i a r sign function, defined as +1, 0, o r
s e t s provided in c o n t e m p o r a r y p r i n t e r s and c o m - -1 a c c o r d i n g as x is s t r i c t l y positive, z e r o , o r
p u t e r s . A high d e g r e e of f o r m a l i s m is p r o v i d e d . strictly negative.

Basic O p e r a t i o n s V e c t o r s and M a t r i c e s

The language is b as ed on a consistent u n i - A v e c t o r is denoted by an underlined l o w e r -


fication and extension of existing m a t h e m a t i c a l c a s e l e t t e r ( e . g . , x_), its i-th component by x . ,
notations, and upon a s y s t e m a t i c extension of a and its d i m e n s i o n by v(x_). A m a t r i x is denoted"
s m a l l set of b a s i c a r i t h m e t i c and logical o p e r a - by an underlined u p p e r c a s e l e t t e r ( e . g . , X), its
tions to v e c t o r s , m a t r i c e s , and t r e e s . The i-th row by X1, its j - t h column by X;, its ij-th
a r i t h m e t i c o p e r a t i o n s include the four f a m i l i a r element by X-^, its row d i m e n s i o n ( i . e . , the
a r i t h m e t i c o p e r a t i o n s and the absolute value c o m m o n d i m e n s i o n of its row v e c t o r s ) by v(X),
(denoted by the usual symbols) as well as the and its column d i m e n s i o n by p.(X).
floor, ceiling, and r e s i d u e functions denoted and
defined as follows: All of the b a s i c o p e r a t i o n s a r e extended
c o m p o n e n t - b y - c o m p o n e n t to v e c t o r s and m a t r i c e s .
Name Symbol Definition Thus,

floor [xj [_xj < x < [ x j +1 z . = x . + y.


—l —l -*"i
ceiling fx"| JVJ > x > fx"J -1
z\ = X ? X Y !
residue m o d m m|n n=mq + m|n;0< m|n<m, -J - J -3

where j_xj, ("x"], m, n, and q a r e i n t e g e r s . W = U_ A V < = > W . = U_. A V . ,

The logical operations and, or, and not a r e w = (x < y) <i—> w . = (x . < y.)
— — -*• — l — l - ^ l
defined upon the logical v a r i a b l e s 0 and 1 and a r e
denoted by A> V I a n d an o v e r b a r . They a r e a u g - The symbol _^ (n) will denote a logical v e c -
mented by the r e l a t i o n a l s t a t e m e n t (proposition) t o r of d i m e n s i o n n whose components a r e all unity,
(xRy) defined as follows. If x and y a r e any and e(n) t h e r e f o r e denotes the z e r o v e c t o r . The
346 PROGRAMMING AND CODING

d i m e n s i o n n w i l l b e e l i d e d w h e n e v e r it i s c l e a r (A B)* = +/(A1X B . ) .
from context.
A d o p t i n g t h e n o t a t i o n A. x B f o r t h i s p r o d u c t m a k e s
T h e c y c l i c left s h i f t of a v e c t o r x_ i s c a l l e d e x p l i c i t t h e r o l e s of t h e b a s i c o p e r a t i o n s + a n d X ,
left r o t a t i o n . It i s d e n o t e d by k f x a n d d e f i n e d and s u g g e s t s the following useful g e n e r a l i z a t i o n :
by t h e r e l a t i o n : 0i
An B = ©l/fA1© B.) ,
2= (kf x ) 4 = > 2- ~ %• '
w h e r e ©1 and O a r e any o p e r a t o r s or r e l a t i o n s
w h e r e j = 1 + v ( x ) | (i + k - 1 ) . R i g h t r o t a t i o n
with suitable d o m a i n s .
i s d e n o t e d by k 1 x and i s defined a n a l o g o u s l y .
Thus C = M = X is an "incidence m a t r i x "
Reduction
such that CI = 1 if and only if M 1 and X. a g r e e in
all c o m p o n e n t s . If M is the m e m o r y o r a binary .
F o r e a c h b a s i c b i n a r y o p e r a t o r O , t h e CD-
c o m p u t e r (i. e . , M is a logical m a t r i x and row M
r e d u c t i o n of a v e c t o r JC i s d e n o t e d b y 0 / x _ a n d
is the i - t h w o r d of m e m o r y ) , and if x is an
defined by
" a r g u m e n t r e g i s t e r " , then (treating x as a o n e -
©/x = ( • • • ( ( x 1 0 x 2 ) 0 x3) ©•••© x ). column m a t r i x )
s = M A x
T h u s -t-/x_ i s t h e s u m , a n d X/x_ i s t h e p r o d u c t of
a l l c o m p o n e n t s of x . M o r e o v e r , if u_= ( 1 , 0, 1), defines the s e n s e v e c t o r s of an a s s o c i a t i v e
t h e n +/u_= 2, + / i i = 1, A / U _ = 0, a n d V/u_= 1 . m e m o r y such that s . = 1 if and only if word M
. , —i —
a g r e e s with x.
Reduction is extended to m a t r i c e s r o w - b y -
row: As f u r t h e r e x a m p l e s , R = P > Q gives the
1 n u m b e r of p l a c e s in which a component of P e x -
z_ = © / X < = > _ z . = O / X ,
ceeds the c o r r e s p o n d i n g component of Q . , and
and c o l u m n - b y - c o l u m n : K = P > Q is a " c o v e r i n g m a t r i x " which indicates
which rows of P c o v e r (exceed in e v e r y component)
z_ = 0 / / X -£=> z_. = © / X . ,
which rows of Q.
t h e c o l u m n r e d u c t i o n b e i n g d i s t i n g u i s h e d by t h e
double s l a s h . De M o r g a n ' s law and the identity

F o r e x a m p l e , if u_= ( u . , u_ ) i s a l o g i c a l
4/u= I?u
v e c t o r of d i m e n s i o n t w o , t h e n De M o r g a n ' s l a w e s t a b l i s h a duality with r e s p e c t to negation b e -
m a y be e x p r e s s e d a s : tween A and v , and between 4 a n d =. This
duality is e a s i l y extended to m a t r i c e s . F o r
A/U = v/vf .
example,
M o r e o v e r , t h i s i s t h e v a l i d g e n e r a l i z a t i o n of
A A B = AJ B .
D e M o r g a n ' s l a w t o a v e c t o r u of a r b i t r a r y
dimension.
Selection
The reduction o p e r a t i o n can be extended to
The f o r m a t i o n of a v e c t o r 2 from a v e c t o r
a n y r e l a t i o n R by s u b s t i t u t i n g R f o r O i n t h e f o r -
x_ by deleting c e r t a i n components of x will be
m a l definition above. The p a r e n t h e s e s in the
denoted by
definition now signify r e l a t i o n a l s t a t e m e n t s as
well as grouping, and thus the e x p r e s s i o n //u_ 2 - ii/x »
d e n o t e s t h e a p p l i c a t i o n of t h e e x c l u s i v e - o r o v e r
w h e r e u is a logical v e c t o r (of d i m e n s i o n v(x) and
a l l c o m p o n e n t s of t h e l o g i c a l v e c t o r u . For
x . is deleted if and only if u_. = 0. Thus u / x and
e x a m p l e , / / ( l , 0, 1) = ((1 4 0) 4 1) = (1 4 1) = 0 .
Induction c a n be u s e d to show that
]I/x_ provide a d i s j o i n t decomposition of x , and
(x_ >£_) / x is the v e c t o r of all s t r i c t l y positive
4 / u = 2 |+/u , and = / u = 2 | +/u_ . components of x_.
Hence, / / u = = / u , a useful c o m p a n i o n to
The o p e r a t i o n u_/x_ is called c o m p r e s s i o n
De M o r g a n ' s l a w .
and is extended to m a t r i c e s by row and by column
as follows:
Matrix Product
Z = u/X <=> Z1 = u / x 1 ,
The conventional m a t r i x product A B may
Z= u//X <=> Z. = u / X . .
be defined a s :
A PROGRAMMING LANGUAGE 347

The familiar identity concerning partitioned Mixed Base Value


m a t r i c e s c a n now be g e n e r a l i z e d a s follows:
If t h e c o m p o n e n t s of t h e v e c t o r _v_ s p e c i f y t h e
X $ Y = (u/X) $ (u//Y) + (u/X) i (u//Y). r a d i c e s of a m i x e d b a s e n u m b e r s y s t e m a n d if x
i s a n y n u m e r i c a l v e c t o r of t h e s a m e d i m e n s i o n ,
Since t h e identity depends only on the a s s o c i a t i v i t y t h e n t h e v a l u e of x_ i n t h a t n u m b e r s y s t e m i s
a n d c o m m u t a t i v i t y of t h e o p e r a t o r s + a n d X , it c a l l e d t h e b a s e y v a l u e of x , i s d e n o t e d b y y I x ,
holds also for all o p e r a t o r s (and relations) p o s - and i s defined f o r m a l l y by
sessing these properties. Moreover,
y__L x = _w x x ,
u / ( X $ Y) = X $ (u/Y),
w h e r e w is the weighting v e c t o r defined by
and
w = 1 and w. , = w. v V.. F o r e x a m p l e , if
u / / ( x h ) = (U//X) X Y. —v(w) —l-l — I - ^ I ^
y = (24, 60, 60) and if x = ( 1 , 2 , 5) is the e l a p s e d
T o i l l u s t r a t e o t h e r u s e s of c o m p r e s s i o n , t i m e in h o u r s , m i n u t e s , and s e c o n d s , t h e n
consider a bank ledger L so a r r a n g e d that L 1 _y_ _|_ x_ = 3725 is the e l a p s e d t i m e in s e c o n d s .
r e p r e s e n t s the i-th account, and L^, L ? , and L ,
The value of x i n a d e c i m a l s y s t e m is d e -
r e p r e s e n t t h e v e c t o r - o f n a m e s , of a c c o u n t n u m -
noted by (1 0 e j J_ x_, and in a b i n a r y s y s t e m by
b e r s , a n d of b a l a n c e s , r e s p e c t i v e l y . T h e n t h e
e i t h e r (2 e_) _j_ x_, o r _J_ x_. M o r e o v e r , if y is any
p r e p a r a t i o n of a l i s t P (in t h e s a m e f o r m a t ) of a l l
r e a l n u m b e r , t h e n (y e j j ^ x_ d e n o t e s the p o l y -
accounts having a balance less than two dollars is
n o m i a l in y with coefficients x .
d e s c r i b e d by t h e s t a t e m e n t :

Application to M i c r o p r o g r a m m i n g
P - (L_ 3 < 2 « _ ) / / L ,

To i l l u s t r a t e the u s e of the notation in d e -


w h e r e t h e a r r o w d e n o t e s s p e c i f i c a t i o n (in t h e
s c r i b i n g the o p e r a t i o n of a c o m p u t e r , c o n s i d e r the
s e n s e of t h e s y m b o l = i n F o r t r a n a n d t h e s y m b o l
IBM 7090 with a m e m o r y M of d i m e n s i o n 2 *X 36,
:= i n A l g o l ) .
a c o m m a n d v e c t o r c_ of d i m e n s i o n 36 r e p r e s e n t i n g
the i n s t r u c t i o n next to be e x e c u t e d , a s e q u e n c e
T h r e e useful operations c o n v e r s e to c o m -
v e c t o r s_ of d i m e n s i o n 15 r e p r e s e n t i n g the i n s t r u c -
p r e s s i o n a r e defined a s follows:
tion c o u n t e r , and a 3 x 1 5 index m a t r i x I r e p r e -
senting the t h r e e index r e g i s t e r s . The i n s t r u c t i o n
M e s h : z_ = \ a _ , u_, b_\<=> "u/z_= a_; u/z_ = b_
fetch p h a s e of o p e r a t i o n (excluding the channel
t r a p ) c a n t h e n be d e s c r i b e d a s in F i g u r e 1. 0 -
M a s k : z_ = /a_, u_, b_ /<$> ^_/^_- " u / a ; u / z = u / b o r i g i n indexing will be u s e d for a l l v e c t o r s and
matrices.
Expansion: z = u\ b <$=> z_ = \ e _ , u , b \ .
—? c — M-L -
They m a y be e x t e n d e d to m a t r i c e s in the e s t a b -
l i s h e d m a n n e r a n d a r e r e l a t e d by t h e o b v i o u s J_ s. — 2 1 5 | (1 + J_ a)
identities:
a —k (c) A c_ A c.
\a_, u , b_\ = /ji\a_, u_, u\— / ,
k 2 (c_) : 0 <
A , u, b / = Vi/a.. u.» H./k\ *
_t_— (18 1 Q 3 ) / C

l<,l5/c-215Klcol5/c.-l(tXl))
In a d d i t i o n t o t h e f u l l v e c t o r e_(n) a l r e a d y
d e f i n e d , it i s c o n v e n i e n t t o d e f i n e t h e p r e f i x 3 a : 0 • = - >

v e c t o r a_J (n) a s a l o g i c a l v e c t o r of d i m e n s i o n n 15
18/ 1 8 W J| u /c
w h o s e f i r s t j c o m p o n e n t s a r e u n i t y . T h e suffix w / c — CJ / /M —
v e c t o r coJ (n) i s d e f i n e d a n a l o g o u s l y . A n i n f i x
a — 0
v e c t o r h a v i n g i l e a d i n g O's f o l l o w e d by j l ' s c a n
be d e n o t e d by i j a ^ . W h e n u s e d in c o m p r e s s i o n
I n s t r u c t i o n F e t c h of IBM 7090
operations, these special v e c t o r s a r e very useful
in specifying fixed f o r m a t s . Figure 1
348 PROGRAMMING AND CODING

15
S t e p 1 s h o w s t h e s e l e c t i o n of t h e n e x t i n - t h e i n s t r u c t i o n c, r e d u c i n g t h e r e s u l t m o d u l o 2 ,
s t r u c t i o n f r o m t h e m e m o r y w o r d s p e c i f i e d by t h e a n d r e s p e c i f y i n g t h e a d d r e s s p o r t i o n of c_
i n s t r u c t i o n c o u n t e r s_ a n d i t s t r a n s f e r t o t h e accordingly.
c o m m a n d r e g i s t e r c_. S t e p 2 s h o w s t h e i n c r e -
m e n t a t i o n ( r e d u c e d m o d u l o 2 ) of t h e c o u n t e r s , The fetch t e r m i n a t e s i m m e d i a t e l y from
T h e l o g i c a l f u n c t i o n k (c_) of s t e p 3 d e t e r m i n e s s t e p 7 if no i n d i r e c t a d d r e s s i n g i s i n d i c a t e d ;
w h e t h e r the instruction just fetched belongs to the otherwise step 8 p e r f o r m s the indirect addressing
c l a s s of i n s t r u c t i o n s w h i c h a r e s u b j e c t t o i n d i r e c t and the indexing phase is r e p e a t e d . Step 9 limits
addressing, the bits £.i2an<^—13 d e t e r m i n e t h e i n d i r e c t a d d r e s s i n g t o a s i n g l e l e v e l . It m a y
w h e t h e r this p a r t i c u l a r i n s t r u c t i o n is to be be noted that all f o r m a t i n f o r m a t i o n is p r e s e n t e d
i n d e x e d , a n d a i s t h e r e f o r e s e t t o u n i t y o n l y if directly in the m i c r o p r o g r a m .
i n d i r e c t a d d r e s s i n g is to be p e r f o r m e d .
T h e d e s c r i p t i o n of t h e e x e c u t i o n p h a s e of
2
T h e f u n c t i o n k (c ) d e t e r m i n e s w h e t h e r t h e c o m p u t e r o p e r a t i o n w i l l b e i l l u s t r a t e d by t h e
i n s t r u c t i o n i s i n d e x a b l e . If k ( c ) = 0, t h e b r a n c h f a m i l y of i n s t r u c t i o n s f o r l o g i c a l f u n c t i o n s i n t h e
from step 4 to step 7 skips the potential indexing 7090. R e p r e s e n t i n g the 38-bit a c c u m u l a t o r by
of s t e p s 5 a n d 6 . A s s h o w n by s t e p 6, i n d e x i n g t h e l o g i c a l v e c t o r u ( w i t h v ( u ) = 38, a n d w i t h
p r o c e e d s by o r i n g t o g e t h e r t h e i n d e x r e g i s t e r s u., u . , andu r e p r e s e n t i n g the sign, q and p bits,
( i . e . , r o w s of 1/ s e l e c t e d by t h e t h r e e t a g b i t s r e s p e c t i v e l y - / , m e s e i n s t r u c t i o n s m a y u6 u.e =
t = (18 1 a ) / c , s u b t r a c t i n g t h e b a s e t w o v a l u e of s c r i b e d a s in F i g u r e 2.
t h e r e s u l t i n g v e c t o r f r o m t h e a d d r e s s p o r t i o n of

O r to storage ORS
_Ml f £ l 5 / c _ ( ^ 2 / i i ) V M l c £ 1 5 / c

Or to a c c u m u l a t o r ORA u - u v (a 2 \ M - i £ 5/
£)

And to s t o r a g e ANS
T U1 J V V C
M- -—
._2, .
— -*-<a / u ) A M-4-—
, J c u l 5 / c—
~~ 2v~ | T > 1 5 / T
And to a c c u m u l a t o r ANA
u — u Afja^NyM- 1 - ~)
Exclusive or to a c c u m u l a t o r ERA
2 5 /
u~(u/(a \Mi^ ^))

Complement magnitude COM -1 / ^ - 1


/ -
a_ /u_ •*- a /u_
Clear magnitude CLM -1 /
a / u "*- £
Change sign CHS H-O^H.0

Set s i g n plus SSP u —U


-0
Set s i g n m i n u s SSM

Store logical word SLW


J^Vc _2
a /u
M- -L. — — • « — n

1 5
_ 2 > / c
C l e a r and add logical CAL u_ "- a_u \ M J — —
5
1,-2/, | x , I CO /c
Add and c a r r y logical ACL

l a 2 / u - ( 2 3 6 | y ) + ( y > 2 36 )

I n s t r u c t i o n s in IBM 7090

Figure 2
A PROGRAMMING LANGUAGE 349

Ordered Trees

A t r e e c a n be r e p r e s e n t e d g r a p h i c a l l y as in If e a c h i n d e x v e c t o r i s a u g m e n t e d by
F i g u r e 3(a) a n d , s i n c e it i s a s p e c i a l c a s e of a s u f f i c i e n t n u l l c o m p o n e n t s ( d e n o t e d by 0) t o b r i n g
d i r e c t e d g r a p h , it c a n a l s o b e r e p r e s e n t e d by a a l l t o a c o m m o n d i m e n s i o n e q u a l t o t h e h e i g h t of
n o d e v e c t o r n a n d c o n n e c t i o n m a t r i x C_ a s i n the t r e e , t h e n they m a y all be a r r a y e d in an
F i g u r e 3(b). i n d e x m a t r i x _I a s i n F i g u r e 4 ( b ) . If, a s i n
F i g u r e 4(b), t h e node v e c t o r n is defined s u c h
Defining an o r d e r e d t r e e a s a t r e e in which t h a t 11. i s t h e v a l u e of t h e n o d e i n d i c a t e d b y (the
t h e s e t of b r a n c h e s e m a n a t i n g f r o m e a c h n o d e h a s s i g n i f i c a n t p a r t of) t h e i n d e x v e c t o r I J, t h e n t h e
m a t r i x o b t a i n e d by a p p e n u i r i g n t o I p r o v i d e s a n
for o r d e r e d t r e e s c a n be defined in t h e m a n n e r u n a m b i g u o u s r e p r e s e n t a t i o n of t h e t r e e T . It i s
i n d i c a t e d by F i g u r e 4 ( a ) . T h e d i m e n s i o n of t h e convenient to also append the d e g r e e v e c t o r d
v e c t o r index i a s s i g n e d to e a c h node is e q u a l to s u c h t h a t d_. i s t h e d e g r e e of ( i . e . , t h e n u m b e r of
t h e n u m b e r of t h e l e v e l o n w h i c h it o c c u r s . If T b r a n c h e s e m a n a t i n g from) node IJ. The r e s u l t i n g
is an o r d e r e d t r e e , then T . will denote the s u b - m a t r i x of v ( T ) + 2 c o l u m n s i s c a l l e d a f u l l l i s t
t r e e r o o t e d i n t h e n o d e with""index _i_. T h u s T , . m a t r i x of T .
is the s u b t r e e e n c l o s e d in b r o k e n lines in
F i g u r e 4(a). M o r e o v e r , T—will denote the A n y m a t r i x o b t a i n e d by i n t e r c h a n g i n g r o w s
(unique) p a t h v e c t o r c o m p r i s i n g a l l nodes f r o m of a f u l l l i s t m a t r i x i s a l s o a f u l l l i s t m a t r i x a n d
t h e r o o t t o n o d e _ i . T h u s T f1* 2 ) = (a, b ) . T h e i s a g a i n a n u n e q u i v o c a l r e p r e s e n t a t i o n of t h e t r e e .
m a x i m u m dimension o c c u r r i n g among the index If, a s i n F i g u r e 4 ( c ) , t h e i n d e x v e c t o r s a r e r i g h t
v e c t o r s i s c a l l e d t h e h e i g h t of t h e t r e e a n d i s justified and a r r a n g e d in i n c r e a s i n g o r d e r on
d e n o t e d by v ( T ) . t h e i r v a l u e a s i n t e g e r s (in a p o s i t i o n a l n u m b e r
s y s t e m ) , t h e r e s u l t i n g list m a t r i x is c a l l e d a full
The index vector notation proves very con- r i g h t list m a t r i x and is d e n o t e d by I T . If, a s
v e n i e n t in d e s c r i b i n g a l g o r i t h m s involving t r e e i n F i g u r e 4(b), t h e i n d e x v e c t o r s a r e left j u s t i f i e d
o p e r a n d s . M o r e o v e r , it p r o v i d e s a s i m p l e f o r - and a r r a n g e d in i n c r e a s i n g o r d e r a s f r a c t i o n s ,
m a l i z a t i o n of t h e t w o i m p o r t a n t r e p r e s e n t a t i o n s t h e l i s t m a t r i x i s c a l l e d a f u l l left l i s t m a t r i x
of a t r e e , t h e L u k a s i e w i c z r e p r e s e n t a t i o n a n d t h e a n d i s d e n o t e d by CT.
level-by-level list.

n = (a, c, f, k, e, d, h, g, b>)

ft) 1 0 0 0 0 0 0 l\

0 0 1 1 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

C= 0 0 0 0 0 0 0 0 0

0 0 0 0 1 0 1 1 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

io o o o o o o o oj

(a) (b)

FIGURE 3
350 PROGRAMMING AND CODING

The right list groups nodes by levels, and r e p r e s e n t a t i o n of t h e t r e e i s t h e r e f o r e m o s t


t h e left l i s t by s u b t r e e s . M o r e o v e r , i n b o t h s u i t a b l e . T h e a n a l y s i s of a c o m p o u n d s t a t e m e n t
c a s e s t h e d e g r e e a n d node v e c t o r t o g e t h e r (that p r o c e e d s by s u b t r e e s a n d t h e left l i s t ( i . e . ,
i s , a_ 2 /( I T ) o r _ a 2 / ( CT)) c a n b e s h o w n t o p r o - L u k a s i e w i c z ) f o r m is t h e r e f o r e a p p r o p r i a t e . T h e
i n d e x v e c t o r s of t h e l e a v e s of an* r t r e e clear!* 7 -
w i t h o u t t h e i n d e x m a t r i x . If, a s i n t h e c a s e of a f o r m a legitimate Huffman prefix code and the
tree representing a compound statement in- c o n s t r u c t i o n of s u c h a c o d e p r o c e e d s by c o m -
v o l v i n g o p e r a t o r s of k n o w n d e g r e e , t h e d e g r e e b i n i n g s u b t r e e s i n a m a n n e r d i c t a t e d by t h e f r e -
v e c t o r d i s a k n o w n f u n c t i o n of t h e n o d e v e c t o r q u e n c i e s of t h e c h a r a c t e r s t o b e e n c o d e d , a n d
n_, t h e n t h e t r e e m a y b e r e p r e s e n t e d b y t h e n o d e t h e r e f o r e e m p l o y s a left l i s t . H o w e v e r , t h e
v e c t o r n a l o n e . I n t h e c a s e of t h e left l i s t , t h i s c h a r a c t e r s a r e f i n a l l y a s s i g n e d i n o r d e r of
leads to the f a m i l i a r Lukasiewicz''" notation for d e c r e a s i n g frequency to the leaves in right list
compound statements. o r d e r , and the index m a t r i x p r o d u c e d m u s t
t h e r e f o r e be brought to right list o r d e r .
A p p l i c a t i o n s of T r e e N o t a t i o n

T h e t r e e n o t a t i o n a n d t h e r i g h t a n d left l i s t
m a t r i c e s a r e u s e f u l in m a n y areas'1"'". T h e s e i n -
clude sorting a l g o r i t h m s such as the r e p e a t e d
s e l e c t i o n s o r t , t h e a n a l y s i s of c o m p o u n d s t a t e -
m e n t s and t h e i r t r a n s f o r m a t i o n to optimal form
a s r e q u i r e d in a c o m p i l e r , and the c o n s t r u c t i o n
of a n o p t i m a l v a r i a b l e - l e n g t h c o d e of t h e
Huffman prefix type. The sorting algorithm
p r o c e e d s l e v e l by l e v e l and the r i g h t list

2 3
F i r s t i n t r o d u c e d by J . L u k a s i e w i c z , a n d f i r s t a n a l y z e d b y B u r k s e t a l .
F o r d e t a i l e d t r e a t m e n t s of t h e a p p l i c a t i o n s m e n t i o n e d , s e e R e f e r e n c e 1 .

i 1
d n 2 n

2 a 0 0 2 a 0 0 1

2 c I 0 3 d 0 0 2

0 k l 1 2 c 0 1 1

0 f l 2 0 b 0 1 2

0 b 2 0 0 g 0 2 1

3 d 2 0 0 0 e 0 2 2

0 g 2 1 0 0 h 0 2 3

0 e 2 2 0 0 k 1 1 1

0 h 2 3 0 0 f 1 1 2

CT IT

(b) (c)

FIGURE 4
A PROGRAMMING LANGUAGE

REFERENCES

1. I v e r s o n , K. E . , "A P r o g r a m m i n g L a n g u a g e " , Wiley, 1962.

2. L u k a s i e w i c z , Jan, A r i s t o t l e ' s Syllogistic F r o m the Standpoint of


Modern F o r m a l Logic, C l a r e n d o n P r e s s , Oxford, 1951,
p . 78

3. B u r k s , A. W._, D. W. W a r r e n , and J, B, Wright, An Analysis


of a Logical Machine Using P a r e n t h e s i s - f r e e Notation",
M a t h e m a t i c a l T a b l e s and Other Aids to Computation,
Vol. VIII (1954), pp 53 - 57

4. F r i e n d , E . H . , "Sorting on E l e c t r o n i c C o m p u t e r S y s t e m s " ,
J . A s s o c . Comp. Mach. 3, pp 134 - 168 (March 1956)

5. Huffman, D. A . , "A Method for the C o n s t r u c t i o n of Minimum


Redundancy C o d e s " , P r o c . IRE, Vol. 40 (1952)
pp 1098 - 1101

You might also like