• No results found

A namefree lambda calculus with facilities for internal definition of expressions and segments

N/A
N/A
Protected

Academic year: 2021

Share "A namefree lambda calculus with facilities for internal definition of expressions and segments"

Copied!
42
0
0

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

Hele tekst

(1)

A namefree lambda calculus with facilities for internal

definition of expressions and segments

Citation for published version (APA):

Bruijn, de, N. G. (1978). A namefree lambda calculus with facilities for internal definition of expressions and segments. (EUT report. WSK, Dept. of Mathematics and Computing Science; Vol. 78-WSK-03). Technische Hogeschool Eindhoven.

Document status and date: Published: 01/01/1978

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)

TECHNISCHE HOGE SCHOOL E INDHOVEN NEDERLAND

ONDERAFDELING DER WISKUNDE

TECHNOLOGICAL U N I V E R S I T Y EINDHOVEN THE NETHERLANDS D E P A R b l E N T O F MATHEMATICS A n a m e f r e e l a m b d a c a l c u l u s w i t h f a c i l i t i e s f o r i n t e r n a l d e f i n i t i o n o f expressions and ' s e g m e n t s . N.G. d e B r u i j n . T . H . - R e p o r t 78-WSK-03 A u g u s t 1978

(3)

Abstract.

The paper starts with a formal definition of a lambda calculus with abbreviation facilities, including a set of single-step reductions which can be used to effectuate substitution and beta-reduction. A novelty is the abbreviation of segments of formulas. Later reference to such a segment involves duplication of the segment variables. These variables can be local, global, formal or somehow disguised by other segment abbreviations, and there- fore it would be hard to describe without namefree references what the system would be.

A large part of the paper consists of informal explanations.

(4)

1 . I n t r o d u c t i o n . We d e v i a t e from t h e u s u a l way of p r e s e n t a t i o n , s h i f t i n g i n t r o d u c t o r y m a t e r i a l t o t h e end of t h e p a p e r ( s e c t i o n 6 ) . T h i s makes i t c l e a r t h a t such m a t e r i a l , a l t h o u g h i t p r o v i d e s a background, i s i n no way used i n t h e main s e y t i o n s .

The c a l c u l u s c o n s i s t s of a s y n t a x ( s e c t i o n 3 ) and a s e t of p r i m i t i v e r e d u c t i o n s . A t p r e s e n t t h e r e i s n o t much a v a i l a b l e i n t h e d i r e c t i o n of a t h e o r y about t h e s e r e d u c t i o n s . I t i s q u i t e c o n c e i v a b l e t h a t i t may t u r n o u t Lo be b e t t e r t o a l t e r s y n t a x a ~ d r e d u c t i o n s i n o r d e r t o make room f o r a more s a t i s f a c t o r y t h e o r y . T h e r e f o r e t h i s n o t e h a s t o b e c o n s i d e r e d a s a f i r s t s t e p r a t h e r t h a n a s something f i n a l .

2.

