calculus where terms are types
Citation for published version (APA):Benthem Jutting, van, L. S. (1985). The language theory of $\Lambda_\infty$, a typed $\lambda$-calculus where terms are types. (Eindhoven University of Technology : Dept of Mathematics : memorandum; Vol. 8502).
Technische Hogeschool 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.
EINDHOVEN UNIVERSITY OF TECHNOLOGY
Department of Mathematics and Computing Science
Memorandum 1985-02
THE LANGUAGE THEORY OF
A ,
(XlA TYPED A-CALCULUS WHERE TERMS ARE TYPES
by
L.S. van Benthem Jutting
Eindhoven University of Technology, Department of Mathematics and
Computing Science,
P • 0 • Box 513, 5600 MB Eindhoven, The Netherlands.
by
L.S. van Benthem Jutting
1. Introduction
In the present paper we present the theory of a system op typed A-calculus
A .. ",
which is essentially the system introduced by Nederpelt in [6]. Its characteristic feature is that any term of the system can serve as a type. The main difference between the two systems is that our system only allows for S-reduction, while Nederpelt's system has n-reduction as well.The importance of A lies in the fact that it may be considered as basic to <» the AUTOMATH languages. Therefore its theory can also be seen as basic to the theory of AUTOMATa [2,3J.
In our notation we will follow the habits of AUTOMATH, that is: for terms u and v, types a and variables x we will denote
and
(uv) by <v>u
The system consisting of such terms will be called ~. The system A is the
00
subset of ~ to which a term <u>v belongs only if v is a function, and if the domain of v and the type of u have a common (S-)reduct.
Our main theorems will be:
1. Church-Rosser for ~. This will be proved along the lines of well-known proofs by Tait and Martin-Lof [5].
Our proof will be along the lines of proofs by Gandy [4] and de Vrijer [7J for strong mormaization in simple typed A-calculus.
3. Closure of h~ under (S-) reduction. For this we have a new direct proof, though the theorem has been proved previously by van Daalen [3] •
Moreover, we prove that the terms of hex> are "normable" in the sense intended above; therefore those terms strongly normalize. This, together with correct-ness of types, implies that hex> is decidable.
In our presentation we will use "nameless variables" as suggested by de Bruijn
!1].
That is, our variables will not be "letters from an alphabet" but "references to a binding A", or rather, because of our notational habits, "references to a binding square brackets pair". In order to grasp the use of nameless variables one should note that terms can be interpreted as trees. Consider e.g. the term:[x :0.] < x > [y: S] < y > x •
The corresponding tree is
In this tre~ the bindings may be indicated by ar:;ows, omitting the naLleS of the variables :
and here, again the arrows may be replaced by numbers, indicating the depth of the binding node to which the arrow points as seen from the node where the arrow starts (only binding nodes, indicated by "0" , are counted!):
2
This last tree can again be represented in a linear form:
[a
J
< 1 > [aJ
< 1 > 2 •Note that the same variable x in the first term (or tree) is represented in the "nameless" term (or tree) once by 1 and once by 2, whereas the same refer-ence 1 in the "nameless" representation once denotes x and once y. Both the name carrying and the nameless linear representation can be considered as formalizations of the underlying intuitive notion of "tree with arrows".
The presentation with nameless variables makes the notion of a-conversion superfluous (and even meaningless). Thereby the definition of operations where "clash of variables" might arise (e.g. substitution) becomes more definite, and the proofs more formal. The drawbacks of this presentation might be a loss of "readability" of the formulas, and the need of a number of technical lemmas for updating references involved in certain formula manipulations.
In our presentation frequent use will be made of inductive definitions (e.g. the definition of term, of substitution, of reduction and of A;J. Subsequently proofs are given with induction with repect to these definitions. This should always be understood in the sense of "induction with respect to the number of applications of a clause in the definition", or, in other words, "in-duction with respect to the derivation tree". This concept is not formalized here.
2. Preliminaries and notations
In our theory we will use some notions of intuitive set theory. ~ will denote the set of natural numbers {O,1,2,3, •••• },~+ the set of positive natural num-bers {1 ,2,3, ••• } , and IN <» = IN U {oo} the set N extended with infinity. The
co
predecessor function is extended to:m by defining 00 - 1:= 00 •
For n E:m we define:m
n:= {k ElN+ Ik::;; n}, solNO ""
0,
the empty set.Let A and B be sets, Then A x B denotes the cartesian product of A and B, that is the set of pairs
r
a,b1
where a E A and b E B; and A ..,. B denotes the set of functions with domain A and values in B. If f E A ..,. B and a E A then <a>f will denote the value of f at ai and if for a E A we have b(a) E B then[a E A]b(a) will denote the corresponding function, that is the set
As a consequence of our notation for the values of a function our notation
for the composition of functions will be a little unusual: if f and g are
functions with domains Aand B respectively, then
f 0 9 =
r
x € C]<<x>f>g ,where C=
{x € AI
<x>f € B}.So <x>(f 0 g)
=«
x> f>g for x € C.If A is a collection of sets then U A denotes the union of A.
If A is any set and n
€~
then A(n)denotes~
+ A, i.e. the set of finite nsequences of elements of A with length n. In particular A (0)
=
{~}
and~
is the empty sequence. A* will denote U fA en) In€~}
, that is the set of all finite sequences of elements of A. If s € A* then L(s) is the length of a; and if s1 € A* and s2 € A* then s1&s2 denotes the concatenation of s1 and s2. In particular,~&S
=
s for s€
A*.If a € A we will often confuse a with {r1,al}, that is the element of A(1) with value a. In particular, if a € A and s € A*, then a&s € A*,
<l>-(a&s)
=
a, and <n+1>(a&s)=
<n>5 for )1. :ii L(s) •Where no confusion is expected we will often omit the symbol "&tI.
For the updating of references we will use the following functions and
oper-ations on functions: For m € ~ For m € ~ T(m,n) + In = [n € N ] (n + m) • 'I'm +
e
= [n € N ] T (m,n) , m where + 1 if n ~ m if n=
m+l if n > m+1.For m €:N and 1J1 € :N + -+ :N + <m> + 1J1
=
[n€:N]'¥(l/I,m,n) , where 'l'(lIJ,m,n) ={
:.
<n-m>-l/i i f n i f n ;:ii > m m • I t follows that t'PO
=
00=
En
€ :N+]n, the identity on:N +, and that for+ + <0>
l/I € :N -+ :N we have l/I
=
l/I. Note that t'P and (9 are injective, and that1D m
i f l/I is injective then so is l/I<m>.
Simple computation shows that the following lemmas hold:
LEMMA 2.1. I f k,m € :N then i . t'P k 0 t'Pm
=
t'Pk +m i i . (9<m> o (9=
Ok • k m +m i i i . (9k 0 <1> t'P m o (9 t'P m=
k+m.
LEMMA 2.2. I f k,m € :N and 1J1 € :N -+::N then + +
i . (l/I <k> <m> ) = l/I<k+m> i i . t'P k 0 1J1<k>
=
l/I o t'P k (9k_l c l/I <k>=
l/I <k> c (9k_l-i (9k_l-i (9k_l-i .LEMMA 2.3. I f k € IN and l/Il,l/I2 ElN + -+IN + then
LEMMA 2.4. If k,m E IN and n E IN + then
LEMMA 2.5. If k, R.,m E m then
=
if k > R. •
3. Terms, transformation and substitution
We define the set of terms ~ inductively as follows:
DEFINITION 3.1.
1. T E ~
2 • if n E:fi then n E ~
3. if u,v
E
~ then <u>vE
~4. if u,v
E
~ then [u]vE
~Transformation, Le. adaptation of the references in terms by means of a·
function ~ is defined as follows:
DEFINITION 3.2. Let ~ E~+ +~+. Then ~ is defined by
1. ~T = T
2. ~!:
=
<n>~3. ~<u>v :;<~u>~v
Clearly if u E ~ then ~u E ~. Moreover
1/Iu
=
T iff u=
T,~u
=
m iff u=
n and <n>=
m ,~u
=
<v1>v2 iff u=
<u1>u2, ~u1=
v1 and ~u2=
v2,
~u = [v1]v2 iffn = [u1]u2, ~u1 = v1 and Lu2 <1> = v2 It follows that for injective 1/1, ~u
=
~v implies u = v.LEMMA 3.1. If 1/1 1, 1/1 2 E:IN + ~:IN + , u E ~ then
Proof: By induction on u.
+ t U
For u,v E~, k EIN we define substitution of u in vat k, denoted by Lkv as follows: DE}'INITION 3.3. 1.
L~
T = Tr~
!C
=
{:k-\
U ifn < k 2. if n=
k if n > k n-1l
-3.L~
<v1>v2=
<L~
v1>I~
v2Clearly, again,'ifu,v E
~
thenL~
vE~.
Now we have the following technical lemmas:
Proof: By induction on v. LEMMA 3.3. \,u
=
t1P
1 U 1/1 <1>v1P
l.1 v l Proof: By induction on v. LEMMA 3.4. If m < k then \' 'u m v - m!U
V l.k '¥m - '¥m k-mProof: By Lemma 3.2 and Lemma 2.1.
tU
<£> <1>LEMMA 3.5. If m+t ~ k > t then l.k (j)m v
=
(j)m_lv Proof: By induction on v.These lemmas are used to prove the following theorem:
THEOREM 3.1 Substitution theorem.
If m ~ k then
I
U 1w • m+ Proof: By induction on w.The relevant case is when w
=
n If n= k thenand on the other hand
E
U vI
m-k+1 \"U w k L.m+l EU v=
t m-k+1k = ~ tU v Lk - k-1 Lm-k+1 If n = m+1 then andI
'U m = ~ U m - m-1E
U v \'km-k+1t
u L Lm+1wE
U v "km-k+1= L ~mU
=
~m_1u by Lemma 3.5.For other values of n the proof is straightforward.
4. Reduction
We define on 6 the relation >, called one step reduction.
DEFINITION 4.1. 1. <u>[w]v >
r~
v If U > v then 2. <u>w > <v>w 3 • <w>u > <w>v 4. [u]w>[v]w 5. [w]u > [w]v •The relation> on 6 is the reflexive and transitive closure of >, defined by
DEFPlITlON 4.2. 1. U
>
UIt is easily seen that the relation> is transitive and monotonic. By induc-tion on u
>
v, respectively ~u>
~v the following technical lemma is proved:LEMMA 4.1. If u
>
v then for any 1/1 ~u>
~v;if 1/1 is injective then ~u
>
~v implies u>
v.Another technical lemma:
LEMMA 4.2. If ~u
>
v then for some w v=
~w and u>
w. Proof: By induction on ~u > v.Finally is is easily,,;hown that if [ul]u2 > v the v::: [vl]v2 , ul > vl and u2 > v2.
5. The Church-Rosser theorem
We define on
A
the relation ~ called nested one step reduction.DEFINITION 5.1. 1. u ~ u If u ~ ul and v ~ vl then ~ul 2. <u>[w]v ~ £1 vl 3. <u>v ~ <ul>v1 4. [u]v ~ [ul]v1 •
~ denotes the transitive (and - of course - reflexive) closure of ~.By an easy inductive argument it is seen that u ~ v iff u > v.
LEMMA 5. 1 • If u ::) v then for any 1/J ~u::) ~v.
Now we are able to prove two lemmas on substitution.
LEMMA 5.2. If u ::) ul then
~v
::)Z:~lv.
Proof: By induction on v it is proved that for
anYkL~v
::)Z:~lv.
I..EMMA 5.3. Substitutxm lemma for ::).
tou toul If u ::) ul and v ::) vi then LkV::) Lk vl.
Proof: By induction on v::) vl it is proved that for any k Lkv::) Lk vl. u toul
Lemma 5.2 and Theorem 3.1 are used.
Using these lemmas we can prove the diamond property for ::).
LEMMA 5.4. Diamond lemma for ::).
If u ::) ul and u ::) u2 then there exists a term v such that ul ::) v and u2 ::) v.
Proof: By induction on u ::) ul and u ::) u2, using Lemma 5.3.
As a corollary we have:
THEOREM 5.1. Church-Rosser theorem for >.
If u
>
ul and u>
u2 then there exists a term v such that ul>
v and u2>
v.6. Norms, norming functionals and monotonic functionals
A term u
E
~ is called normal if u>
v implies u=
v. A reduction sequence of u is a finite or infinite sequence uo'
ut ' u2' ••• such that Uo
= u and+
un_1
>
un for n €:N • We say that u strongly normalizes if all reduction sequences of u are finite. This is the case, by Konig's lemma, iff there is a uniform upperbound to the lengths of the reduction sequences of u.We will prove strong normalization for a subset of A, the set of normable
~_. Our proof extends proofs of Gandy [4] and the Vrijer [7] for strong normalization in simple type theory. It is based mainly on de Vrijer's "quick proof II ; we refer also to that proof for comments.
We define the set F of norms recursively as follows:
DEFINITION 6.1. 1.:N€F
2. if a,B € F then a ... B:= (a -+ B) x :N € F.
It is clear th'at, for .-a,B € F, a
=
B
or an
B
=
¢.The elements of UF will be called norming functionals. For any norming func-tional fthe norm to which f belongs is denoted by ft. Moreover, we define
the projection operators:
if .p
=
n, n € :N then f* = n,if f
=
rg,nl, rg,nl € a ... B then f'=
g and f*=
n.Let f be a norming functional, m a natural number. We define the norming functional f + m as follows:
DEFINITION 6. 2. 1. I f f € :N, f
=
n then f + m=
n + m. 2.If f € a'"S,
f=
rg,nlthen f + m
=
r[h € aJ(<h>g + m), n + ml. Thus for f € a we have f + m € a and(f + m)*
=
f* + m ,<h>(f + m)'
=
<h>f' + m if a=
B ... y and h €S.
Note that + extends addition on the natural numbers.
a
For a € F and n € :N we define the norming functional c € a.
DEFINITION 6.3. Thus Note that 111 1. c
=
n n a a c +m=c • n n+m if h € B.°
°
Now let a be a norm. We define a subset a of a and a relation ;< on a by a simultaneous inductive definition.
DEFINITION 6.4. 1. 111° = 111; for f,g € 111° , f < 9 iff f* < g*
2. (13 .... y)O
=
{f€ 6 .... yI
V°
«g>f, E yO) A V· O(g<h .. <g>f'<<h>f')};gEB g,hEB
°
for f,g
E (6 ....
y) , f < 9 iffV
°
(<I1>f , < <h>g'} A f* < g* • hE 13We define G:= {aOla E F}; the elements of G will be called monotonic functionals.
°
Note that < on:IN is the order on the naturals. The following facts are easily proved:
°
If f,g,h E a I f < 9 and 9 < h then f < h.
°
°
If f,g E a , m E 111 then f + mEa and if f < 9 then f+m < g+m.
°
If f E a , m,n E Nand m < n then f+m < f+n. Moreover a°
a a cn E a and if m < n then c m < cn 7. Strong normalizationWe will assign to certain terms u E 6 a functional in UF, which will be called
*
t may be thought of as an administration of the functionals assigned to the free variables of u. fn(u,t) will denote-the norming functional of u. It may be the case that fn(u,t) is undefined. This will be denoted by fn(u,t) = o.
.
*
Terms u for which fn(u,t)
#
0 for some t€
(UG) will be called normable.DEFINITION 7.1. 1. fn(T ,t)
=
0 2. fn(n,t) = { <no>t 3. fn«v> W,t)=
4. fn([v]w,<p) = if n ~ L(<P) otherwise <fn(v,<p»fn(w,<p) 1 if fn(v,<P)#
0 fn(w,t)#
0 and dom(fn(w,<P) 1)= fn(v,<P)to
otherwise rCh€
a]fn(w,h&<P)+h*+fn(V,<p)*+l,fn(V,<p)*+fn(W,C~&<P)*l if fn(v,<p)#
0, fn(v,W)t=
a and fn(w,h&<p)#
0 for h E ao
otherwise.It will be clear from Lemma 7.5, which will be proved presently, that for normable terms u fn (u, w)
*
is an uprerbound for the lengths of the reduction sequences of u.Note that if fri«u>[w]v,<P)
#
Othen fn(u,w)t = fn(w,<p)t.Our first lemma expresses that it only depends on the norms of the functionals in <P whether fn(u,<p) is defined and, if so, what is the value of fn(u,<p)t.
*
L~MMA 7.1. If ~1.~2
E
(UF) , L(~l)=
L(~2)=
n and <k>~lt = <k>~2t for k ~ n then either fn(u,~l) = fn(u,~2) = 0,or fn(u,~l)t
=
fn(u,~2)t •Proof: By induction on u.
The following technical lemma is also proved by induction on u.
*
"ac~+ --'- "acT+*
LEMMA 7. 2 • If ~ E (UF) , 1/1 E.a~ -"-.a~ and 1/1 0 ~ E (UF) then
fn(~u,~)
=
fn(u,1/I 0 ~).(Note that ~ as well as 1/1 is a function, hence 1/1 0 ~ iLs a function.)
The following important lemma expresses that an upperbound for the lenghts
of the reduction sequences of t~v can be calculated from fn(u,~) and
fn(v,fn(u,~}&~).
LEMMA 7.3 • Substitution lemma.
If fn(u,~) , 0 then fn(L~v,~)
=
fn(v,fn(u/~)&~).Proof: By induction on v.
The main case is: v
=
[v1]v2.where a
=
fn(1.~v1/~)t , while by the induction hypothesisTherefore
fn(L~v2,h&a)
=
fn(v2,e2o(fn(u,~)&h&~»=
fn(v2,h&fn(u,~&~).It follows that
In order to formulate the next lemma we need the concept of a free variable. Therefore we define for u E A and k E :N+ the proposition free(u,k), expressing
(in the language of section 1) that the term u contains a reference (or an arrow) to the k-th binding node below u.
DEFINITION 7.2. 1. not free (T ,k)
2. free(~,k) iff n
=
k3. free «v>w,k) iff free(v,k) or free(w,k) 4. free{[v]w,k) iff free(v,k) or free(w,k+l).
LEMMA 7.4. Monotonicity lemma.
If ~ E (UG)* then fn(u,~) E (UG) U {Ole
If
~1,~2
E(UG)~" L(~l)
=L(~2)
= n,<k.>~1
<<k.>~2
and for Ji. :;; n, 11-
:f.
k <fI->~1=
<fI->~2then fn(u,~l) < fn{u,~2) or fn(u,~l)
=
fn(u,~2)=
0 if free(u,k) and fn(u,~l)=
fn(u,~2) if not free(u,k) •Proof: By induction on u.
The main case ia, again, u = [ u 1 ] u2 •
Let a denote fn(u1,~)t. Then also by the induction hypothesis for every
g € a we have fn(u2,g&~) € UG.
Now let g,h be elements of a such that 9 < h.
Then either fn(u2,g&$) < fn(u2,h&~) or fn(u2,g&$)
=
fn(u2,h&~} , hencefn(u2,g&~)+g*+fn(u1,$)*+1 < fn(u2,h&~)+h*+fn(ul,~)*+1.
It follows that fn(u,~) € UG.
Now assume that free (u,k) . Then for 9
€
a we have:<g>fn(u,~l)'
=
fn(u2,g&~1)+g*+fn(ul,$1)*+1 and <g>fn(u,~2)'=
fn(u2,g&~2)+g*+fn(ul,~2)*+1 and therefore <g>fn(u,~l)' < <g>fn(u,~2) 1 • Moreoverfn«u,~l)*
=
fn(u1,~1)* +fn(u2,co&~1)* aand
fn(u,~2)*
and therefore
fn(u,~l)* < fn(u,~2)*.
Hence if free(u,k) then fn(u,~l) < fn(u,~2).
It is easily seen that if not free(u,k) then fn(u,~l)
=
fn(u,~2) •LEMMA 7.5. Reduction lemma.
If
~
€ (UG)*,fn(u,~)
#
0 then u > v implies fn(v,$) <fn(u,~).
Proof:
u
1
By induction on u
>
v. The case u=
<ul>[u3]u2, v=
!1 u2 is covered by Lemma 7.3.As a corollary we have
THEOREM 7.1. Strong normalization.
If u is normable then u strongly normalizes.
*
If ~ € (UG) , fn(u,~)
#
0 then fn(u,~)* is an upperbound for the lengths of reduction sequences of u.8. contexts and types
In Sections 8 and 9 we will define the system Am' In order to do so we must be able to calculate the type of an expression u
€
6. For assigning a type to u we need a sequence UE 6*.
Such a sequence is called a context. It can be considered as administrating the types of the free variables in u. The type of u may be undefined which, again, will be denoted by thesymbci "0". DEFINITION 8.1, 1. typ r,U) = [J 2. typ(~,U)
=
3. typ«v>w,U) = cp <n>U n o <v>typ (w ,U). [J { [v]typ(w,V&U) 4. typ([v]w,U) = [J if n :i L(U) otherwise if typ(w,U)#
[J otherwise if typ(w,V&U)#
[J otherwiseIn order to express the properties of the typing operator typ, we must extend the transformation operation, the substitution operation and the reduc-tion relareduc-tion to contexts. As far as transformareduc-tion is concerned we restrict
<k>
oursel ves to the functions <P •
m
DEFINITION 8.2. Let U be a context, L(U) = n. Then n is defined by <k-l> <P <1>U m if t Si k, t Si n <1>U if k < 1 Si n •
The following lemmas are easily seen to hold:
LEMMA 8.1. <Pm <0> U
=
U; <P m <k+l' ~(U&U)=
<P m <k> U & <Pm <k> U<k> <k>
LEMMA 8.2. If L(U1)
=
k then <P (U1&U2)=
(<p Ul}&U2.m m
We prove a technical lp.mma by induction on U:
LEMMA 8.3. If L(UO)
=
k, L(U1) = m and U=
UO&Ul&U2<k> <k>
then either tYP(<Pm u'<Pm U)
=
typ(u,UO&U2)=
0or typ(<p <k> u,<P <k> U)
=
<Pm <k> typ(u,UO&U2).m m
This gives as a consequence:
COROLLARY 8.3. If L(Ul)
=
m, then eitheror
typ(~ u,Ul&U2) = typ(u,U2) = 0 m
typ(~ u,Ul&U2)
=
<P typ(u,U2) •Now in order to investigate the relation between substitution and typing we define substitution in contexts:
DEFINITION 8.3. Let U be a context, L(U)
=
n, and 1 ~ k ~ n.'u * u
Then LkU E h with L(LkU)
=
n-l is defined by if R, < k<t+ 1>U if k ~ R, < n.
We have the following easy lemmas on substitution in contexts:
LEMMA
8.a.
If L(U1)=
k thenl~(U1&U2)
=
(L~U1)&U2
•The next lemma describes the relation between substitution and typing:
LEMMA 8.6. Substitution lemma for typ.
If tYP(~ku,U) > w and ~k<k>U >w
or
typ(L~V/r~U)
;:"wO andL~typ(V'U)
> wO for some wO E f:..Because k ~ L(U) we have U = U1&U2, where L(U1) = k.
'u 'u
Hence, by Corollary 8.3 : tYP(LkV,LkU)
=
~k_1tYP(u,U2), so, again by Corollary 8.3:On the other hand
This gives us
By Lemma 4.2 it follows that w
=
~1we
and thattYP(L~V' L~U)
> wO andL~tyP(V'U)
> wO.COROLLARY 8.6. If typ(u,V)
>-
wand v1 > w then eithertYP(l:~v,V) = typ(v,v1&V) = 0 or
'u
and L1tYP(v,v1&V).> wO for some wO € 6.
Proof: Take k
=
1 and U=
v1&V in Lemma 8.6.Finally, in order to describe a relation between typing and reduction we de-fine the concept of reduction on contexts.
DEFINITION 8.4. Let u and v be terms, U and V contexts. 1. if u> v then u&U > V&U
2. if U > V then U&U > U&V •
We have the following lemma:
LEMMA 8.7. If U
>
V then LeU)=
L(V) = n > 0 and there is just one k ~ n such that<k>U > <k>V and <t>U = <t>V for t ~ n, t ~ k. Proof: By induction on U
>
V.Moreover we have
LEMMA 8.8. If U > V then either typ(u,U) > typ(u,V) or typ(u,U) = typ(u,V) Proof: By induction on u.
COROLLARY
8.B.
If v> w then either typ(u,v&U) > typ(u,W&U) or typ(u,V&U) = typ(u,W&U) •The relatiom
>
between contexts is the reflexive and transitive closure of> .
If u>
v and U>
V then clearly u&U>
viVo9. The system Ars
We will define by simultaneous induction the set
r
c~*
which is the set00
of correct contexts, and the set A c ~ x ~
*
. (it will turn out even00
Aoo c ~ x roo)' If ru,ul € Aoo u will be called a correct term on context U. Here correctness should be understood as follows:
If <u>v is correct on context U then v "is a function" and moreover typ(u,U) and "tJle domain of v" have a common reduct. In fact, we have not formalized what it means for v to "be a function" and, if it is, what "the domain of v" is. The requirements described above appear however in clause 4 of our de-finition and - implicitly - also in clause 6.
Together with
r
and A we will define the setsr.
and A. for i E :N. They~ ~ 1 1
are introduced only for the purpose of induction in the proof of Lemma 10.3. If ru,ul
E
A. then u will be called i-correct. The systems are connected1
with the notion of degree in [2] and [3] in the sense that any i-correct term will have degree at most i. (The converse however does not hold.)
~
In the following discussion it is always assumed that i r;:tJ • For i
=
00the definitions and lemmas contain the theory of A .
~
DEFINITION 9.1.
o. rO
=AO
= (?jIf i > 0 then
1. (?j
E r
i
2. i f ru,ul
E
A. then u&U 1E r.
13. if U
E r.
then rT,ulE
A.1 1
4. if typ«u>v,U)
=
0, ru,ulE
Ai' rv,ulE
A. ,1
typ(u,U)
>
vl and v>
[vl]v2 then r<u>v,ulE
A.1
5. i f typ([u]v,U)
=
0 and rv,u&ul I-; A.1
then r[u]v,ul
E
A.1
6. if rtyp(u,u),ul E A. 1 then ru,ul E A .•
1- 1
Clearly if ru,ul E
A.
then U Er.
and if Ul&U2 Er.
then U2 Er ..
It is1 1 1 1
also clear (by induction on i) that A. c A. 1 for i E :N and it is easy 1 1+
We have the following technical lemma:
LEMMA 9.1. If L(UO)
=
k, L(U1)=
m, U=
UO&U1&U2 and U1&U2€
r
i thenf (j) m <k> u,(j) m <k> U € Ai iff u,UO&U2
1
f1
E A .• 1.ind f 21
€
A d fm<k> m<k> 1 c._ A Proof: By llction, respectively on U,UO&U i an on 'l"m u''I''m U - i'where frequent use is made of Lemma 8.3.
The lemma has some nice corollaries:
COROLLARY 9.1" 1 • Weakening and strengthening lemma •
COROLLARY 9.1.2. If U
€
r
i , k<
L(U) then f(j)k<k>u,ul F. Ai"COROLLARY 9.1.3. f~,u1
€
A~ iff U F. r~ and n ~ L(U).The next lemma partially expresses our assertions about correctness of terms.
LEMMA 9.2. Soundness of application.
If f<u>[w]v,ul € Ai then typ(u,U)
>
wO
and w>
wO for some wO € ~. Proof: By. induction on r<u>[w]v,ul EA .•1.
Types of correct terms are, in a sense, preserved under reduction.
LEMMA 9.3. Preservation of types.
If ru,u1
€
A., u > v then either typ(u,U)=
typ(v,U) = C1.
Proof: By induction on u
>
v.'u1 We will consider the case u
=
<u1>[u3]u2, v=
I1 u2.By the previous lemma typ(u1,U) > wO and u3 > wOo Now typ(u,U)
=
<ul>[u3]typ(u2,u3&U)>
L~1typ(U2,U3&U)
\"u1
and typ(v,U)
=
tYP(l1 u2,U). Apply Corollary B.6.The following lemmas are easy to prove. The first contains the converse of clause 6 in Definition 9.1.
LEMMA 9.4. Correctness of types.
It typ(u,U)
#
0 then ru,u1 E Ai iff ftyp(u,U) ,u1 E Ai_I'The second te>lls us that if an application of a function to an argument is
cor-rect, then both the function and the argument are correct.
LEMMA 9.5. Correctness of functions and arguments.
We prove two lemmas which are, in a sense, converses of Lemma 9.5.
LEMMA 9.6.
then
I f r<u>vl,u1 E Ai' 1\r2,u1 E Ai' v1 >w and v2 >w r <u>v2, U 1 EA .•
l.
Proof: By induction on f<u>v1,u1 EA .•
l.
We consider the case of clause 4:
typ«u>v1,u)
=
0, ru,u1 EA., [v1,ul E A., typ(u,U) > wO and v1 > [wO]w1.l. l.
We know that typ(v1,U)
=
0, hence, by Lemma 9.3 typ(w,U)=
0 and alsoMoreover, by the Church-Rosser theorem we have, for some w2 F. ~:
w > w2 and [wO]wl > w2, hence w2
=
[wO*]wl* for some wO* and wl*. Therefore typ(u,U} > wO > wO* and v2 > w > [wO*]wl*, so, by clause 4,r <u>v2, U 1 ( A ..
1.
LEMMA 9.7. If r<ul>v,u1 ~ A., ru2,u1 E A. and ul
>
u2 then r<u2>v,u1 fA ..1. 1. 1.
Proof: By inductionpul>v,u1 E Ai •
We consider again the case of clause 4:
typ«ul>v,u)
=
0, rul,u1 ~ A., rv,u1 E A., typ(ul,U} > wl and v> [wl]w2.1. 1.
First we have typ(v,U)
=
0, hence typ«u2>v,U}=
o.By Lemma .9. 3 we have for some wO typ(ul ,U}
>
wO and typ(u2,U} > wOoHence, by the Church-Rosser theorem: wO > vl and wl > vl for some vl. Therefore typ(u2,U} > wO > vl and v > [wl]w2 > [vl]w2, so,by clause 4,
r <u2 >v , U 1 EA .•
1.
Finally we state a lemma on correct abstraction:
LEMMA 9.B. r[u]v,u1 E A. iff rV,U&U1 EA ..
1. 1.
Proof: By induction, respectively on r[u]v, u1 EAi and on rV,U&U1 E Ai.
10. Closure for Aoo
For the proof that A is closed under reduction we need Lemma 10.2 which
00
tells us that correctness is preserved under correct substitution. In order to prove this lemma we give a slightly different definition of Ai'
which we will prove to be equivalent to the first definition. Induction on
this alternative definition will be used in the proof of Lemma 10.2.
eo
We define for i E ~ the sets C
i and Li by a simultaneous inductive defi-nition as follows:
DEFINITION 10.1.
If i > 0 then
2. If ru,ul E Li then u&U E Ci
4. if typ«u>v,U)
=
0, ru,ul ELi' rv,ul€
Li 'typ(u,U) > vl and v> [vl]v2 then r<u>v,u1 ELi
5. if typ([u]v,U) = 0 and rv,u&u1 E Li then r[u]v,u1 E Li
6.1. ;if ftYP(E,U),u1ELi_l then r!!,u1 E Li
6.2 if rtyp«u>v,U) ,u1 E L. 1 and rv,u1 E L. then r<u>v,u1 € L.
1- 1 1
6.3. if rtyp([u]v,U) ,u1 E L
i_1 and rv,u&ul E Li then r[u]v,ul E Li •
The clauses 0 to 5 are the same as the corresponding clauses of Definition
9.1, but clause 6 of that defintion has been split up into three clauses.
We easily verify that L. 1 c: L. and that Leo
=
u{L.li t:::~} • In order1- 1 1
to show that C. =
r
i and L
=
A. we first prove the following lemma:1 i 1
LEMMA 10.1. If rtyp(u,U) ,u1 E L
Proof: By induction on r typ(u,ul E L i_1•
We consider the case of clause 4: typ(u,U)
=
<ul>v, typ«ul>v,U}=
0,ru1,ul E L
i_1, fv,u1 E Li_1, typ{ul,U) > wl, v> [wl]w2. Now either u
=
n or u=
<ul>u2 and typ(u2,U)=
v.If u
=
~ then ru,ul E Li by clause 6.1.If u
=
<ul>u2, typ(u2,U)=
v then we have by the induction hypothesis ru2,u1 E Li and therefore ru,u1 E Li by clause 6.2.As another case we consider clause 6.3: typ(u,U)
=
[ul]v, rtyp([ul]v,U) ,u1 E Li_2 and rv,u1&Ul E Li-1 •
Again we either have u
=
n or u=
[ul]u2 and typ(u2, ul&U) = v. If u=
n then again clause 6.1 applies.And if u
=
[ul]u2, typ(u2,ul&U)=
v then by the induction r.ypothesis fu2,Ul&Ul E Li and therefore ru,u1 E Li by clause 6.3.Proof: Li C Ai is trivial, Ai eLi is proved by using Lemma 10.1.
Now we are able to prove the following important substitution lemma.
LEMMA 10.2. SUbstitution lemma for L .•
---~~~~~~~~~~~~~~:1
If r'ku,ul ELi' rv,ul
€
Li , tYPC'ku,U) > wand 'k<k>U > w thenProof: By induction on rv,ul ELi' freely using Corollary 10.1.
We consider some of the clauses:
Clause 3. v = T. We have to prove the L~U ~ C i•
If k
=
1 this is clear by Lemma 8.4.If k > 1 then U
=
w&V andI~u
=
~w
&r~v,
also by Lemma 8.4.Now we have rw,vl ELi' hence by the induction hypothesis
rL~w'L~vl ~
Li and therefore I~u E Ci by clause 2. Clause 4: v
=
<v1>v2 •We know that typ(v,U)
=
0, rvl,ul f. Li, rv2,ul ELi' typ(vl,U)
>
w1 and v2>
[w1]w2.By Lemma 8.6 we have: typ(I~v,I~u) = 0 (i>. The induction hypothesis gives us:
(ii) •
Also by Lemma 8.6 we see that
typ(~V1,r~U)
>
wO andr~typ(Vl,U)
>
wO for some wOoNow by Lemma 5.3 it follows that
and also
hence by the Church-Rosser theorem
wO
>
w and r~W1>
w for some w.Therefore we have:
From (i), (ii) and (iii) we conclude by clause 4 that
Clause 6.1: v = n. We know that rtyp(v,U) ,u1 = r<pn<n>u,ul .c L i_1• We discern two cases: n
=
k and n#
k.Suppose n
=
k. As L(U) ~ k we may put U=
U1&U2 with L(U1)=
k. ThenL~U
=
(L~U1)&U2
by Lemma 8.5 andL(L~1)
=
k-1.Moreover it can be shown, just as under clause 3, that I~u F. Ci .
Bence by Corollary 9.1.1 we have ru,u21 E L. and by the same corollary 1.
Now suppose n # k. r~v either equals n (if n < k) or n-1 (if n > k). Using Lemma 3.4 (for n < k) or Corollary 3.5 (for n > k) we see that
By the induction hypothesis we have rru<Pn<n>uIL~u1 E Li_1 and therefore
u u
by clause 6.1 rLkv,Lkul ELi.
Clause 6.2: v
=
<v1>v2.We know that r<v1>typ(v2,Uhul E L. 1 and that rv2,ul E L .•
1.- 1.
By the induction hypothesis it follows that
(i)
and
(*)
By Lemma 8.6 it is known that for some wO E ~
And from (*) we conclude by Lemma 9.4 that
(iii)
From (i), (ii) and (iii) it follows by I.eImlla 9.6 that
and this, together with (*) gives us by clause 6.1:
We leave the other clauses to the reader.
COROLLARY 10.2. If ru,vl E L., rv,vl&vl E L., typ(u,V) > wand vi > w
~ ~
Proof: Take k
=
1 and U=
vl&V in Lemma 10.2.OUr next lemma implies that for i E JIl A. is closed under reduction. In
~
order to word it we use the relation> between contexts, which has been defined in section 8.
In order to prove the lemma we assign to every context U hhe number M(U) which is the sum of the lengths of the terms in U:
if L(U)
=
n then M(U)=
L«l>U) + L«2>U) + ••• + L«n>U).LEMMA 10.3. If i E JIl , u&U > v&V and ru,ul E A. then rv,vl E A .•
~ ~
Proof: By induction on i.
If i
=
0 then A.=
0,
so the lemma holds. ~PROPOSITION: If u&U > V&V and fu,ul € Ai then fv,vl C Ai'
Proof: By induction on M(u&U).
If M(u&U)
=
1 then u&U>
v&V is impossible, so the proposition holds. Now suppose M(U&U) > 1.As U&U
>
V&V we have either u>
v and U=
V or u = v and U>
V. Suppose u>
v and U=
V. We inspect the clauses for u>
v. 1. u=
<ul>[u3]u2, v=
1,~IU2.
By Lemma 9.2 we have typ(ul,U>
>
wand u3>
w for some w, and by Lemma 9.5 f[u3]u2,ul€
Ai so fu2,u3&ul ~ Ai by Lemma 9.B.Apply Corollary 10.2.
2. u
=
<ul>u2, ul > vI, v=
<v1>u2 •By Lemma 9.5 we have ful,ul € A .•
1.
Moreover u1&U
>
vl&U and M(u1&U) < M(U&U) •Therefore by our induction hyothesis we have fvI,ul ( Ai and hence fv,ul~Ai by Lemma 9.7.
3. u
=
<uI>U2, u2 > v2, v=
<ul>v2.fv,ul
€
Ai by a similar argument, where Lemma 9.6 is used instead of Lemma 9.7.4. u = [u1 ]u2 , u1
>
vI , v=
[vI] U2 • By Lemma 9.B we have fu2,ul&ul € Ai'Moreover u2&ul&U
>
u2&v1&U and M(u2&ul&U) < M(u&U) ; in fact M(u&U) = M(u2&ul&U) + 2.Therefore our induction hypothesis gives us fu2,vI&ul E A. and it follows
1.
that fv,ul € Ai by Lemma 9.B.
5. u
=
[ul]u2, u2 > v2, v=
[ul]v2.Now suppose u
=
v and U > V. We inspect the clauses for ru,u1 € Ai' 3. u = T. We have to prove that V€
rioAs U> V it is impossible that U
=
~, so we may put U=
ul&Ul and V=
vl&Vl. As U ~ r. we have rul,Ul1 ~ A. and also M(U) < M(u&U).1 1
Therefore we have by our induction hypothesis rvl,Vl1 ~ Ai' hence V ~ rio 4. u = <u1>u2, typ(u,U) = 0, rul,u1 E Ai' ru2,u1 E Ai'
typ(ul,U) , v1 and u2 , [v1]v2.
By Lemma 8,7 we know typ(u,V)
=
O. Moreover, we have u1&U > ul&V andM (u1 &U) < M (U&U) so by our induction hypothesis r ul , V 1 € Ai' and by a similar argument we see that ru2,vl
€
Ai.Also by Lemma 8.7 it is seen that typ(u1,U) , typ(u1,V) so by the Church-Rosser theorem we have:
vi , wand typ(u1,V) , w for some w.
It follows that u2 , [vl]v2 , [w]v2, hence ru,vl f A. by clause 4.
1
5. u
=
[u1]u2, typ(u,U)=
0, ru2,ul&u1 € A .•1
We know that u2&u1&U > u2&u1&V and that M(u2&u1&U) < M(u&U). It follows
that rU2,ul&V1 E Ai' hence 6. rtyp(u,U) ,u1 E A. l'
1
-ru,v1 E A. by Lemma 9.8.
1
By Lemma 8.7 we have typ(u,U) , typ(u,V), hence typ(U&U)&U, typ(U&V)&V. Now by our induction hypothesis on i it follows that -rtyp(u,V) ,vl EA. 1
1-and therefore
r
u , V1
€ Ai by clause 6.So our proposition is proved, and it follows immediately that u&U, V&V, ru,u1 EA.-imply rv,vl E A .• This proves our lemma.
1 1
COROLLARY 10.3. Closure for A .•
1.
As a consequence we have:
THEOREM 10.1. Closure for h
~
If ru,ul
E h
m and u> v then rv,ul E hm11. Normability for hm•
In this section we will prove that ru,ul F. A~ implies that u is normable. It then follows from Theorem 7.1 that u strongly normalizes. In order to
*
prove that u is normable we will assign to certain sequences U ~
A
a*
sequence s(U) E (UG) • If the assignment is not possible then we will write as before, s(U)
=
o.DEFINITION 11.1. 1. s(~)
=
~.a
CO&s(U) if s(U) # 0, fn(u,s(U» # 0
2. s(U&U)
=
and fn(u,s(U»+=
a. o otherwiseLEMMA 11.1. If s(U) # 0 then L(s(U»
=
L{U)=
n and fn(~k<k>U, s(U»+=
<k>s(U)t for k ~ ~.Proof: By induction on U.
Our second lemma gives a relation between norms and typing.
LEMMA 11.2. If U
E A ,
*
s(U) # 0 and typ(u,U) # 0 then eitherfn(typ(u,U) ~ s(U»
=
fn(u,s(U» = 0or
fn(typ(u,U) ,s(U»+=
fn(u,s(U»t .We consider the case that u
=
[ul.l u2.Then typ(u,U)= [ul]typ(u2,ul&U) and typ(u2,ul&U} ; o.
If fn(ul,s(U»
=
0 then fn(typ(u,U),s(U}) = fn(u,s(U»=
o.Now assume that fn(ul,s(U» ; 0 and put fn(ul,s(U»+
=
a. Then it follows athat s(ul&U)
=
CO&s(U) ; o.If fn(typ{u2,ul&U),s(u1&U» = 0 then also fn(u2,s(ul&U»
=
0 by theinduc-tion hypothesis, and therefore fn(typ(u,U) ,U)
=
fn(u,U)=
o. So let us assume fn(typ(u2,ul&U) ,s(ul&U» ; o.Putting fn(typ(u2,ul&U),s(ul&u»+
=
e
we have by the induction hypothesis fn(u2,s(ul&U»+=
B
and also fn(u2,g&s(U»+=
e
for g E a. Hencefn(typ(u,U) ,s(U»+
=
fn(u,s(U»+=
a ~e .
LEMMA 11.3. If ru,u1 € Ai then stU) ; 0 and fn(u,s(U» ; o.
Proof: . By induction on
r
u, U 1 EA .• ~We consider clause 3: u
=
T. We only have to show that stU) ; o. If U=
~then s(U)
= ~,
and if U=
V&V then we have rv,v1 E A., so by the induction ~hypothesis s(V)
#
0 and fn(v,s(V»#
0 and therefore s(U)#
o.We will also consider clause 4: u
=
<ul>u2.We have typ(u,U) = 0,
r
ul ,u1 € \ , r u2 ,u1 E \ ,typ(ul,U)
>
vi and u2>
[vl.]v2.By the induction hypothesis fn (u1,s (U» ; 0 and fn (u2,s (U»
#
o.Putting fn(u1,s(U»t
=
a we have fn(typ(u1,U) ,s(U»t=
a by Lemma 11.2 and fn(vl,s(U»t=
a by Lemma 7.5.Also by Lemma 7.5 fn(u2,s(U»t
=
fn([v1Jv2,s(U»t=
a ~e
for some e,hence fn(u,s(U» ; o.As a consequence we have
THEOREM 11.1. Strong normalization for A~
If ru,ul E A~ then u strongly normalizes.
ACKNOWLEDGEMENT
I want to express my gratitude to R. Nederpelt for his encouragement and his careful reading of the original text, where he suggested some improve-ments and detected a serious error.
REFERENCES
[1] de Bruijn, N.G. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Kon. Ned.
Akad. Wetensch. Proceedings Sere A,75 (= Indag. Math. 34),
381-392 (1972).
[2] de Bruijn, N.G. A survey of the Project AUTOMATH.
To H.B. Curry: Essays on Combinatory Logic, Lambda calculus and Formalism, 579-606, Academic Press (1980). [3] van Daalen, D. T. The language theory of AUTOMATH.
Thesis. Eindhoven University of Technology, Dept. of Mathematics (1980).
[4] Gandy, R.O. Proofs of Strong Normalization.
To H.B. CUrry: Essays on Combinatory Logic, Lambda Calculus and Formalism, 457-477. Academic Press (1980).
[5] Martin-LOf, P. An intuitionistic Theory of Types. Report. University of Stockholm, Mathematical Inst. (1972).
[6] Nederpelt,R.p. Strong Normalization in a typed lambda calculus with lambda structured types.
Thesis. Eindhoven University of Technology, Dept. of Mathematics (1973).
[7] de Vrijer, R. Exactly estimating functionals and strong normaliza-tion. Preprint (19B3).