Upper bounds for the length of normal forms and for the length
of reduction sequence in lambda-typed lambda calculus
Citation for published version (APA):
Bruijn, de, N. G. (1985). Upper bounds for the length of normal forms and for the length of reduction sequence in lambda-typed lambda calculus. Technische Universiteit Eindhoven.
Document status and date: Published: 01/01/1985
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.
August 12, 1985
M23
Revised form, September
20,
1985Upper bounds for the length of normal forms and for the length of reduction sequences
in lambda-typed lambda calculus
by N.G. de Bruijn
Department of Mathematics and Computing Science Eindhoven University of Technology
PO
Box 513, 5600MB Eindhoven, The Netherlands1. For notations and definitions, as far as not explained in this note itself, we refer to
[I].
Nevertheless it should be noted that for the material of the present note there is no substantial difference between the system of 111 and the system of[4].
Almost all ideasinvolved in this note are already in [4]; the only new
idea is to use Nederpelt's normalization proof for estimating the length of the normal forms. The estimate we give here for the length of the normal form is presented as a very fast growing function of the length of the given non-normal expression.
I r
is of the order of the diagonal of the Ackermann function.2.
We consider the minireductions of[l]
section 4, slightly generalized since we shall admit these operations with theu s e of AT-couples ( [ I ] s e c t i o n 4.3) i n s t e a d of j u s t AT-pairs ( [ I ] s e c t i o n 4.2).
A lambda t r e e w i l l be c a l l e d almost-normal i f e a c h one of
i t s AT-couples a d m i t s AT-removal ( [ I ] s e c t i o n 4.5). The i d e a w i l l be t h a t we s t a r t from a lambda t r e e , a p p l y a sequence of l o c a l b e t a - r e d u c t i o n s and hope t o end up w i t h an almost-normal lambda t r e e . From t h a t p o i n t onwards i t w i l l be a simple a c t i o n t o g e t t o a normal lambda t r e e , j u s t o m i t t i n g AT-couples u n t i l t h e r e a r e no more l e f t .
The t e r m "almost-normal" w i l l a l s o be used f o r a s u b s e t of t h e set of p o i n t s of a lambda t r e e . It w i l l mean t h a t t h i s s u b s e t c o n t a i n s no e n d - p o i n t s t h a t r e f e r t o t h e T-part of an AT-couple.
3 . The number of e n d - p o i n t s i n a lambda t r e e w i l l be c a l l e d i t s
l e n g t h . I f a lambda t r e e ( V , l a b ) i s s e m i c o r r e c t , i t has a norm, denoted by norm(V,lab) ( [ I ] s e c t i o n 5.9). T h i s i s a g a i n a lambda t r e e ; i t s l e n g t h i s l e n g t h ( n o r m ( V , l a b ) ) , and w i l l be a b b r e v i a t e d t o l n ( V , l a b ) .
The n o t i o n of norm was a l s o d e f i n e d f o r s u b t r e e s , and t h a t g i v e s r i s e t o t h e s i m i l a r e x t e n s i o n f o r I n .
I f a t r e e ( V , l a b ) i s r e p r e s e n t e d a s a formula P, we j u s t
w r i t e l n ( P ) i n s t e a d of l n ( V , l a b ) .
4. L e t u s d e v e l o p some t e r m i n o l o g y around t h e s t r u c t u r e of t h e main l i n e ( s e e [ l ] s e c t i o n 5.2) of a lambda tree. The r i g h t m o s t l a b e l on t h e main l i n e i s e i t h e r a dummy o r
t
,
a l l t h e o t h e r s a r e e i t h e r T o r A. I n t h e formula t h e s e T's and A's c o r r e s p o n d t o a b s t r a c t o r s[...:...I
and a p p l i c a t o r s<...>.
We c a n draw a g r a p h of t h e sequence i f we r e p r e s e n t T's and A's by l i n e segments w i t h p o s i t i v e and n e g a t i v e s l o p e , r e s p e c t i v e l y . An example i s shown i n f i g u r e1.
F i g u r e 1. Graph of TTATTAAATAATTTAATATTAATA
...
I n f i g u r e 1 we have drawn t h e T's a s heavy l i n e s i f t h e y a r e " v i s i b l e " from t h e l e f t , and t h e A's a s heavy l i n e s i f t h e y are v i s i b l e from t h e r i g h t . These v i s i b l e T's can be s a i d t o form t h e w e s t e r n f a c a d e , and t h e v i s i b l e A's t h e g a s t e r n f a c a d e . A l l t h e o t h e r A's and T's can be combined p a i r w i s e t o AT-couples.
This c o u p l i n g c a n be v i s u a l i s e d a s f o l l o w s : we c o n s i d e r t h e g r a p h s
as a l o n g i t u d i n a l s e c t i o n of a f o l d e d p a p e r s t r i p . Next w e a p p l y g l u e t o t h e u p p e r s i d e of t h e s t r i p and p r e s s t h e s t r i p
t o g e t h e r ( p r e s s i n g from t h e l e f t and from t h e r i g h t ) . Taking
t h e p r e s s u r e away, we s e e t h a t t h e AT-couples a r e p a s t e d t o g e t h e r , and t h a t w e s t e r n and e a s t e r n f a c a d e a r e u n i n t e r r u p t e d l i n e s
F i g u r e 2. Showing w e s t e r n f a c a d e , e a s t e r n f a c a d e , and AT-couples.
To e v e r y T and t o e v e r y A i n t h e main l i n e sequence t h e r e c a n be a t t a c h e d a p o s i t i v e number: t h e l e n g t h of t h e norm of t h e l e f t - h a n d s u b t r e e . O r , i n t e r m s of e x p r e s s i o n s i n s t e a d of t r e e s , t o t h e a b s t r a c t o r [x:P] we a t t a c h t h e number l n ( P ) , and t o t h e a p p l i c a t o r <Q> we a t t a c h l n ( Q ) . Note t h a t t h e s e norms a r e d e f i n e d o n l y by v i r t u e of t h e lower p a r t of t h e t r e e ; t h a t
p a r t g i v e s a meaning t o t h e t y p e s of t h e dummies i n v o l v e d i n P and Q.
S i m i l a r l y we can a t t a c h a v a l u e of I n t o t h e r i g h t m o s t end-point of t h e lambda t r e e , e i t h e r l n ( x ) , where x i s a dummy, o r l n ( ' C ) ( = I ) .
L e t [ x l : P l ] , . . . , [ x k : P k ] be t h e a b s t r a c t o r s of t h e w e s t e r n f a c a d e , and <Ql>,...,<Qm> t h e a p p l i c a t o r s of t h e e a s t e r n f a c a d e . L e t u s c a l l
--
5--
the open in^ value of our lambda tree,
the deficit of the sequence of abstractors and aplicators. The length of the norm of the rightmost end-point will be called the closing value.
We note that all terminology developed thus far for lambda trees, can be used for its subtrees too.
5. If a lambda tree is norm-correct
([I]
section 5.9) then in every AT-couple <Q>[x:P] we have ln(Q) = ln(P). Moreover we haveln([x:P]R) = ln(P)
+
ln(R), ln(<Q>R) = ln(R)-
ln(Q)>.By
the way, this shows that the purely accidental notationalsimilarity between "length of norm" and "natural logarithm" is not so unfortunate after all. The formation of [x:P]R can be felt as a kind of product, and <Q>R as a kind of quotient (with the denominator in front).
6.
The following theorem for norm-correct lambda trees can be proved by routine methods:Theorem 1. Let
E
be a subtree in a norm-correct lambda tree,-
let p be its opening value, d its deficit, q its closing value. Then we have
7. We i n t r o d u c e a s l i g h t m o d i f i c a t i o n of t h e n o t i o n of a l m o s t - n o r m a l i t y , t o be c a l l e d f r a c t u r e d almost-normality. L e t P be a lambda t r e e , and l e t i t be w r i t t e n i n t h e form WUd where W and U a r e sequences of a b s t r a c t o r s and ,
a p p l i c a t o r s , and CI: i s e i t h e r o r a dummy. L e t t h e e a s t e r n f a c a d e of W c o n s i s t of t h e a p p l i c a t o r s <Ql>,...,<Qm>.
W e s a y t h a t P i s f r a c t u r e d a l m o s t normal w i t h r e s p e c t t o W i f a l l i t s AT-couples admit AT-removals, p o s s i b l y e x c e p t f o r AT-couples of which t h e a p p l i c a t o r i s one of
<Ql>,.*.,<Qm>.
So i n ( h i u ~ t h e r e may o c c u r bound i n s t a n c e s of dummies which a r e bound by a b s t r a c t o r s i n U which form AT-couples w i t h one
of <Ql>,...,<Qm>. I f s u c h bound i n s t a n c e s do n o t o c c u r i n U i t s e l f ( l e a v i n g t h e f i n a l x a s t h e o n l y p o s s i b i l i t y ) , we can e x p r e s s t h i s by s a y i n g t h a t
WU
i s almost-normal.I f WIJU i s f r a c t u r e d almost-normal w i t h r e s p e c t t o W , and i f WIJ i s almost-normal, t h e n w e have two p o s s i b i l i t i e s :
( i ) The f i n a l & ' d o e s n o t admit l o c a l b e t a - r e d u c t i o n . I n o t h e r words, L'is e i t h e r C o r i t i s a dummy bound by an
a b s t r a c t o r t h a t d o e s n o t form a n AT-couple w i t h a n a p p l i c a t o r i n t h e e a s t e r n f a c a d e of W.
I n t h i s c a s e WUw. i s o b v i o u s l y almost-normal.
( i i ) The f i n a l c t ' i s a dummy x , bound by a n a b s t r a c t o r forming a n AT-couple w i t h some < Q j > from t h e e a s t e r n f a c a d e of W. L e t t h i s Qj have t h e form
V T .
( C i s t o r a dummy). W a p p l y e l o c a l b e t a - r e d u c t i o n , which t r a n s f o r m s WUx i n t o W W 6.
I n t h i s s i t u a t i o n i t i s e a s y t o s e e t h a t
W U V C
i s f r a c t u r e d almost-normal w i t h r e s p e c t t o W. The dummies i nV 6
bound bya b s t r a c t o r s o u s i d e
V T
cannot g i v e r i s e t o b e t a - r e d u c t i o n , s i n c e V 6 i s a t r a n s p l a n t a t i o n of a p i e c e of W, and W i salmost-normal. But t h e dummies i n
V t
bound by a b s t r a c t o r s i nV Q
i t s e l f , c a n g i v e r i s e t o l o c a l b e t a - r e d u c t i o n s ; t h o s e a b s t r a c t o r s form AT-couples w i t h a p p l i c a t o r s on t h e e a s t e r n f a c a d e of WU.We s h a l l show t h a t
under t h e a s s u m p t i o n t h a t o u r lambda t r e e WUx i s norm-correct. According t o s e c t i o n 6 we have d e f i c i t ( U )
<
l n ( x ) . But t h e e a s t e r n f a c a d e of WU can c o n t a i n more t h a n t h e one of U :i t a l s o c o n t a i n s t h a t p a r t of t h e e a s t e r n f a c a d e of W t h a t d o e s n o t form c o u p l e s w i t h p i e c e s of t h e w e s t e r n f a c a d e of Ux. One s u c h p i e c e of t h e e a s t e r n f a c a d e of W i s <Qj>, mentioned above. T h e r e f o r e
S i n c e WU i s norm-correct we have l n ( Q j ) = l n ( x ) . And by
Theorem 1 we have d e f i c i t ( U )
<
l n ( x ) . So d e f i c i t ( U )<
l n ( Q j ) , and (1) f o l l o w s .8. It was shown i n [ 2 ] t h a t a lambda t r e e P of l e n g t h n s a t i s f i e s
'h- I
l n ( P ) 2
.
It f o l l o w s t h a t i f a lambda t r e e has l e n g t h n t h e nn-1
i t s d e f i c i t i s a t most n.2
.
T h i s e s t i m a t e i s rough; l e tu s w r i t e H(n) f o r t h e b e s t p o s s i b l e e s t i m a t e .
that any norm-correct lambda tree of length <n can be reduced, by repeated local beta-reduction (no AT-removals), to an
almost-normal form of length at most q. Then it is not hard to show that if
Rd
(whereR
is a sequence of abstractors and applicators andid
is either -G or a dummy) is a norm-correct lambda tree of length n then we can reduce the sequenceR
to an almost-normal form of length at most (n-1)q.10. We define the functions G and
V
by recursion.The function G is a function of three integer variables
k , h, n, all having non-negative values only. The values of G are non-negative integers. We define them by recursion, according
to the lexicographic order of the pairs (k,n):
(i) if k = 0 or n = 0: G(k,h,n) = h .f ?z
+
I ,(ii) if k
>
0, n>
0:
G(k,h,n) = G(k
-
1, h+
(n-l)G(k,h,n-
I), h).This definition is very similar to the one of the Ackermann function (see [ 3 ] ) .
It is easy to show that G is a monotonically increasing function of each one of its variables.
By means of this function
G
we define the function V: V(n) will be defined for all positive integers n, and its values willwhere
H
is the function mentioned in section 8.11. We now come back to the situation sketched in section
7.
We shall prove the followingTheorem 2. Let WRrc! be a norm-correct lambda tree,
fractured almost-correct with respect to W. Let h be the length of W, n the length of
R,
k the deficit of W. ThenW R d can be reduced (by local beta-reductions, without AT-removal) to an almost-normal form of length 1 G(k,h,n).
Proof. We apply induction with respect to k , next for every value of
k
induction with repect to n, and oncek
and n have been fixed we prove the statement for all h simultaneously. Ifk
= 0 or n=O then WVW is almost normal itself; its length is h+
n+
1.Let k>O, and assume that the statement is true for all smaller values of
k
(with arbitrary h and n). We apply induction with respect to n. The case n=O has been settled, so we take n>
0 , and we assume that the statement is true for all smallervalues of n.
We now apply the idea exposed in section
9,
withq=G(k,h,n-1). The idea has to
be
slightly modified because of the W in front and the fractured almost-normality, but we shall leave this to the reader. Because of our induction assumption we conclude that our WR can be reduced to some almost-normal WU (the reduction cannot affect W),
where the length ofU
is InG(k,h,n-1).We can now apply section
7.
In case (i) W U 3 is almost-normal, in case (ii) W U L ; reduces to W W C,
the length of V is at most h (V being a copy of a part of W), W U V 6 is fractured almost-normal with respect to WU, and thed e f i c i t of WU i s l e s s t h e n k. So by i n d u c t i o n W U V C r e d u c e s t o
something of l e n g t h a t most G(k-l,h+(n-l)G(k,h,n-l),h). By t h e
d e f i n i t i o n of G this i s a t most G(k,h,n).
1 2 . W e c a n now prove o u r main r e s u l t .
Theorem 3 . A norm-correct lambda t r e e of l e n g t h m can be reduced ( l o c a l b e t a - r e d u c t i o n s , no AT-removals) t o a n a l m o s t - c o r r e c t lambda t r e e w i t h l e n g t h 5: V(m). P r o o f . We a p p l y i n d u c t i o n w i t h r e s p e c t t o m. The c a s e m = l i s t r i v i a l . Having proved t h e r e s u l t f o r m
g
n , we s h a l l t r e a t t h e c a s e m = n+
1. L e t t h e t r e e be p r e s e n t e d a sQ3
(where c) i s e i t h e r t o r a dummy). So Q h a s l e n g t h n. According t o s e c t i o n 9 we can reduceQ t o a n almost-normal form W of l e n g t h S ' n V ( n ) .
I f G, e q u a l s
r ,
o r a dummy t h a t does n o t admit b e t a - r e d u c t i o n ,t h e n W c : i s almost-normal, s o i t s u f f i c e s t o remark t h a t nV(n)
+
1C
V(n+
1 ) .If Gi i s a dummy that a d m i t s b e t a - r e d u c t i o n , t h e n t h i s r e d u c t i o n l e a d s t o W U c r (where a g a i n f,T i s e i t h e r
r
o r a dummy), and t h i s i s f r a c t u r e d almost-normal ( s e e s e c t i o n 7 ) ,s o we c a n a p p l y s e c t i o n 11. The l e n g t h of W i s a t most nV(n).
F u r t h e r m o r e , U i s a copy of a s u b e x p r e s s i o n of W , s o i t s l e n g t h i s
<
nV(n) t o o ( b u t i t i s n o t hard t o show t h a t i t i s _( V(n)i t s e l f ) . The d e f i c i t of W can be e s t i m a t e d by H(n) a c c o r d i n g t o s e c t i o n 8 (remark t h a t t h e d e f i c i t d i d n o t change by p a s s i n g from Q t o W; w i t h o u t t h a t remark we would have t o u s e t h e e s t i m a t e ~ ( n ~ ( n ) ) i n s t e a d of H ( n ) ) . Applying Theorem 2 we g e t an
almost-normal form of l e n g t h a t most G(H(n),nV(n),nV(n)), and this e q u a l s V(n+l).
13.
We shall indicate how strong normalization for norm-correct lambda trees follows from Theorem3.
First we mention that for our local beta-reduction the Church-Rosser property holds. This is essentially contained in Nederpelt ( 4 1 , where it is proved for
fl.
-reduction (P
-reduction is the effect of local beta-reduction applied to all dummies bound by one and the same abstractor).The normal forms corresponding to local beta-reduction are what we have called almost-normal. From Theorem 3 we have the
reducibility to such an almost-normal form, and the Church-Rosser property expresses the uniqueness.
If local beta-reduction transforms the lambda tree (V,lab) into a lambda tree (V0,lab') then (V,lab) is almost entirely embedded in (V',labO): we have VcV', and lab' coincides with lab on
V with the exception of the end-points to which the
beta-reduction was applied. It follows that (V,lab), and all its reducts (by repeated local beta-reduction), are embedded in the almost-normal form, if we take exception for the labels of end-points.By a local beta-reduction the length of a lambda tree will increase, apart from a trivial case where it remains constant. The trivial case is that the AT-couple in question has its applicator in the form <x>, where x is either t o r a dummy.
This increase of length enables us to prove strong
normalization.
Theorem
4
(strong normalization for local beta-reduction). Letbe such that every P . is obtained from P; by some local
L + I
3
beta-reduction. Then we have m S(V(n))
+
V(n).Proof. Let Q be the almost-normal form of P. We have
We show that a sub-sequence P.,P
,...,
P.?L can have constant lengthJ
J*'
3
only if h
3
(~(n))'. In such a sub-sequence the tree is constant, only the labels at end-points can change. At such an end-point a dummy is sometimes replaced by another one whose abstractor lies lower in the tree, or by t.
The number of candidates for the change is at most equal to the length of the tree, so at most V(n). A candidate can never turn up a second time for thesame position. Irrespective of the order in which these
2
replacements ar carried out, we conclude to h
5
(V(n)).
In the sequence P,,
...
,
Pm we have at most V(n)-
1steps where the length increases, and, at most V(n) subintervals
2
of length S (V(n)) where the length is constant. This proves the theorem.
14.
If we admit both local beta-reduction and AT-removal, we get to what is usually called the normal form. It is easy to understand that the longest reduction sequences are obtained by taking first all the local beta-reduction steps and then the AT-removals. A tree with length5
V(n) can not have more than V(n) AT-couples, so a reduction sequence (starting from3
a norm-correct tree) can not have more than (V(n))
+
2V(n) steps. Ordinary beta-reduction consists of a sequence of local3
the bound (V(n))
+
2V(n) for the number of ordinary beta-reduction
steps.
15. We have presented bounds for the length of the normal form
expressed in terms of the length of the initial tree.
A
simple
example shows that it can not be done in terms of the length of
the norm of the tree.
We can present an infinite sequence of norm-correct (and
even correct) lambda trees, all with the same norm. It will
be clear how the sequence is defined if we just present its
sixth entry:
Actually these can occur in an Automath book on natural numbers:
there v is the type of naturals, y is the successor function and x
is the number 1.
REFERENCES
1.
N.G. de Bruijn. Generalizing Automath by means of a
lambda-typed lambda calculus. To be published. (P153).
2. N.G.
de Bruijn. Upper bound for the length of the norm
of an expression in lambda-typed lambda calculus. (M21)
3. G.T. Kneebone. Mathematical Logic and Foundation of
of Mathematics, Van Nostrand (1963).
c a l c u l u s w i t h lambda s t r u c t u r e d t y p e s . D o c t o r a l