N o t a t i o n . We adopt t h e m e t a l i n g u i s t i c n o t a t i a n e x p l a i n e d i n [ 6 ] . (The n o t a t i o n i s e s s e n t i g l l y t h e same a s i n [ 5 1 , e x c e p t f o r t h e f a c t t h a t i n

[ 5 ]

t h e "combs" have been r e p l a c e d by something e l s e , j u s t f o r p r i n t a b i l i t y . I n

[ 4 1

t h e n o t a t i o n i s e s s e n t i a l l y d i f f e r e q t . ) A s h o r t e x p l a n a t i o n f o l l o w s h e r e .

&is a f i n i t e non-empty s e t , c a l l e d t h e a l p h a b e t . S(J% i s t h e s e t of a l l f i n i t e &words, I n s(& we have c o n c a t e n a t i o n a s b a s i c o p e r a t i o n ; w i t h t h i s o p e r a t i o n S G ) i s what i s u s u a l l y c a l l e d t h e f r e e mopoid o v e r A . For k=0,1,2,

...

we d e n o t e by S (&) t h e s u b s e t c o n s i s t i n g of a l l words of k

k

l e t t e r s . There

i s

a t r i v i a l b i j e c t i o n f r o m b t o

~ ~ ( 4 ) .

so(&

c o n s i s t s of t h e empty word o n l y . That empty word i s denoted by E.

From now on we p u t

$(/a)

= S, s l @ ) = Sl

,

and we no l o n g e r mention

&

and

i t s

e l e m e n t s . The elements of S a r e t o b e denoted by mathematical symbols ( l i k e t h e elements of any o t h e r s e t ) , and a symbol used f o r an o b j e c t i n S u s u a l l y does n o t r e v e a l t h e d e m e n t s of

A

t h e o b j e c t c o n s i s t s o f .

I f p e S t h e n t h e index k w i t h p c Sk i s c a l l e d t h e l e n g t h of p . C o n c a t e n a t i o n of p and q ( w i f h p E S, q E S ) i s denoted by

mi,

and s i m i l a r l y we w r i t e

b m ! ,

e t c .

We a l s o u s e n o t a t i o n s l i k e t h i s one: i f P c S, q e S, R c S, s E S, t E S t h e n

(5)

3 . The s e t T. We w r i t e !ll = C1,2,3,

...

1,

OIJo

= 0 1 2

1

;

8

i s t h e s e t of a l l mappings of LN i n t o IN,

M i s t h e s e t of a l l p a i r s (k.0) where k r R o , and where 0 i s

a

mapping of { I

,

.

.

.

k i n t o

No.

( I f k=0 t h e n 0 can o n l y be t h e empty mapping).

We i n t r o d u c e a number of elements and s u b s e t s of S1 and mappings i n t o S1 which w i l l be f i x e d f r ~ m qow on.

X 0 , X 1 , X 2 ,

...

a r e m u t u a l l y d i s j o i n t s u b s e t s of S1.

5

i s an i n j e c t i o n of

BI

i n t o Xo. w i s an i n j e c t i o n of M i n t o Xo,

4

i s an i n j e c t i o n of

8

i n t o X I . Q i s an i n j e c t i o n of 1N o x IN i n t o X1. X , G a r e e l e m e n t s of X 1 , X 2 , r e s p e c t i v e l y . The s e t s e(W,o(M), 4 ~ 8 ) ~ n(N o x @J) {A}, { 6 >

(6)

We d e f i n e t h e s u b s e t T of S as t h e minimal s o l u t i o n of

By r e c u r s i o n we d e f i n e mappings o : T -t { 0 , 1 , 2 ) and p : T

-+Do.

I f x o E X O , X I e x 1 , x2 c X 2 ,

...,

t~

T,

t l E T , . .

.

we a g r e e t h a t

-

[ o ( t ) o t h e r w i s e e t c . As t o p we a g r e e t h a t e t c . For i n t e r p r e t a t i o n we r e f e r t o s e c t i o n 6.16. 4. R e d u c t i o n s . We d e f i n e a r e l a t i o n on T. The r e l a t i o n

i s

c a l l e d " s i n g l e - s t e p r e d u c t i o n " and w i l l simply b e d e f i n e d by a l i s t of c a s e s .

I n t h i s l i s t , wl and w2 s t a n d f ~ a r b i t r a r y elements of r S , which a r e such t h a t t h e t h i n g on t h e l e f t of >1 i s an element of T . The r i g h t - h a n d s i d e w i l l b e i n T a s a consequence.

(7)

if B E @ , & , e l ) E M ; here

eel

is the composition of 0 and 8 1

.

if O , B l

€8;

here

e e l

is the composition of 0 and €I1

.

(8)

i f

e

€8

and I

4

e(N); h e r e

e l

i s d e f i n e d by e l ( j ) = e ( j ) - l f o r a l l j E B . i f ( k , e ) E M and 1 & e ( { l ,

...,

k ) ) ; h e r e 81 i s d e f i n e d by e l ( j ) = = 9 ( j ) * 1 f o r j =

I

,.

. .

, k . and

e 2

by e 2 ( 1 ) 7 2 , 0 2 ( 2 ) = 1 , O 2 ( j ) = j i f j > 2 . i f ~ E T , k 6 D O , EN, m > 1; h e r e

e l

i s d e f ? n e d by o l ( j ) = j + k

--

i f ~ E T , k e B 0 , o ( t ) = 1 , t

= &

r w ( k , 8 ) ( ; h e r e

e l

and 0 2 are d e f i n e d as i n ( B 8 ) , and e 3 ( j ) = ~ ( j ) i f j I k , e 3 ( j ) = j + ~ ( t )

-

k i f j > k .

(9)

if t,tl,t2 E

T,

x3 E X 3 ; similarly for X4,X5,

...

5.

The reduced form. We define the set

R

as a subset of

T,

consisting of all those words of T which do not contain any $(0)'s. In other words it is the minimal solution of

where

X;

=

X

\

$(@).

We define a mapping rf : T +

R.

If t e T then rf(t) is called the reduced form of t. It is defined by recursion:

(ii) If t has the form of one of the left-hand members of (AI),

...,(

A 9 ) with wl = E, then rf(t) is defined as the rf of the right-hand member.

Theorem

5.1.

If t E T then rf(t) E

R .

If t E

R then rf

(t) = t

.

Theorem 5.3. If t~

T

then there exists a natural number m such that every sequence

with reductions taken from (Al),

...,

(A9) satisfies n 5 m, moreover rf(tl) =

= rf(t2) =

.

.

.

= rf(tn>, and either t = rf(t) or the reduction sequence can n

(10)

These theorems are easily proved by induction with respect to the length of t. At a certain point of the proof of theorem 5.2 it plays a

*

rale that the operations occurring in (A5) and

(A7)

satisfy

(BIB2)

=

*

*

= 8 1

e2

.

6. Explanations and comments. In the previous sections we described a system (or, as one might prefer to say, a language) which we shall now denote by

CXcr$wr~. We shall try to explain the purpose of all this, and to connect it

with related systems and their notations. We start with a simple formula language, to be called CV.

6.1 The language CV. The system CV has formulas like this:

Here p,f,g,h,c are constants, and x,y are variables. There is no difference between constants and variables until we introduce the notion of substitution, where variables are replaced by formulas (all x's by one formula, all

y's

by a second formula, etc).

In case of long formulas it helps to represent them in tree form; (6.1.1) becomes

(6.1.2) P-

f

h 8

It is what combi~~atorialists might call a "planted planar tree", oriented towards the "roott' p. In further pictures we shall omit the arrows: we agree that the arrows always have to run from right to left.

Every node in such a tree has an "indegree", i.e. the number of arrows entering from the right. Quite often one requires that one and the same constant has the same indegree at all its occurrences, like the g in (6.1.2). (This is not required in AUTOMATH, but that is irrelevant at this moment). The variables x,y,..

.

all have indegree 0.

The correspondence between formulas like (6.1.1) and trees like (6.1.2) is one-to-one. However, if the indegrees are known (either known from some list, or indicated in the formula itself) one can represent (6.1.2) without parentheses and commas:

(11)

P a r s i n g i s e a s y . Read p , w r i t e p ( ...) and t r y t o i n t e r p r e t t h e r e m a i n d e r o f ( 6 . 1 . 3 ) a s a f o r m u l a t o b e p l a c e d on t h e d o t s . Next r e a d f , w r i t e f (

...,...),

and t r y t o i n t e r p r e t t h e r e m a i n d e r o f ( 6 . 1 . 3 ) a s two f o r m u l a s , t o b e p l a c e d i n s u c c e s s i o n on t h e d o t s , e t c . F o r s u c h t r a n s f o r m a t i o n s of v a r i o u s t r e e r e p r e s e n t a t i a n s we r e f e r t o Knuth C81. I t would n o t b e a v e r y s e r i o u s r e s t r i c t i o n t o r e q u i r e t h a t t h e i n d e g r e e s a r e a t most 2. We c a n always s i m u l a t e t h e g e n e r a l c a s e by means of i n d e g r e e s 0 , l and 2 , e . g . r e p l a c i n g A f D by 1

/*/"/".,

.

£2 £ 3 The s y s t e m CV i s a s u b s y s t e m o f CX$wq, a t l e a s t a s l o n g a s we do n o t t h i n k of r e d u c t i o n s , and ~ r o v i d e d we r e p r e s e n t t h e f o r m u l a s o f CV i n t h e form ( 6 . 1 . 3 ) , and a s l o n g a s we a g r e e t h a t a l l i d e n t i f i e r s o f i n d e g r e e 0 a r e t a k e n from a s e t X i n d e g r e e 1 f r o m X i n d e g r e e 2 from X 2 , e t c . . The s e t s

0

'

1

'

xo9xI

, -

.

a r e d i s j o i n t , and t h e r e f o r e i t i s n o l o n g e r n e c e s s a r y t o i n d i c a t e t h e i n d e g r e e s i n t h e f o r m u l a ( l i k e i n ( 6 . 1 . 3 ) ) . Now ( 3 . 1 ) j u s t d e f i n e s t h e s e t T o f a l l f o r m u l a s o f CV. The < , w , n , $ , h , b o f s e c t i o n 3 p l a y no r 8 1 e .

The r e l a t i o n between CV-formulas and t r e e s c a n o b v i o u s l y b e e x t e n d e d t o f o r m u l a s of Ch<~$wq. Example:

where b t X f t X I , p, t X 2 , 0 t

#.

I t c e r t a i n l y h e l p s t o t h i n k o f t h e e l e m e n t s

0

'

of T ( o f s e c t i o n 3 ) a s s u c h t r e e s , and i n p a r t i c u l a r t o s e e t h e r e d u c t i o n s of s e c t i o n 4 a s r e d u c t i o n s of s u c h t r e e s .

The above embedding o f CV i n t o CXc$wq i s a m a t t e r of t h e s y n t a c t i c s t r u c - t u r e of t h e f o r m u l a s o n l y . I f we b e a r i n mind what o u r f o r m u l a s w i l l b e u s e d f o r , i t i s b e t t e r t o d i s t i n g u i s h between t h e v a r i a b l e s and t h e o t h e r c o n s t a n t s of i n d e g r e e 0 . L e t u s o r d e r t h e v a r i a b l e s : f i r s t x , t h e n y , e t c . I n s t e a d of x we now w r i t e < ( I ) , e t c . So ( 6 . 1 . 2 ) becomes

(12)

P f h g C

The i d e a t h a t c ( k ) always r e f e r s t o t h e k - t h v a r i a b l e w i l l be g i v e n u p l a t e r , when i n t e r m e d i a t e lambdas have t h e i r e f f e c t on t h e r e f e r e n c e s .

6 . 2 S u b s t i t u t i o n . L e t t h e CV-formula F have v a r i a b l e s x , y , z . L e t P 1 ' P 2' P 3 b e CV-formulas ( t h e y may a l s o c o n t a i n x,y,z).We now c o n s t r u c t a f o r m u l a G a s f o l l o w s : Mark a l l x , y , z o c c u r r i n g i n F ( l e t u s s a y c o l o u r them r e d )

,'

i n o r d e r t o d i s t i n g u i s h them from t h e x , y , z l s i n P P P Now r e p l a c e e a c h

1 ' 2' 3' r e d x i n F by P e a c h r e d y by P2, each r e d z by P I n t h i s way F t u r n s 1

'

3 ' i n t o what we c a l l G. T h i s G w i l l b e c a l l e d t h e r e s u l t of t h e s u b s t i t u t i o n ( X , ~ , Z ) -t ( P l , P ,P ) on F. Example: 2 3 F 1 2 3 G

Q u i t e a d i f f e r e n t t h i n g i s what we g e t from F i f we c a r r y o u t the t h r e e sub- s t i t u t i o n s c o n s e c u t i v e l y : f i r s t r e p l a c e x by P ( l e a v i n g y , z u n a l t e r e d ) , 1 t h e n r e p l a c e y by P2 ( l e a v i n g x , z u n a l t e r e d ) , t h e n r e p l a c e z by P 3 ( l e a v i n g X , Y u n a l t e r e d ) . We o b t a i n 6 . 3 A b b r e v i a t i o n . Formulas a r e o f t e n p r e s e n t e d by means of a p h r a s e l i k e t h i s : F i s t h e f o r m u l a where u i s a n a b b r e v i a t i o n f o r f h g

(13)

What i s meant by t h i s , i s t h e formula

One might a l s o s a y t h a t i t i s t h e e f f e c t of s u b s t i t u t i o n : t h e n we s a y t h a t u i s a v a r i a b l e , and u i s r e p l a c e d by g e x . A d i f f e r e n c e w i t h g e n e r a l s u b s t i t u t i o n , however, i s t h a t we a r e n o t supposed t o l e t u a b b r e v i a t e a formula c o n t a i n i n g a n o t h e r u.

A b b r e v i a t i o n goes beyond t h i s , however. The symbol used f o r a b b r e v i a t i o n may be something of non-zero i n d e g r e e . L e t us t a k e t h e c a s e of i n d e g r e e 2. We may speak of t h e f o r m u l a

and s a y t h a t p ( u , v ) i s an a b b r e v i a t i o n f o r

( 6 . 3 . 4 )

f g

The a b b r e v i a t i n g symbol p c a n n o t be c o n s i d e r e d a s a v a r i a b l e i n t h e s e n s e of t h e s y n t a x of CV, f o r i t h a s i n d e g r e e 2. What we mean by t h e above p h r a s e (11(6.3.3), where p ( u , v ) s t a n d s f o r ( 6 . 3 . 4 ) " ) i s of c o u r s e t h e formula L e t u s i n t r o d u c e t h e term " i n d e g r e e of an a b b r e v i a t i o n " . The a b b r e v i a t i o n of ( 6 . 3 . 4 ) by p ( u , v ) i s s a i d t o have i n d e g r e e 2, t h e one i n ( 6 . 3 . 1 ) i s s a i d t o have i n d e g r e e 0 . I n C X 4 ~ t h e r e i s something t h a t p l a y s t h e r 8 l e of a b b r e v i a t i o n s of i n d e g r e e 0 and t h e r e i s something t h a t p l a y s t h e r 8 1 e of a p a r t i c u l a r c a s e of i n d e g r e e 1 . The p a r t i c u l a r c a s e i s t h a t p(u) a b b r e v i a t e s a f o r n u l a t h a t c o n t a i n s u o n l y on t h e e x t r e m e r i g h t , l i k e

(14)

The use of more general cases (including indegree >

I)

might lead to extensions of CA$wq, some of which are not essentially more difficult than CA$wn itself, but they require a rather unpleaseant system of notation. They will not be considered in this paper.

An

LSP-book (cf. [ 2 ] ) is nothing but a game of abbreviations of various indegrees. We give an example, where two constants p,q (of indegree

2

and I, respectively) are considered to be primitive, i.e. p and q are no abbreviations for anything else. Next we write a list of abbreviations:

(there happens to be an interpretation which is interesting, but irrelevant at the moment: u,v are propositional variables, p stands for conjunction, q for negation, r for disjunction, s for implication, t for equivalence).

The abbreviations in a "book" like (6.3.7) can be eliminated in various ways and lead to "normal forms" (which contain no other constants than primitive ones). The question of the existence and uniqueness of these normal forms is something most people take for granted! A theory for this will be one of the topics to be treated in a forthcoming Ph.D. thesis by D. van Daalen.

6.4 Shifting substitution and abbreviation from metalanguage to language. If CV

is considered to be the "language" then substitution and abbreviation are expressed in terms of a metalanguage, i.e. a language that speaks about CV.

One might try to extend a language like CV with a symbolism that produces some of the effects of substitution and abbreviation.

Something in this direction is done if the language is extended in such a way that a complete LSP-book (like (6.2.7))is considered as an expression

in the language.(Actually LSP does a bit more: it also expresses that some constants are primitive; in the case of (6.3.7) the book has to start with the lines p(u,v) :=

PN,

q(u) :=

PN).

Quite a different point of view is taken in lambda calculus. We introduce

(15)

I f we p u t A x i n f r o n t of t h e formula ( 6 1 . ) , c o n t a i n i n g t h e v a r i a b l e x , we i n t e n d t o d e s c r i b e t h e " f u n c t i ~ n " t h a t maps x i n t o ( 6 . 1 . 1 ) . A f t e r t h a t , we no l o n g e r admit a n y t h i n g t o be s u b s t i t u t e d f o r x , which i s now c a l l e d a bound v a r i a b l e ; t h e o t h e r v a r i a b l e s a r e c a l l e d f r e e ,

Connected w i t h t h e a d d i t i o n of A's, we e n r i c h o u r s y n t a x w i t h symbolism f o r " a p p l i c a t i o n t t . I t t r i e s t o d e s c r i b e what we g e t i f we s u b s t i t u t e something, l e t us s a y k ( c , y ) , f o r

x

i n ( 6 . 1 . 1 ) . I n A-calculus we w r i t e what can be ccm- s i d e r e d a s t h e i n s t r u c t i o n f o r s u b s t i t u t i o n . The i n s t r u c t i o n s a y s :

T h i s h a s t o be i n c o r p o r a t e d i n t h e s y n t a x . L e t u s t a k e a c o n s t a n t 6 w i t h i n d e g r e e 2 (6 has t o b e "new": i t d i d n o t o c c u r e a r l i e r i n t h e l a n g u a g e ) . We w r i t e t h e i n s t r u c t i o n a s

The n e x t s t e p i s t h a t we a l s o admit S(F,G) i n c a s e s where t h e formula G

does n o t s t a r t w i t h A . T h i s e x t e n s i o n makes two t h i n g s p o s s i b l e : ( i ) t o u s e a b b r e v i a t i o n s , t o t h e e f f e c t t h a t G t u r n s i n t o a formula s t a r t i n g w i t h a lambda i f we c a r r y o u t t h e a b b r e v i a t i o n i n s t r u c t i o n s , and ( i i ) t o i n c o r p o r a t e t h i n g s which a r e , i n g r d i n a r y mathematical language, e x p r e s s e d by p h r a s e s l i k e : " l e t f be any f u n c t i o n ; i t s v a l u e a t c i s denoted by f ( c ) " . Here we w r i t e d ( c , f ) i n s t e a d o f f ( c ) .

We remark t h a t i n

[4]

t h e n o t a t i o n f o r a p p l i c a t i o n was A ( f , c ) . Most

p r e s e n t a t i o n s of lambda q a l c u l u s ( c f . [ l ] ) w r i t e f ( c ) . I n AUTOMATH ( c f . [ 1 ] ) t h e n o t a t i o n f o r A i s

[x]

( o r r a t h e r

[x

: S ] where S r e p r e s e n t s a t y p e ) and X f o r a p p l i c a t i o n c u r l y b r a c k e t s g r e used: { c ) f i n s t e a d of f ( c ) . T h i s AUTOMATH n o t a t i o n c o r r e s p o n d s t o w h a t w e g e t i f we draw t h e t r e e of ( 6 . 4 . 1 ) : we have t o i n f r o n t of t h e t r e e ( 6 . 1 . 2 ) . N e e d l e s s t o s a y , t h e u s e of X's and 6 ' s i s c u m u l a t i v e i n t h e s e n s e t h a t s e v e r a l X's and 6 ' s may o c c u r i n one and t h e same t r e e .

(16)

6.5 Namefree lambda calculus. Qne of the troubles of lambda calculus is that we have to make it clear which bound variables refer to which lambdqs. When we carry out

I substitutions we get duplication of bound variables and we might fear ambiguities.

A second thing is that the tradition in mathematics is that the name of the bound

I variable is unessential: a formula is not considered tq change if such a name is I

I altered, provided this does not conflict with names we already have in the formula.

I In [4] the names of variables are eliminated. We just write A instead of AxYiy,

...,

and every further bound variable is replaced by a positive integer indicating the "reference depth". This number tells us where to find the corresponding

A.

If the reference depth is k, we run down the tree and take the k-th A we encounter. If we get beyond the roof of the tree we count free variables (which have to be

,

I arranged in some order) instead of A'S.

Let us call this namefree lambda calculus C A E . Its syntax is the one of

I section

3

if we

just

omit the $'s, w's and n's. The rSle of the letter

6

is

just a formality: for every n

€IN

the ~ ( n ) is a constant of indegree 0. "~ssentially"

I

5

(n) is the same thing as n.

6.6

Beta reduction. In lambda calculus there is no automatic identification between the instruction for substitution and the effect of the substitution. The effect of the instruction (6.4.1) is

We say that (6.6.1) is obtained from (6.4.1) by beta reduction.

6.7 Lambda calculus with reference transgorming mappings. If we think of lambda calculus formulas as strings that are handled by a machine, the process of substitution is less simple than the intuitive idea of replacing all x's by

some other expression. What we have to do is connected with recursive definitjon of substitution. This recursivity is explained by an example. If we have to replace all x's by

P

in the formula

/ Q

f L R

(where Q and 8 stand for trees) then we replace all x's by P in

?

(effect

Q

) ,

(17)

A s i m i l a r t h i n g h a s t o b e d e s c r i b e d i n o r d e r t o r e p l a c e a l l x ' s by P i n t h e formula X

Q.

Y

I n p r a c t i c e i t i s n o t always d e s i r a b l e t o c a r r y o u t t h e s u b s t i t u t i o n i n a l l b r a n c h e s of t h e t r e e . We may do i t i n some of t h e b r a n c h e s , and l e a v e i t a t t h e mere i n s t r u c t i o n i n t h e o t h e r b r a n c h e s . T h i s may i n v o l v e t h a t i n s t r u c t - i o n s l i k e ( 6 . 4 . 2 ) , which c a r r y a lambda, have t o jump o v e r o t h e r lambdas. I n combinatiop w i t h t h e namefree n o t a t i o n t h i s c r e a t e s t h e need f o r r e f e r e n c e t r a n s f o r m i n g mappings ( s e e [5] ) . The i d e a i s t h a t we a t t a c h , a t v a r i o u s p o i n t s of a t r e e , mappings 0 o f N i n t o N ( s y n t a c t i c a l l y we do t h i s by a t t a c h i n g a c o n s t a n t of i n d e g r e e 1 t o e v e r y 0 ; t h i s c o n s t a n t i s w r i t t e n a s $(f3)).' The r 8 1 e of t h e s e $ ' s i s i n h e l p i n g t o i n d i c a t e t o what X's e n d p o i n t s of t h e t r e e r e f e r . It works l i k e t h i s . We r e a d a t a n end-point t h e number n. We r u n down t h e t r e e . I f we e n c o u n t e r a X w e s u b t r a c t 1 , b u t i f we e n c o u n t e r a

I f we have, e . g . ,

0 we a p p l y t h a t 0

.

and i f 8(2)=4 t h e n t h e 5 ( 5 ) r e f e r s t o t h e 3'd f r e e v a r i a b l e . T h i s c a l c u l u s c a n b e c a l l e d CAE$. We c a n d e s c r i b e

i t

a s i n s e c t i o n 3 , j u s t o m i t t i n g t h e w ' s and q ' s . And we can p r q v i d e i t w i t h t h e r e d u c t i o n o p e r a t i o n s A 1 , 2 , 4 , 6 , 7 , 8 , 9 and B 1 , 2 , 3 , 6 , 7 , 1 0 , 1 1 of s e c t i o n 4 ( i . e . a l l t h o s e r e d u c t i o n s which do n o t c o n t a i n w's o r q ' s ) . Note < h a t r e p e a t e d u s e of t h e A-reductions s h i f t s t h e @ ' s towards t h e end-points of t h e t r e e , where t h e y v a n i s h on b e h a l f of Al,A2,A3.

The f o r m u l a s of CXc$ t h a t do noF c o n t a i n any $ ' s , form t h e subsystem CAE ( s e e s e c t i a n 6.5). We can p r o v i d e CX( w i t h a s e t of r e d u c t i o n r u l e s , v i z .

where ~ * 7 i s o b t a i n e d from B7 i f we r e p l a c e t h e right-hand s i d e by t h e reduced form r f (where a l l $ ' s have been pushed t o t h e end-points of t h e t r e e , s e e s e c - t i o n 5 ) . There i s no e q u i v a l e n t of B4, where a $ o c c u r s on t h e l e f t . We s h a l l comment on t h i s B4 i n s e c t i o n s 6.8, 6.19 aad 6.20.

6.8 B e t a r e d u c t i o n i n C A E . The b e t a r e d u c t i o n d e s c r i b e d i n 6.6 c a n be c a r r i e d o u t i n C A E by means 05 a sequence of s m a l l e r s t e p s . I n o r d e r t o show how t h i s works, we s t a r t i n f o r m a l l y w i t h a n example t h a t i s n o t namefree. S t a r t i n g from

(18)

we proceed by single-step operations:

and this means that some of the x's have been replaced by P and some others have oat. The single-step operations have the effect that the instructions

is shifted to the endpoints of the tree. 6

X

X

Actually we have cheated when passing from (6.8.1) to (6.8.2),taking several steps at a time. If we stick to our single-step list of section

4,

we have to proceed like this:

It will be clear how beta reduction is effectuated by means of a sequence of these single-step operations, shifting all instructions

(6-X

pairs) to- wards the end-points.

In the name-free version (with I$(@)'s) of sections

3

and 4, this shift of substitution instructions is described by the B-reductions (except B5,B8,B9 which contain w and rl). It is not possible to shift these instructions (6-A pairs) over a $ ( @ ) , so occasionally these $(€))Is have to be shifted first.

(19)

The reduction B4 does not have its equivalent in CAE. Stated in popular terms, B4 says that a definition (a 6-A pair) may be cancelled if there is an indication (directly following that 6-A pair) that no reference to that definition will ever be made.

If

we start shifting the (J'S to the end-points

(i.e. if we start evaluating The reduced form) this advantage gets lost. The

6-X

pair can still be cancelled, but not without a long sequence of B-reductions, shifting 6-A pairs to the end-points where they vanish on behalf of B1 and B2. For further comments on B4 see section 6.19.

Substitution was described in [41 and [5] by means of a recursive process with things corresponding to our reduction steps Al-B11 as basic ingredients. Yet there are differences. In [4] and [5] substitution is described in the metalanguage, and not by means of substitution instructions in the formulas themselves. Another differerence is that in [4] and [5] substitutionis described for a number of variables, and not just for one at a time.

6.9 The normal form problem.Aformula inCA6 is said to be normal if it admits no reductions of our list of section 4. The normal form problem asks: starting from a formula, it is possibleto arrive at a normal form by means of a number of

reduction steps? The answer is not always affirmative. Church's well-known example, in our present notation, is

The only possible reduction is B10,leading to

By means of two applications of B3 we get back to (6.9.1) again, and so there is an infinite reduction sequence.

(20)

It is a bit more troublesome to show that every reduction sequence is infinite. (This bit of trouble is the price we have to pay for our single- step policy!). We do it for the sake of curiosity. The formulas we can get are characterized by pairs (m,n) of nonnegative integers. As an example we draw formula (3,2):

.

In the generalcase there are m branches

&-X-S(I)

on the left and m on the right. Possible reductions are:

Formula (6.9.1) is (0,O). It is obvious that no reduction sequence ever terminates.

6.10 Diamond properties and the Church-Rosser theorem. Two formulas F,G of CAE$ are called equivalent if there is a chain F=P F

,...,

F = G such that for

0' 1 n

each i

(I

s i

<

n) either F reduces to F (by one of the reductions of

i- 1 i

our list) or F. reduces to F

.

We say that F has a reduction chain to G

1 i- l

if we have, with the same notation, that (for all i) Fi

-

]reduces to Fi. We also say that F has a reduction chain to G if that chain is empty, i.e. if F=G.

The Church-Rosser proposition for this system says that if F and G are equivalent then

H

exists such that F and G have a reduction chain to

H.

It is very close to the Church-Rosser theorem in ordinary lambda calculus. We shall prove it in section 6.21 (theorem 6.21.2). That proof depends on having the Church-Rosser property for ordinary lambda calculus. Needless to say, it would be nicer to have a proof that sticks to the small reduction steps of our calculus, in particular since that would look promising for generalization to the more complicated system C X C $ ~ ~ .

(21)

A particular case of the Church-Rosser theorem is the diamond property

for reduction chains. It says: if there are reduction chains from

F

to F

1 l

and from F to F then there is an

H

with reduction chains from

F

to

H

and

2 I

from F to

H.

The Church-Rosser theorem easily fol.lows from this special 2

case.

We also consider a

-

weak diamond property: If there are single-step reductions from

F

to

F

and from

F

to

F

then

H

exists with reduction

1 2

chains from P to H and from F2 to

H.

This weak diamond property is

1

easily established for our system CAE$, but unfortunately the Church-Rosser theorem does not follow from it (cf. [ 7 ] ) . For the weak diamond property of CXE$wq see section 6 . 2 2 .

6 . 1 1 Substitution and abbreviation in the metalanguage. Substitution and abbre-

viation have, to a certain extent, been built in by the passage from CV to CAE$ (cf. section

6.4).

Nevertheless we can again discuss in the meta- language what substitution (for the free variables) does to the formulas of CAE$, and we can use abbreviations when discussing these formulas. As to substitution, this was actually done in [ 5 ] .

6 . 1 2 Typed lambda calculus. In typed lambda calculus every bound variable is I

introduced as having a certain formula as its type. Along with it, there is a procedure for adhering a type to any formula, and for some reductions restrictions concerning the types are made.

We

do not gointo this here. We only mention how the typing of bound variables can be described in the syntax.

Insead of just a lambda we write, with a new symbol T of indegree 2:

.

P

-.?. -- C

,

where

P

is some formula.

T

X

In AUTOMATH this would be read as [x : P I

... .

6 . 1 3 What things can be abbreviated in CX<$? In 6 . 4 we explained how instructions for

abbreviation can be written inside the formulas as soon as we have the lambda notation (e.g. in CAE or in CAE$).

A

combination like (6.4.2) can be considered to define x as an abbreviation (in this case it abbreviates k L Y ; the fact that this example is

-

not in the namfree calculus, does not matter). The kind of abbre- viation is the one mentioned in (6.3.1) (the case of zero indegree). The case of non-zero indegree can also be dealt with, but in an indirect way, reduced to zero indegree. Instead of abbreviating, e.g.

(22)

( i . e . t h e example of ( 6 . 3 . 4 ) ) we d e f i n e , a s a n a b b r e v i a t i o n of z e r o i n d e g r e e .

I n s t e a d of l a t e r u s e of p(R,S) (where R and S a r e f o r m u l a s ) we have S(S, S ( R , P ) ) .

I n AUTOMATH n o t a t i o n , ( s e e s e c t i o n 6.4) t h i s r e a d s {S]{R)P.

6.14 Segments. I n a d d i t i o n t o what was i n d i c a t e d i n s e c t i o n 6.13, t h e r e a r e , however, s t i l l q u i t e d i f f e r e n t t h i n g s we want t o a b b r e v i a t e . One t h i n g i s a s t r i n g l i k e {S){S2}{S3}{S }. I f i t o c c u r s more t h a n once, we wish t o a b b r e v i a t e i t . Yet i t

4

i s n o t a formula b u t a p a r t of a formula, a c t u a l l y a beginning segment. I n AUTOMATH we have many c a s e s where we would l i k e t o a b b r e v i a t e s t r i n g s

-

of a b s t r a c t o r s l i k e

[x

: A t ]

[y

: A 2 ] [ z : A ] ( a l s o c a l l e d t e l e s c o p e s ) . 3 I n t r e e n o t a t i o n ( c f . s e c t i o n ( 6 . 1 2 ) ) t h i s i s t h e segment I f we a b b r e v i a t e (6.14.1) by Q , t h e n f y i s t o be a b b r e v i a t e d by

T h i s i s s t r a n g e : t h e x , y , z r e f e r t o

X X

X

which a r e hidden i n t h e symbol q .

X Y Z

Each time t h e q i s used,we have t o c r e a t e new dummy v a r i a b l e s , s o t h i s i s a n obvious c a s e f o r namefree c a l c u l u s .

We s h o u l d c e r t a i n l y n o t confuse t h i n g s l i k e (6.14.2) w i t h a b b r e v i a t i o n s of i n d e g r e e 3 ( t h e n t h e r e i s no q u e s t i o n of b u i l t - i n lambda').

(23)

Roughly speaking, segments are trees which are open-ended on the extreme right, like (6.14.1). Another example is the tree representation of the string

We shall use the symbol UJ to represent the open end on the right. So

6 x f

is a segment. These w's may also occur in other branches, like

The notation of the w's is a preliminary one; in section 6.17 we shall explain the way we actually use the w f s in our syntax.

Abbreviation and reference to abbreviation takes place as follows. Let us give the segment (6.14.3) the name q(or rather, r, refers to (6.14.3) without the w on the extreme right), then r, has become a symbol of indegree 1. In tree form

(not yet namefree) we can have

and we indicate what we get if the two n-references are replaced by their definition:

Note that we get two new dummies s and s The s,'s in (6.14.4) refer,

1

2'

(24)

r e v e a l what names a r e t o b e g i v e n t o t h e v a r i o u s c o p i e s o f s t h a t a r i s e when t h e n ' s a r e r e p l a c e d by t h e i r d e f i n i t i o n .

The r e a d e r may wonder why we h a v e n o t removed t h e i n s t r u c t i o n ( i . e t h e

I

p a r t

-

) a f t e r h a v i n g c a r r i e d i t o u t . The answer i s t h a t ( 6 . 1 4 . 4 ) i t s e l f i s a segment, and p o s s i b l e l a t e r i n s e r t i o n s of t h a t segment i n t o some t r e e may i n v o l v e f u r t h e r r e f e r e n c e s t o q .

6 . 1 5 Towards C X < + w n . The e x t e n s i o n of CAE,$ t o C A < + w q i s j u s t t h i s a d d i t i o n of w's !

and q ' s . The r e f e r e n c e s t o o r d i n a r y v a r i a b l e s a r e d i f f e r e n t from t h o s e t o s e g m e n t s , and y e t i n t h e n a m e f r e e c a l c u l u s t h e y a r e t r e a t e d a s e q u a l s : a n i n t e g e r n > 0 s t i l l r e f e r s t o t h e n - t h X we meet when r u n n i n g down t h e t r e e . Only, when p a s s i n g a n 0 ( r e f e r e n c e t o a segment) we h a v e t o r e a l i z e t h a t i t s t a n d s f o r s o m e t h i n g h a v i n g number of lambdas. So t o e v e r y Q we a d h e r e ( a p a r t

f r o m t h e i n t e g e r t h a t t e l l s u s t o which

X

t h i s 0 r e f e r s t o ) a n o n n e g a t i v e i n t e g e r k : i t s w e i g h t . Taking a f r a g m e n t o f a t r e e a s a n example, we show by means of d o t t e d a r r o w s what t h e i n t e g e r s r e f e r t o

4

%.

- -

- - - A - \ -

--

,.

- -

2-

- -

Over t h e 0 we have drawn t h r e e d o t s ( r e p r e s e n t i n g what happens i f t h e s u b s t i t u t i o n i s c a r r i e d o u t : t h e n we g e t t h r e e l a m b d a s ) . L e t u s c a l l t h e s e d o t s t h e " r e f e r e n c e d o t s " . The 3 on t h e e x t r e m e r i g h t r e f e r s t o t h e m i d d l e d o t .

6.16 The r o o t d i s t a n c e of a n w . I n t h e f o r m u l a s we s h a l l d e a l w i t h , e a c h w c o r r e s p o n d s t o a c e r t a i n d e l t a t o b e c a l l e d i t s r o o t . I f we s t a r t a t a n u and r u n down t h e t r e e , t h e n we g e t , s o o n e r o r l a t e r , t o a S i n t o which we e n t e r t h r o u g h t h e upper one of t h e two b r a n c h e s t h a t e n t e r from t h e r i g h t .

(25)

This 6 is called the root of w; here it is indicated by means of a dotted arrow. The number of lambdas we meet when travelling down from u to its root (counting an q(k,m) for k lambdas) is called the root distance of a; here it is

5.

The root distance of is easily seen to be equal to p(t) (see section 3), where t is the tree growing on that same upper branch that enters the root 6 from the right, viz.

X

8 r1(?,7)

The root of an w is invariant under the operations of our list of section 4, but the root distance is not! In the example (6.16. I), the 6-A on t.he left might shift into the branches of the next '6 (i. e. the root of a), and increase the root distance.

In the example (6.15.1) the weight of the r1(3,4) (i.e. the number 3) is equal to the root distance of the w in the 6-), branch we are supposed to substitute for the

n .

So upon substitution (which can be effected by means of a number of single-step operations, cf. section

6.8)

we get three X'S on the places of the

three dots. Unfortunately this cannot be maintained. As we saw above, local

operations on the 6-w branch can alter the root distance, and far away "customers" like our q(3,4) are in no way informed about this. They are not even interested. If a 6-X pair enters into the 6 - w - branch (as indicated above), then the cus- tomers have no interest in referring to it: they keep referring to the &-A pair that shifts into the other branch of the 6. The system of reference transforming $(@)Is will see to it that all references (like the 3 pointing at the middle dot

in

(6.15.1)

keep referring to the proper lambda's, even if the root distance has

changed.

The w(k,O)'s: We shall now explain how we actually write our syntactically, and why we do it that way.

For various reasons it is desirable to write the weight of the customers of a 6 - ~ branch at the spot where we write the w. One advantage is that this makes it easier to express a correctness condition that formulates that all

customers for one and the same branch have the same weight. Another reason is the fact that this number plays a r6le in the 0's to be introduced presently.

As stated before (section 6.7) the $(o)'s can be pushed towards the end- points of the tree by means of the A-reductions. But we can no longer say that the $ ( @ ) ' s vanish there (as we said in section 6.7 concerning CAE+). If they

(26)

g e t t o an w t h e r e i s no r e d u c t i o n r u l e by which t h e y d i s a p p e a r . And a c t u a l l y t h e y should n o t : t h e y have t o s t a n d by f o r t h e p o s s i b l e customers, and we cannot p a s s t h e 0 ' s t o t h e customers a s long a s we do n o t know t h e customers. But we have f i x e d t h e weight k of t h e customers ( o t h e r customers w i l l n o t be a c c e p t a b l e ) and we know t h a t t h e s e customers w i l l o n l y r e f e r t o t h e k r e f e r e n c e d o t s ( c f . t h e t h r e e r e f e r e n c e d o t s i n ( 6 . 1 5 . 1 ) ) . T h i s means t h a t i f we have s h i f t e d t h e + ( 0 ) n e x t t o a n w of weight k , t h e n no customer w i l l e v e r be i n t e r - e s t e d i n t h e v a l u e of 0 ( j ) i f j > k .

For t h e s e r e a s o n s we have decided t o w r i t e w(k,O) (where 0 h a s domain { I ,

...

k}) i n o r d e r t o keep t h e e s s e n t i a l p a r t of 0 and t o d i s c a r d t h e r e s t . From now on we can s a y a g a i n t h a t a l l $ ( 0 ) d i s a p p e a r a t a l l e n d - p o i n t s . For t h e c a s e of a n endpoint w t h i s i s e x p r e s s e d i n A3.

We now p h r a s e t h e " i n t e r n a l r e f e r e n c e c o n d i t i o n " (IRC). The p o t e n t i a l "customers" of w(k,0) i n d i c a t e one of t h e r e f e r e n c e s 0 ( 1 ) , . . . , 0 ( k ) . We can t r a c e where t h e s e r e f e r e n c e s r e f e r t o , j u s t by r e a d i n g t h e X's, n ' s and + ( O ) ' s on t h e way down. They may r e f e r t o X's, p o s s i b l y t o A's hidden i n an

n ( t h e " r e f e r e n c e d o t s " of t h e q), l y i n g between t h e w a n d i t s r o o t 6 : i n t h a t c a s e we speak of i n t e r n a l r e f e r e n c e s . They may a l s o r e f e r t o X's

beyond t h a t 6 (even t o f r e e v a r i a b l e s ) : t h e n we speak of e x t e r n a l r e f e r e n c e s . We remark t h a t t h e r e i s n o t much u s e f o r e x t e r n a l r e f e r e n c e s . The cus- tomers do n o t need them: t h e y can r e f e r r o t h e s e lambdas d i r e c t l y , w i t h o u t p o i n t i n g a t t h e d o t s .

We s a y t h a t a formula ~ E s a t i s f i e s I R C i f T i t c o n t a i n s no w(k,0) where any of 0 ( 1 ) ,

.

. .

,O(k) i s e x t e r n a l . (Note t h a t we do n o t f o r b i d t h e ~ o s s i b i l i t y t h a t some w h a s no r o o t a t a l l ) .

I t i s e a s y t o prove t h e f o l l o w i n g theorem by checking A I - B I I :

Theorem 6 . 1 7 . 1 . I f ~ E T , t t l , and i f t s a t i s f i e s I R C , t h e n t , s a t i s f i e s I R C .

The IRC w i l l p l a y a r z l e i n t h e diamond p r o p e r t y ( s e c t i o n 6 . 2 2 ) .

6 . 1 8 F u r t h e r comments on r e d u c t i o n s . I n

-

C h g we a l r e a d y had t h e r e d u c t i o n B3, which ex- p r e s s e s t h a t a d e f i n i t i o n ( i . e . a 6-A air) c a n b e d i s c a r d e d i f i t i s obvious from t h e n e i g h b o u r i n g e t h a t no r e f e r e n c e w i l l e v e r b e made t o t h a t d e f i n i t i o n . Now t h a t w e have w(k,0) ' s , we can a l s o say t h i s f o r a 6-1 p a i r t h a t g e t s i n f r o n t of w ( k , @ ) , i n c a s e s where none of t h e v a l u e s 0 ( 1 ) ,

...,

O(k)

(27)

r e f e r s t o t h e A of t h a t p a i r . I n o t h e r words, t h e 6-w p a i r c a n be d i s c a r d e d i f none of t h e s e v a l u e s e q u a l s 1 . That i s e x p r e s s e d i n r e d u c t i o n r u l e B5.

The replacement of an q by i t s d e f i n i t i o n i s e x p r e s s e d i n B9. T h i s r u l e g e t s i n t o e f f e c t o n l y i f t h e 6-A p a i r i s r i g h t i n f r o n t of t h a t

n.

A t t h a t moment t h e r o o t d i s t a n c e of t h e p ( k , 8 ) i s p ( t ) . Now r e q u e s t s coming from t h e r i g h t have t o be t r e a t e d a s f o l l o w s . I f t h e y a r e r e f e r e n c e s j w i t h j I k , t h e y have t o be r e p l a c e d by 8 ( j ) . I f t h e y a r e > k t h e y were n o t supposed t o p o i n t a t one of t h e k d o t s , b u t jump o v e r them. S i n c e t h e number of X's we a c t u a l l y s u b s t i t u t e i s p ( t ) , and n o t n e c e s s a r i l y e q u a l t o t h e weight k , we have t o c o r r e c t t h e s e r e f e r e n c e s by a d d i t i o n of p ( t ) - k . The 8 and 8 1 2

a r e an obvious m a t t e r of h o n e s t a d m i n i s t r a t i o n of r e f e r e n c e s .

Rules A 5 and B8 e x p r e s s what happens i f a I $ ( @ ) o r a 6-A p a i r jumps o v e r a n n(k,m). There we s e e t h a t t h i s

n

j u s t behaves l i k e k lambdas ( c f . A7 and B7)

.

The e f f e c t of B 9 i s t h a t q ( k , l ) i s r e p l a c e d by a copy of t h e 6% b r a n c h , i . e . by a copy of t h e segment i t r e f e r s t o . A t t h i s moment we e x p l a i n a t e r - minology which c o r r e s p o n d s t o a s i m i l a r s i t u a t i o n i n ALGOL p r o c e d u r e s . We d i s c e r n amongst g l o b a l , l o c a l and f o r m a l v a r i a b l e s . We r e f e r t o t h e p i c t u r e

( 6 . 1 5 . 1 ) . The g l o b a l v a r i a b l e s a r e t h o s e whose X's a r e s i t u a t e d t o t h e l e f t of t h e 6 on t h e l e f t . From p o i n t s i n t h e 6-w branch ( i n c l u d i n g s i d e branches) t h e r e can b e r e f e r e n c e s t o t h e s e g l o b a l v a r i a b l e s . I f we r e p l a c e t h e q by t h e 6-w branch t h e s e r e f e r e n c e s a r e j u s t t a k e n o v e r : we do n o t make c o p i e s of t h e s e g l o b a l v a r i a b l e s . Local v a r i a b l e s . a r e t h o s e whose A's l i e i n side-branches of t h e 6-w b r a n c h ( t h e y may a l s o be f o r m a l v a r i a b l e s i n t h e s e s i d e b r a n c h e s ) , and v a r i a b l e s w i t h A's i n t h e main branch a s f a r a s t h e y cannot b e r e f e r r e d t.0 from

t h e w(k,8) a t t h e end of t h e branch ( n o t e t h a t t h i s i s c o n t r o l l e d by 8 ) . Formal v a r i a b l e s a r e t h o s e i n t h e main branch which correspond w i t h t h e d o t s o v e r t h e

q . Some o f t h e s e a p p e a r a s lambdas, o t h e r s a r e hidden i n q ' s ( l i k e t h e n ( 2 , 5 ) i n ( 6 . 1 5 . 1 ) ) . Both l o c a l and formal v a r i a b l e s a r e copied ( i . e . r e p l a c e d by new ones) i f q i s r e p l a c e d by t h e segment. The d i f f e r e n c e i s t h a t from p o i n t s t o t h e r i g h t o f

n

no r e f e r e n c e s t o l o c a l v a r i a b l e s a r e p o s s i b l e ; r e f e r e n c e s t o g l o b a l v a r i a b l e s a r e p o s s i b l e indeed: t h e y a r e j u s t t h e r e f e r n e c e s t o t h e d o t s . From p o i n t s t o t h e r i g h t of q i t i s q u i t e p o s s i b l e t o r e f e r t o t h e g l o b a l

v a r i a b l e s , b u t t h i s i s n o t done by means of r e f e r e n c e s t o t h e d o t s . These

-

r e f e r e n c e s t o g l o b a l v a r i a b l e s a r e made i n e x a c t l y t h e same way a s i f t h e

n

had n e v e r been t h e r e .

We h a v e t o t a k e a p r e c a u t i o n w i t h t h e + ( 0 ) ' s b e f o r e r e p l a c i n g t h e

n

by t h e segment: we have t o r e q u i r e t h a t t h e r e a r e no + ' s i n t h e main branch ( i . e . on t h e l i n e from 6 t o w ) ; t h i s i s e x p r e s s e d by s a y i n g

i n

B9 t h a t a ( t ) s h o u l d

(28)

b e 1 ( s e e s e c t i o n 3 f o r t h e d e f i n i t i o n o f a). Such + ( e ) ' s i n t h e main b r a n c h make s e n s e f o r t h e s i d e b r a n c h e s , b u t we do n o t i n t e n d them t o a c t on t h e

c u s t o m e r ' s j ' s i f j > k ( t h o s e which h a v e t o b e c o r r e c t e d by a d d i t i o n of p ( t )

-

k ( s e e a b o v e ) . T h e r e f o r e we f i r s t h a v e t o push t h e s e $ ( @ ) ' s i n t o t h e s i d e b r a n c h e s (by A - r e d u c t i o n s ) , a n d t h e o n l y r e m a i n i n g o n e i n t h e main b r a n c h v a n i s h e s i n t o t h e w by A 3 . Once t h i s h a s been a c h i e v e d ,

-

a p p l i c a t i o n of B9 g i v e s j u s t what we w a n t .

One of t h e c o n d i t i o n s o f B9 i s t h a t t h e k i n w ( k , @ ) e q u a l s t h e k i n q ( k , l ) . A c t u a l l y we hope t h a t , i f we s t a r t w i t h " s e n s i b l e " f o r m u l a s , we g e t i n t o s i t u a t i o n s where t h e s e two k ' s a r e d i f f e r e n t . And a l s o we hope we n e v e r g e t i n t o a s i t u a t i o n a s d e s c r i b e d i n t h e l e f t - h a n d s i d e o f B9 i f ~ ( t ) f 1 , j u s t a s we hope t h a t B3 w i l l n o t o c c u r w i t h ~ ( t )

#

0 . We s h a l l r e t u r n t o t h i s i n 6.22. 6 . 1 9 D e r i v a b l e and s e m i d e r i v a b l e r u l e s . A r e d u c t i o n ' i s cal1e.d d e r i v a b l e i f i t s e f f e c t c a n b e o b t a i n e d by a f i n i t e c h a i n o f r e d u c t i o n s > from o u r l i s t 1 A I - B l l . A s i m p l e example of s u c h a r u l e i s i f 8 i s t h e i d e n t i t y ( e ( j ) = j f o r a l l j ) . We c a n s h i f t t h i s + ( 8 ) t o w a r d s t h e e n d - p o i n t s where i t v a n i s h e s a c c o r d i n g t o AI,A2,A3,A4, u n l e s s i t v a n i s h e d u n d e r way a c c o r d i n g t o A6. A r u l e i s c a l l e d s e m i d e r i v a b l e i f i t s e f f e c t c a n b e o b t a i n e d by e q u i - v a l e n c e w i t h r e s p e c t t o t h e r e d u c t i o n s > from o u r l i s t A l - B I I . I n o t h e r 1 words, i f f o r a l l r e d u c t i o n s F > G produced by t h e r u l e t h e r e i s a c h a i n F = F O , F , ,

. ..

,F =G s u c h t h a t f o r e a c h i (1 5 i

s

n) e i t h e r F > F . o r n i - 1 1 1 F . > F ( c f . s e c t i o n 6 . 1 0 ) . 1 1 i - 1 An example of a s e m i d e r i v a b l e r u l e t h a t l o o k s q u i t e u s e f u l , i s i f m e w , where 8 i s d e f i n e d by @ ( I ) = m , 8 ( j ) = j

-

1 i f j > 1 . A c l e a r r e a s o n why i t c a n n o t b e d e r i v e d i s t h a t , i f t h e 6 - ~ ( m ) - A o c c u r s i n a 6-w b r a n c h , i t may happen t h a t t h e l e f t - h a n d s i d e of ( 6 . 1 9 . 2 ) s a t i s f i e s I R C ( s e e s e c t i o n 6.17) w h e r e a s t h e r i g h t - h a n d s i d e d o e s n o t .

(29)

Another semiderivable rule that may turn out to be quite useful is the long distance variant of B3 (and there is a similar variant of B9). It is not a rule that can be evaluated locally like the rules Al-Bll, and therefore we describe it in a different style. Let

[(k)

be a point that refers to the

t

of some combination 6 L X . Assume that on the path down from the [(k) to

A

we have no $(O)'s. Then the long distance rule says: replace this ~ ( k ) by

$(€I )-t where 0 is defined by ek(j) = j+k for all j

>

1 .

k k

We can also phrase a slightly stronger long distance rule by admitting $(G)'s between the X and the [(k)

,

provided that it is possible to find a B* such that the replacement of [(k) by +(e*)---t still gives the proper correct- ions to all the references occurring in t.

These long distance variants of B3 can be very practical: they enable us to apply a definition at a place where we want it, without the obligation to apply it simultaneously at all other places of the tree.

A further example of a non-local semiderivable rule is an extension of B4. The rule says that we may discard a 6-A pair (just replacing it by $(0 ) with

1

~{j) = j

-

1 for all j > 1, 01(1) arbitrary if there is no demand (see 6.20). As a last example of a semiderivable rule we mention that if we cross out B4 from our list Al-Bll, then B4 becomes semiderivable.

6.20 The system CA[wq. The set T of section 3 has

a

subset

R

(section 5) consisting of all $-free formulas. In

R

there is no question of reductions Al-A9, nor of B4. The reductions Bl,B2,B3,B5,B6,BlO,BlI can be carried out in R, but B7,B8,B9

*

*

take us outside

R.

Let us define the reduction B 7 (and similarly B 8, B*9) as follows: first apply B7, then apply rf (the operator of section

5)

to the right- hand side. Now B*7, ~ * 8 , ~ * 9 transform formulas of

R

into formulas of R.

Let us call the system CAcwq, i.e.

R

with reduction rules

Something like B4 can be formulated in CX[wn as a derivable rule. It says that a 6-X pair can be cancelled if there is no demand for it (provided that all references occurring in the formula are adjusted because of the disappearance of a lambda). "No demand" means: (i) none of the end-points refer to this lambda, and (ii) for no w(k,O) in the formula there is a j (with

I

5 j

a

k) such that

*

O ( j ) refers to this lambda. Let us call this derived rule B 4.

In the theorems of section

5

it was stated that from every formula t in T there is a sequence of reductions leading to rf(t), and that this is the only

(30)

element of R w e can ever reduce to. For many questions about T it suffices to study R. The following theorem is useful in this respect.

Theorem 6.20.1. If t ,t,. E T , and t > t in CA<+wq, then there is a

1 L 1 1 2

reduction chain from rf(t ) to rf(t ) in CXcwn (i.e.

R

with reductions

1 2

(6.20.2)).

We do not present a formal proof. The only case that requires some attention is the one where t reduces to t by B4. Then we have a 6-1 pair

1 2

followed by +(0) with 1

4

0@). Nor rf(tl) is no longer followed by such a +(0) In order to get from rf (t ) to rf(t ) we have to apply the operations of

1 2

(6.20. l), shifting the 6-?, pair to the end-points or towards the a's. The 6-X pair is annihilated there because the $ ( @ ) arrived there first.

From theorem 6.20.1 it can be seen that once we have the Church-Rosser theorem for CX<wq, we have it for CX<$wn. In 6.21 it is shown how this works

for CAE and' CAE$.

,21 The system CAE. Just as we got from CXc+wn to CXcwq in 6.20, we can get from

C A E + to C

AS.

The formulas of CAE form the set R consisting of all formulas I

'

of R which containno

w'

s or qls. I n the set R 1 we can consider the reductions

The difference of CX< with ordinary lambda calculus (e.g. in the form of C41 is very slight: in C41 the reductions are just @-reductions and not our present single-step @-reductions.

A full @-reduction (notation

> ) is

R

r-

carried out by taking some 6-A pair and pushing it to the end-points of the tree. So if t > t then WE can get from t, to t2 by means of a chain of

I @ 2

reductions > The converse is not true, but the following is easy to see: 1 '

if t l > I t2 then t exists with B-reduction chains from tl to t3 and from t2

3

to t It follows that if t > t then tl and t are @-equivalent (i.e.

3 ' 1 1 2 2

connected by a chain of > 's and < Is).

8 B

Theorem 6.21.1. (Church-Rosser theorem for CAE). If tl - t (equivalence 2

in the sense of then there is a t with reduction chains (in the sense 3

of from t to t and from t to t3

I 3 2

Proof. We know that if t > t2 then t and t2 are @-equivalent (see above),

(31)

s o i f t

-

t t h e n t and t a r e p - e q u i v a l e n t . We know t h e Church-Rosser 1 2 1 2 theorem f o r R l w i t h > ( s e e

143

f o r t h e n a m e f r e e f o r m u l a t i o n ) . So i f t

-

B 1 t 2 t h e r e i s a t w i t h r e d u c t i o n c h a i n s ( i n t h e s e n s e of > $ from t t o t and 3 1 3 from t t o t g . These r e d u c t i o n c h a i n s c a n b e r e f 2 i n t h e s e n s e of > T h i s p r o v e s t h e theorem. 1 '

Theorem 6 . 2 1 . 2 . (Church-Rosser theorem f o r CAE$) ( e q u i v a l e n c e i n t h e s e n s e of > ) t h e n t h e r e i s a 1 ned t o . r e d u c t i o n c h a i n s I f t 1

-

t 2 i n CAE$ t w i t h r e d u c t i o n c h a i n s 3

( i n t h e s e n s e of > ) from t t o t and from t t o t

1 1 3 2 3 '

P r o o f . L e t t

1

-

t 2 . By theorem 6.20.1 we h a v e r f ( t 1 )

-

r f ( t 2 ) i n CAE' ( n o t e t h a t r f ( t l ) and r f ( t ) c o n t a i n no w's and ~ ~ ' s , and t h a t t h e r e d u c t i o n c h a i n

2

d o e s n o t p r o d u c e s u c h w's and n ' s from nowhere: o u r r e d u c t i o n r u l e s h a v e no w ' s o r n ' s o n t h e r i g h t i f t h e y do n o t o c c u r on t h e l e f t ) . By theorem 6.21.1 we h a v e t w i t h r e d u c t i o n c h a i n s from r f ( t ) t o t and from r f ( t 2 ) t o t

3 1 3 3 '

S i n c e we h a v e a l s o c h a i n s from t t o r f ( t ) and from t 2 t o r f ( t 2 ) t h i s f i n i s h e s

1 1

t h e p r o o f .

6 . 2 2 Weak diamond p r o p e r t y f o r CAC$wn. We a r e s t i l l q u i t e f a r from p r o v i n g t h e Church-Rosser p r o p e r t y f o r ChE$wq, b u t p r o v i n g t h e weak diamond p r o p e r t y

( s e e s e c t i o n 6.10) seems t o b e t h e l e a s t t h i n g we c a n do.

The r e d u c t i o n r u l e s A l - B l l were j u s t d e s i g n e d t o s a t i s f y t h i s weak diamond p r o p e r t y i n t h e f i r s t p l a c e . The many c a s e s of t h e weak diamond p r o p e r t y t h a t a c t u a l l y a r i s e , were c h e c k e d i n d e p e n d e n t l y by R.Wieringa [ l o ] and L.S. v a n Benthem J u t t i n g . They showed t h e weak diamond p r o p e r t y f o r t h e sub-system c o n s i s t i n g of a l l f o r m u l a s of CAE$wq t h a t do n o t l e a d t o a d e a d l o c k ( a s d e f i n e d i n 6 . 2 3 ) . I n p a r t i c u l a r t h i s means t h a t I R C i s r e q u i r e d .

A c a s e where I R C d o e s n o t h o l d and t h a t g i v e s t r o u b l e i s

where 0 ( I ) = ] , 0 2 ( 1 ) = 1 , 0 ( 2 ) = 2 . I f we s t a r t a p p l y i n g B9 we g e t i n t o a

1 2

s i t u a t i o n where 8 ( 1 ) and 0 2 ( 2 ) r e f e r t o o n e and t h e same lambda (and t h i s 2

w i l l n e v e r change by f u r t h e r r e d u c t i o n s ) . I f we s t a r t a p p l y i n g B10 we n e v e r g e t i n s u c h a s i t u a t i o n by any f u r t h e r r e d u c t i o n s . For o t b e r c a s e s where dead-

locks g i v e t r o u b l e s e e

U

01.

-

6 . 2 3 C o r r e c t n e s s o f f o r m u l a s i n C X E 4 w r l . We s h a l l s a y t h a t a f o r m u l a i s a t a

(32)

(i) it is the left-hand side of

B3

with a(t)#O,

(ii) it is the left-hand side of 99 with o(t)#O or t# I-swlw(k,B)1

,

(iii) it does not satisfy the condition IRC (section

6.17).

A formula which is at a deadlock may still admit reductions.

We say that a formula t leads to a deadlock if there is a reduction I

sequence t > t >

...

> t such that t is at a deadlock.

1 1 2 1

1

n n

This definition is not very practical. We of course like to have a decision procedure that shows in a finite number of steps whether a given formula leads to a deadlock or not.

Actually we want more. We want to be sure we are dealing with formulas that do not lead to deadlocks if we apply operations which are not reductions but yet reasonable things in formula manipulations. We think of substitution of other formulas or segments for the free variables of t, or substitution of t into other formulas, also in cases where t is a segment.

We feel that a general notion of "correctness" should be -formulated in sucl a way that if we act "correctly" with "correct" formulas, we never run into a deadlock. Some indications of what might be done are to be Eound in the next sections.

6.24

Frames. In ordinary lambda calculus (let us say in CXS) it is a fundamental

question whether a formula is normalizable, i.e. whether it can be reduced to a form that does not admit any further reductions. Together with the Church-Rosser property, normalizability gives unique normal forms. In order to study normalization in typed lambda calculi, R.P.Nederpelt [ 9 ] developed a system in which a certain tree-shaped norm was attached to every formula, somehow indicating a frame of the expression serving as the type of that

formula.

He

showed that the possibility of attaching such frames ("normability-') guarantees normalizability.

In CX<$wq (or in CX<wq) there is the problem of finding guarantees again.+t deadlocks. The idea of attaching a kind of frame trees presents itself naturafil~: the frames have to indicate whether a variable refers to a segment or not, and if it does, in what manner that segment is composed of segments and other formulas. Digging deeper into this,we observe that the matter cannot be separated ff O m a kind of normability, and it seems to be appropriate to study deadlock-preven- tion and normalization simultaneously.

In the system we are presenting here, the frames will have a red root irF=l case of a segment, and a green root in case of other formulas. In the red-rooted :=frames the edges pointing to the root are divided into three groups, with i,j,k edg es, respectively.

A vague indication of what we intend, follows here. The first

Referenties

GERELATEERDE DOCUMENTEN

Als u zich ten doel stelt uw bedrijf krachtiger te maken zodat u ook in de toekomst een goed inkomen zult hebben, kunt u kiezen voor bijvoorbeeld één of meerdere van de

Zowel de recreatieve betekenis als de economische betekenis zijn verschillend voor het Zuiderpark en het Nationaal Park De Hoge Veluwe.. Bij de recreatieve betekenis wordt dit

Hierdie reg word ook deur die Grondwet gewaarborg en in hierdie studie kry jeugdiges die geleentheid om hulle onderwysbehoeftes te verwoord sodat aangeteken kan word

Dankzij hoge prijzen voor nuchtere kalveren en slachtkoeien bleef het saldo van de melkveebedrijven in het tweede kwartaal van dit jaar boven dat van de vergelijkbare periode

Absolute and average figures for accidents with victims, broken down according to the involved participants of slow traffic in the expe- rimental area in the

bijvoorbeeld voor de drieslag `modern humanistisch', `postmodern' en `laatpostmodern', die Vaessens introduceert om de naoorlogse literatuur te periodiseren), verwaarlozing van

Generally the role of the Qing Dynasty Consul-Generals in supporting the indentured Chinese labourers has been overlooked or, in the case of some authors such as Philip Snow,

Pancreatic involvement is rare]·5 This paper describes the pre- operative evaluation and surgical treatment of a patient with asymptomatic hydatid disease of the tail of the