• No results found

A processor for PAL

N/A
N/A
Protected

Academic year: 2021

Share "A processor for PAL"

Copied!
13
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

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.

(2)

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

the

program 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'checks

the 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

q

when

(3)
(4)

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

*

k

of 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

...,

L

1,

and i f x l ,

...,

x i s t h e i n d i c a t o r

1 1

'

k m

I

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 of

X

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 of

X ,

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 .

(5)

-

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 list

i 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 .

(6)

w

1.

-5-

I I

I

6.

Coding of book entries. In extindstrCn1 we put the string number of the

i

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 pression

u .

-

i

I

*

I Then we put into middle [nl the string number of the string wiih single

*

*

entry

u

,

where

u

is the stretched form of

u.

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 list

3[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 procedures

validautex, 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 ,

(7)

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'),

3

it 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.

e

b

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.

(8)

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 < O

v

e > P

v

w < - 2 v w > P

v

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 n

i

:= i f

w

= -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 f

i

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 ;

-

(9)

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 v

d

>

m then v

:=

validautex(u, w, m, P)

-

-

else if d

= 0

then v

:=

true

--

-

-

else if middleEd1

= -1

then begin d

:=

extindstrcdl;

--

--

for

i

:= 1

while d

#

u

A

u

t

0 do u

:=

listlCu1;

-

-

end

-

else

v

:=

validstring(u, list3Cw1, extindstrrdl, m,

P);

-

if

I

v 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

v

w

>

P

v

g

=

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;

-

(10)

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

t

y

A

s

y

do

-

begin y

:=

listlCy1; s

:=

listlCs1 end;

-

-

if s

t

y 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;

-

(11)

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 ;

-

(12)

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 < 0

then e

:=

autexpridentity(v, w, P)

-

-

else if b

= 0 v c = 0

then e

:=

b

= c

--

else if b

=

c then e

:=

if middlerbl

= 0

then true

--

-

--

else

stringidentity(list3Cv1,

list3Cw1,

P)

else if b

> c

then e

:=

if ldefapplic(v, res, P) then false

--

-

-

--

else expridentity(v, res, P);

-

if

1

e 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

= 0

v w

=

0 then false

--

--

else stringidentity(list1 [v], list1

[w],

P)

A

expridentity(v, w,

P)

;

-

if

7 s

then ERCHECK(Q*****$, 0 , 0, 0, -1); niv

:=

niv

-

2

-

-

end stringidentity;

(13)

; i n t e g e r w , t , P , b e g i n b o o l e a n h ; h :=

-

t r u e ; n i v := n i v + 2 ; i f o u t t h e n E R C H E C K ( ~ ~ ~ S ~ ~ ~ ~ # ,

-

-

w , 0 , 0, P + I ) ; i f w = 0 t h e n t := 0

-

-

e l s e b e g i n t := l i s t 4 C w l ;

--

i f t = -1 t h e n

-

-

b e g i n i n t e g e r d , j , s ; d := l i s t 2 [ w ] ; i f 7 h a s t y p e ( l i s t l [ w ] , s , P ) t h e n h

-

e l s e b e g i n P := P

+

1 ; t : = P ; l i s t

--

i f d = 0 t h e n h := f a l s e

-

-

:= f a l s e l [ t ] := s ; l i s t 4 C t l e l s e i f d < 0 t h e n h := a u t h a s t y p e ( w , t , P )

--

e l s e b e g i n i n t e g e r q ; q := m i d d l e c d ] ;

--

i f q = -1 t h e n

-

-

b e g i n i n t e g e r f , g ; f := c a t s t r c d ] ; g := l i s t 2 C f l ; l i s t 2 C t l := g ; l i s t 3 C t l := l i s t 3 C f l ; l i s t 4 C w l := t end

-

e l s e b e g i n i n t e g e r v , e , 1;

--

e := l i s t 3 C w l ; v := s t r i n g s u b s t ( c a t s t r C d 1 , e , e x t i n d s t r c d l , P ) ; i f 7 h a s t y p e ( e , 1, P)

-

t h e n h := f a l s e e l s e i f 7 string~dentity(listl[v], 1, P) t h e n h := f a l s e

--

-

e l s e b e g i n l i s t 2 C t l := l i s t 2 C v l ; l i s t 3 C t l := l i s t 3 C v l ; l i s t 4 C w l := t end end

-

end

-

x . end ;

-

i f o u t A h t h e n ~ ~ ~ ~ ~ ~ $ ( C e n d h a s t y p e # , t , 0 , 0 , w)

-

-

end

-

e l s e i f o u t t h e n ~ ~ ~ ~ ~ ~ ~ ( e e n d h a s t y p e t t

- I t ,

0 , 0 , 0 , t )

--

-

end : i f 7 h t h e n ERCHECK(C*****$, 0 , 0 , 0 , - 1 ) ; n i v := npiv

-

2 ; h a s t y p e := h

- -

end h a s t y p e ;

-

Referenties

GERELATEERDE DOCUMENTEN

The voluntary disclosure of the “long form” audit report by OOB category firms in the Netherlands in the voluntary period by one industry causes the future firm

For a given year of analysis, the RIP value of a journal equals the average number of times the journal’s publications in the three preceding years were cited in the year of

One can also relate the ideal class group to the Galois group of abelian extension of the field K. But to do so, we must first relate the ideals of the order O to ideals of the

The organizational form of foreign banks at least matters for the managers of foreign banks and local regulators in host countries, since branches and subsidiaries typically

Since we intend to do analysis on the resulting state-space model along the lines of balanced realizations (quantitative measures for controlla- bility and

Analogously, is con- structed to estimate G' (p). For our data set the observations are presented as crosses and circles, and the two estimated distribution functions, F = 1 and G

For example, the symbol U +,− denotes a sequence of arguments of ↑, for which the upper strand (of the first argument) must cover the lower strand to the left, and the lower strand

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