A processor for PAL
Citation for published version (APA):
de Bruijn, N. G. (1970). A processor for PAL. Technische Hogeschool Eindhoven.
Document status and date: Published: 01/01/1970
Document Version:
Publisher’s PDF, also known as Version of Record (includes final page, issue and volume numbers)
Please check the document version of this publication:
• A submitted manuscript is the version of the article upon submission and before peer-review. There can be important differences between the submitted version and the official published version of record. People interested in the research are advised to contact the author for the final version of the publication, or visit the DOI to the publisher's website.
• The final author version and the galley proof are versions of the publication after peer review.
• The final published version features the final layout of the paper including the volume, issue and page numbers.
Link to publication
General rights
Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain
• You may freely distribute the URL identifying the publication in the public portal.
If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, please follow below link for the End User Agreement:
www.tue.nl/taverne Take down policy
If you believe that this document breaches copyright please contact us at: openaccess@tue.nl
providing details and we will investigate your claim.
ische Hogeschool, Eindhoven.
erafdeling der Wiskunde.
Notitie 30, d.d, 26 maart 1970.
A Processor for PAL.
by N.G. de Bruijn,
Technological University,
Eindhoven.
The Netherlands.
1ntroduction:In this note we shall describe a program for checking a PAL
-
book;
that program is called a PAL processor. For description of the mathematical lan-
guage PAL we refer to
C 1 1
and C21.
The program checks a PAL book line by line, by means of a boolean procedure
11
acceptline". At the end of this note we give the ALGOL text of that procedure,
as well as the auxilliary procedures "validexpression", "validstring", "stringsubst",
"deflappic", "expridentity", "stringidentity", and "hastype".
"Acceptline" checks the PAL text in a coded form. We shall not present the
part of the processor that transforms the original PAL-text into that coded form,
nor the part of the processor that takes care of error diagnostics and further
output. Those relatively extensive parts of
theprogram were composed by
Mk.
L.G.F.C.
van Bree, who also did all the testing of the completed processot,
Arrays used for storage of the PAL book. We use the following integer arrays:
(i) Three book arrays, viz. "extindstr", "middle", "catstr". These are
-
indexed by line numbers; eg. extindstrCk] refers to the k-th line, where
k
=l,2,3,
... .
Apart from a few exceptions, the integers stored in these arrays
are "string numbers".
(ii) Four list arrays, viz. "list I","list 2", "list
-
3","list 4". These
are used for storing expressions and strings. They are indexed by "string numbers'' m.
The numbers list
l[m]
,
. .
.
,
list4[m] provide information about the m-th string
under consideration. (When we store an expression, we consid& it as an expression
string with just one entry; hence it suffices to deal with strings).
General outline of the
processor."Acceptlinel'checksthe n-th line of the
PAL
book,
under the assumption that all previous lines have been found correct, and that all
information contained in those lines is still available. This means that the book
arrays are filled up to n-1, and the list arrays up to m
=p
say. Next the n-th
n
'
line is brought into its coded form. That amounts to filling the n-th entries of
the book arrays, and the entries of the
list arrays
up to
m
=qn
'
say.Then
we
execute acceptline (n
) .That is, the formal parameter P gets the value
qwhen
If X i s a non-empty s t r i n g , we d e f i n e f r o n t s t r i n g of X , l e a d e r o f A , t a i l s t r i n g of A . The f r o n t s t r i n g of X i s t h e s t r i n g we o b t a i n from
X
-
I? i f we omit t h e l a s t e n t r y . I f t h a t l a s t e n t r y i s R I t h e n b i s c a l l e d t h e l e a d e r of A , and C...,
C i s c a l l e d t h e t a i l s t r i n g 1*
kof A . The l e a d e r i s e i t h e r t h e i d e n t i f i e r of a l i n e , o r t h e symbol t y p e . The t a i l
-
s t r i n g c a n be t h e empty s t r i n g .The s t r e t c h e d form of a PAL-expression
-
i s d e f i n e d r e c u r s i v e l y a s f o l l o w s ( i ) I f t h e e x p r e s s i o n i s a v a r i a b l e , t h e s t r e t c h e d form i s j u s t t h e e x p r e s s i o n i t s e l f .( i i ) I f t h e e x p r e s s i o n i s b(Z
...,
L1,
and i f x l ,...,
x i s t h e i n d i c a t o r1 1
'
k mI
s t r i n g of t h e l i n e whose i d e n t i f i e r i s b ( whence m Z k ) , t h e n t h e s t r e t c h e d form
I
*
where C . i s t h e s t r e t c h e d form of C . ( i = l ,
...,
k ) .1 1
(The d e f i n i t i o n h a s t o be modified i n a t r i v i a l way i f k o r m-k o r b o t h a r e z e r o . ) We g i v e a n example. L e t a , b , c be i n d e n t i f i e r s of l i n e s w i t h i n d i c a t o r s t r i n g s 4 r e s p e c t i v e l y . Then t h e e x p r e s s i o n The s t r e t c h e c
form
of a s t r f a g-
X
i s t 5 e s t r i n g o b t a i n e d by r e p l a c i n g a l l e n t r i e s ofX
by t h e i r s t r e t c h e d form. S i n c e t h e symbol t y p e may o c c u r a s a n e n t r y of X , we s t i p u l a t e t h a t t h e s t r e t c h e d f o m of cype i s a g a i n t y p e .-
'?
5. Coding of s t r i n g s . The empty s t r i n g g e t s s t r i n g number
-
0. This i s a n e x c e p t i o n a l c a s e i n t h e s e n s e t h a t 0 i s n o t i n t h e range of l i s t-
1 ,...,
l i s t 4 .A non-empty s t r i n g
X
w i l l be coded a s f o l l o w s . I f k i s i t s s t r i n g number, t h e n i i s t l i k ] i s t h e s t r i n g number of t h e f r o n t s t r i n g ofX ,
l i s t 2 C k l t h e code number of t h e l e a d e r of x , and l i s t 3 C k l t h e s t r i n g number of t h e t a i l of A .The code number of t h e l e a d e r i s 0 i f t h e l e a d e r i s t y p e ; i f t h e l e a d e r
-
i s t h e i d e n t i f i e r of a l i n e t h e n i t s code number i s j u s t t h e l i n e number of t h a t 1 i n e .We mention t h a t l i s t 4 C k l h a s t h e v a l u e -1 a s l o n g a s t h e c a t e g o r y of A h a s n o t y e t been e v a l u a t e d . I f i t happens t o be e v a l u a t e d , t h e s t r i n g number of t h e c a t e g o r y of A i s g i v e n a s a new v a l u e t o l i s t 4 C k l .
-
AS a n example of s t r i n g s t o r a g e , we show t h e f o l l o w i n g p i e c e of listi n f o m a t i o n .
From t h i s we c a n deduce t h a t t h e f o .owing s t r i n g s a r e i n v o l v e d .
w
1.
-5-I I
I
6.
Coding of book entries. In extindstrCn1 we put the string number of thei
extended indicator string of the n-th line (it is 0 in case of ithe empty string).
In middle [nl we put - 1 if the middle of the n-th line is
PN,
-2
if it is EB . ,In
all other cases the middle of that line is an e pressionu .
-
i
I
*
I Then we put into middle [nl the string number of the string wiih single
*
*
entry
u
,
whereu
is the stretched form ofu.
I
In catstr [n] we always put a string number, viz. the string number of the stretched form of the category string of that line.The reader may fear that the use of stretched form spoils the
advantages of the
PAL
abbreviation system. This is not the case, however. Since all relevant indicator strings have to be stored anyway, the use of the stretched form does not require more memory space than the abbreviated form.7.
--
Some minor remarks. (i) In a few cases we deviate from our system. One thing is that we write -1000 in list3[k]
if list 2[k] = 0.In
that case list 3[k] has to indicate the tail of type, but typ.e cannot have a tail. And sometimes-
we put -3000 in list I[kl in cases where we are not interested in finding out what it should be. These conventions only serve to make the possible diagnos-tical output better readable, earmarking some data as irrevelant because of a specified reason.
(ii)
In our procedures the reader will find reference to boolean proceduresvalidautex, authastype, autsubst, autexprldentity. These are intended for later extension of the PAL processor to an AUTOYATH processor. Since only
PAL is
a t stake here, we can just replace sny cail of these procedures by false.I t
(iii) In stringidentityU the size of the lists is limited to 1000 entries. This number can, of course, be replaced by any other number that the memory of the computer will adnit.
(iv) The reader who consults our procedures may skip all statements containing
t h e procedure ERCHECK or the identifiers niv and out. These are intended for diagnostics of errors of the
PAL
text and similar purposes. We do not discuss that here,8. ~m~erfectioc of the processor. The processor will never accept an incorrect text, but t k z e are, unfortunately, cases where it refuses a
correct
t e x t ,
We shall describe how this can happen.
It is often necessary to check that two seemingly different expressions
are definitionally equivalent. This is the duty of our procedure "expridentityl',
and the strategy of this one is slightly too pessimistic. If it has to compare
a pair of expressions like a(C
1'
C2'
C3), a(L;, I;, L'),
3it refuses to consider
them as equivalent if it finds, e.g., that C and
C'are non-equivalent. This
2
2
overlooks the possibility that in the definition of a(x, y, z) the letter y
does not occur at all.
It would not be hard to change the strategy of "expridentity" such as
to deal adequately with this situation. If we want to keep the processing
time within reasonable limits, the best thing to do seems to be: keep track
of all cases where an identifier is definitionally independant of a part of
its indicator string (cf
.
C31).
It is questionable, however, whether it is worth while to devote so much
memory space and processing time to a possibility that hardly ever occurs and
that can easily be avoided by the PAL text writer.
References.
eb
1 .
N.G.
de Bruijn, Automath, a language for mathematics. THE-report 6 8 - w ~ ~ E 0 5
(1968) Technological University, 'Eindhoven.
2.
The mathematical language Automath, its usage, and some
of its extensions. Appears as a part of: Proceedings of
the Symposium on Automatic Demonstration
(IRIA,
Versailles,
December 1968), in the Springer Lecture Notes Series.
3.
SEMIPAL 2, an extension of the mathematical notational
language SEMIPAL. THE notitie nr 43
(
!
I
maart 1969),
Technological University, Department of Mathematics,
Eindhoven.
boolean procedure a c c e p t l i n e ( n , P); v a l u e n ; i n t e g e r n , P ; b e g i n i n t e g e r e , w, v , k ,
i ,
t ; boolean b ; i f o u t t h e n E ~ c ~ E C ~ ( + a c c e p t l i n e % , e , v , w , P + 1 ) ;- -
i f e < Ov
e > Pv
w < - 2 v w > Pv
v < I v v > P v w P O t h e n b : = f a l s e-
-
e l s e i f w = -1 t h e n b := i f e = 0 t h e n f a l s e e l s e l i s t 2 C e l = n--
- -
---
e l s e b := t r u e ;- -
i f b t h e n b e g i ni
:= i fw
= -1 t h e n l i s t l C e l e l s e e ;- -- -
-
-
k := l i s t 2 C i l ; l i s t l C v l := c a t s t r C k l ; i f-
w > 0 t h e n l i s t l C w l-
:= e ; b :=-
i f k < 0 v k > n-
I--
t h e n f a l s e e l s e i fi
z
e x t i n d s t r c k l t h e n f a l s e e l s e v a l i d e x p r e s s i o n ( i , v , n-
I , P)--
---
end ;-
i f b t h e n b e g i n i f w > 0 t h e n b := i f 7 v a l i d e x p r e s s i o n ( i , w, n-
1 , P) t h e n f a l s e-
---
-
-
--
e l s e i f - , hastype(w, t , P) t h e n f a l s e e l s e e x p r i d e n t i t y ( t , v , P)--
---
'+
e l s e i f l i s t 2 C v l t 0 t h e n b e g i n i n t e g e r m; m := P := P+
1 ; l i s t l C m ] := 0 ; l i s t 2 C m l := I i s t 2 C v l ;-4
--
-
3 l i s t 3 C m l := l i s t 3 C v l ; list4Cml:= - 1 ; end ;-
end ;-
i f 7 b t h e n ERCHECK(-$*****$, 0 , 0 , 0 ,-
1 ) ;-
-
b := i f - , hastype(m, t , P) t h e n f a l s e e l s e l i s t 2 C t l---
= 0 a c c e p t l i n e := b end a c c e p t l i n e ;-
boolean procedure validexpression(u, w, m, P); value u, w, m; integer u, w, m, P;
begin integer d, i; boolean v; niv
:=niv
+
2;
if out then ERCHECK(Tvalidexpr#, u, w, 0, P
+
1)
;- -
d
:=list2Cwl;
if d
< 0 vd
>m then v
:=validautex(u, w, m, P)
-
-
else if d
= 0then v
:=true
--
-
-
else if middleEd1
= -1then begin d
:=extindstrcdl;
--
--
for
i
:= 1while d
#u
Au
t0 do u
:=listlCu1;
-
-
end
-
else
v
:=validstring(u, list3Cw1, extindstrrdl, m,
P);
-
if
Iv then ERcHEcK(Q;*****#, 0, 0,
0,-1);
- -
validexpression
:=v; niv
:=niv
-
2
end validexpression;
-
boolean procedure validstring(u, w, g, m, P); value u, w, g, m; integer u, w, g, m, P;
begin boolean v; niv
:=niv
+
2;
if out then ERCHECK(Q;validstring#, u, w , g,
P
+
I)-;-
-
v
:=validstring
:=-
if w
=g then true
s .
--
else'if
w
<1
vw
>P
vg
=0 then false
--
--
else if ~validstring(u, listl[w],
listl[g],
m, P)
then false
--
--
else validexpression(u, w, m, P);
-
if ~v then ERCHECK(Q;*****),
0, 0,0, -1);
-
-
niv
:=niv
-
2;
end validstring;
-
integer procedure stringsubst(w, s, y, P); value w, s, y; integer w, s,
y,
P;
begin integer d, t, i; niv
:=niv
+
2;
if out then E ~ ~ ~ E ~ ~ ( + s t r i n g s u b s t $ ,
w ,s, y, P
+
I);
else begin d
:=list2CwI;
P
:= t :=P
+
I ;
stringsubst
:=t;
-
listlCtl
:=stringsubst (listlCw], s, y, P); list2Ctl
:=d; list4Ctl
:=- 1 ;
if
d
>0
then begin if middleCd1
=-1
then
-
-
-
-
for i
:=1
while d
ty
As
y
do
-
begin y
:=listlCy1; s
:=listlCs1 end;
-
-
if s
ty then begin list2Ct1
-
:l s t 2 s l ; list3Ctl
:=list3Csl end
-
end
-
else list3Ctl
:=stringsubst(list3[wl,
s, y, P)
-
end
niv
:=niv
-
2
-
else if
d
<0
then list3Ctl
:=aut subst(w, s, y, P) else list3Ctl
:=-1000;
--
-
if out
A d 2 0-
then
~ ~ ~ ~ E ~ ~ ( C e n d s t r s u b s t $ , * t ,0,
0, '1)end
;-
end stringsubst;
-
boolean p r o c e d u r e d e f a p p l i c ( s , t , P ) ; v a l u e s ; i n t e g e r s , t , P; b e g i n i n t e g e r b , q ; boolean d ; n i v := n i v + 2;
-
i f
o u t-
t h e n ~ ~ ~ ~ ~ ~ ~ ( { d e f a ~ p l i c ~ ,5,
0 , 0 , P+
1 ) ; end ;-
i f - i d t h e n ERCHECK(+*****$, 0 , 0 , 0, - 1 ) ;- -
i f o u t t h e n ~ R ~ ~ ~ C K ( + e n d d e f a ~ ~ $ , t , 0 , 0 , - 1 ) ; n i v := n i v-
2- -
end d e f a p p l i c ;-
boolean procedure expridentity(v, w,
P); value v, w; integer v, w, P;
begin integer b,
c ,res; boolean e;
niv
:=niv
+
2; if out then ~ ~ ~ ~ ~ ~ ~ ( + e x p r i d e n t $ ,
-
-
v, w, 0 , P
+1);
b
:=list2Cvl; c
:=list2Cwl;
if b
< 0 v c < 0then e
:=autexpridentity(v, w, P)
-
-
else if b
= 0 v c = 0then e
:=b
= c--
else if b
=c then e
:=if middlerbl
= 0then true
--
-
--
else
stringidentity(list3Cv1,list3Cw1,
P)else if b
> cthen e
:=if ldefapplic(v, res, P) then false
--
-
-
--
else expridentity(v, res, P);
-
if
1e then ERCHECK(+*****$,
0, 0, 0, -1);
-
-
expridentity
:=e; niv
:=niv
-
2
end expridentity;
-
boolean procedure stringidentity(v,
w,
P); value v, w ; integer v, w, P;
begin boolean s;
niv
:=niv
+
2;
-
if
out
-
then E~CHECK(+stringident$,
v, w,
0,P
+I);
if v
<0
v v
>1000
v
w
<0
v
w
>1000 then stringidentity
:=s
:=false
-
-
else stringidentityi:=
s :=if v
=w then true
-
-
--
else if v
= 0v w
=0 then false
--
--
else stringidentity(list1 [v], list1
[w],
P)
Aexpridentity(v, w,
P)
;-
if
7 sthen ERCHECK(Q*****$, 0 , 0, 0, -1); niv
:=niv
-
2-
-
end stringidentity;
; i n t e g e r w , t , P , b e g i n b o o l e a n h ; h :=