# On sets of terms with a given intersection type

We are interested in how much of the structure of a strongly normalizable lambda term is captured by its intersection types and how much all the terms of a given type have in common. In this note we consider the theory BCD (Barendregt, Coppo, and Dezani) of intersection types without the top element. We show: for each strongly normalizable lambda term M, with beta-eta normal form N, there exists an intersection type A such that, in BCD, N is the unique beta-eta normal term of type A. A similar result holds for finite sets of strongly normalizable terms for each intersection type A if the set of all closed terms M such that, in BCD, M has type A, is infinite then, when closed under beta-eta conversion, this set forms an adaquate numeral system for untyped lambda calculus. A number of related results are also proved.

## Authors

• 3 publications
• ### Uniqueness typing for intersection types

Working in a variant of the intersection type assignment system of Coppo...
05/05/2021 ∙ by Richard Statman, et al. ∙ 0

• ### Intersection Types for Unboundedness Problems

Intersection types have been originally developed as an extension of sim...
04/23/2019 ∙ by Paweł Parys, et al. ∙ 0

• ### The intersection of algorithmically random closed sets and effective dimension

In this article, we study several aspects of the intersections of algori...
03/05/2021 ∙ by Adam Case, et al. ∙ 0

• ### Statman's Hierarchy Theorem

In the Simply Typed λ-calculus Statman investigates the reducibility rel...
11/15/2017 ∙ by Bram Westerbaan, et al. ∙ 0

• ### Modelling of crash types at signalized intersections based on random effect model

Approach-level models were developed to accommodate the diversity of app...
05/16/2018 ∙ by Xuesong Wang, et al. ∙ 0

• ### Natural Deduction and Normalization Proofs for the Intersection Type Discipline

Refining and extending previous work by Retoré, we develop a systematic ...
04/23/2019 ∙ by Federico Aschieri, et al. ∙ 0

• ### Intersection Types and (Positive) Almost-Sure Termination

Randomized higher-order computation can be seen as being captured by a l...
10/23/2020 ∙ by Ugo Dal Lago, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Here we are interested in how much of the structure of a strongly normalizable lambda term is captured by its intersection types and how much all the terms of a given type have in common.

In this note we consider the theory BCD (Barendregt,Coppo, and Dezani) of intersection types without the element ([1] pps 582-583) and the notion of an adequate numeral system for the untyped lambda calculus ([3] 6.4 pps 135-137).

## 2 Formal Theory of Type Assignment

We define the notion of an expression as follows. are atomic expressions. If , and are expressions then so are and . Even though we write infix notation we say that these expressions begin with and resp. A basis is a map from a finite set of variables, dom, to the set of types. Below we shall often conflate F with the finite set

 {x:F(x)|x:dom(F)}.

The formal theory of type assignments BCD (Barendregt, Coppo, and Dezani) is defined by the following set of rules here presented sequentially. For basis and terms

 F,x:A⊢x:A(axiom)F,x:A⊢X:B⇒F⊢∖xX:A→B(→I)F⊢X:A→B&F⊢Y:A⇒F⊢(XY):B(→E)F⊢X:A&F⊢X:B⇒F⊢X:A∧B(∧I)F⊢X:A&A [ B⇒F⊢X:B([)

Here we note that the rule ([) is read “less that or equal to”.

## 3 The Relational Theory of Types

The rule is governed by the free theory of a preorder;

and a contravariant-covariant operation ,

satisfying the weak distributive law

.

There is an equivalent equational theory.

## 4 The Algebraic Theory of Types

A semilattice with meet operation

satisfying the distributive law

and an absorption law

where the quotient partial order can be recovered
.

## 5 Theory of Expressions and their Rewriting

With an equational presentation we can associate a set of rewrite rules. The one step rewrite of an expression by the rule to the expression is denoted . This is the replacement of exactly one occurrence of the left hand side of the rule as a subexpression of , the redex, by the righthand side. Sets of rules can be combined by the regular operations + (union) and * (reflexive-transitive closure). We define rewrites

 (asso.)A∧(B∧C)asso.(A∧B)∧C(asso.)(A∧B)∧Casso.A∧(B∧C)(comm.)A∧Bcomm.B∧A(idem.)Aidem.A∧A(absp.)A→Babsp.(A→B)∧((A∧C)→B)(dist.)A→(B∧C)dist.(A→B)∧(A→C)

and we set semi. = assoc. + comm., and slat. = semi. + idem. Let redo. = slat. + absp. + dist.. redo. generates the congruence on expressions induced by the algebraic theory.

We recall the following properties of the rewrite theory from ([5]).

1. idem. can be restricted to atoms.

2. comm. can be restricted to atoms and expressions beginning with .

3. If slat.* then there exists such that
.

4. Every dist. reduction terminates.

5. dist. has the weak diamond property.

6. redo. has the Church-Rosser property.

For each type expression , the unique dist. normal form of is denoted dnf().Each type expression in dnf can be written

 A1∧…∧Ak

associatively with each

 Ai,1→(…(Ai,t(i)→ai)…).

Here is the principal atom of . The are the components of .

## 6 Formal Theories of Type Expressions

The formal theory of simply mirrors the relational theory.

Axioms;

Rules;

2. Equational:

We add the axioms for the algebraic theory of and the usual rules for being a congruence. Since in this theory is defined by , the BCD rule,

in the formal theory of type assignment. In addition, there is a useful proof theoretic variant.

3. Munich Version

The notions of positive, negative, and strictly positive are defined recursively by

is positive and strictly positive in .

If is positive in then is positive in and negative in .

If is strictly positive in then is strictly positive in .

If is positive in or then is positive in .

If is strictly positive in or then is strictly positive in .

If is negative in then is negative in and positive in .

If is negative in or then is negative in .

A single occurrence of as a subexpression of will be indicated . An expression can be thought of as a rooted oriented binary tree with atoms at its leaves and either or at each internal vertex. For each subexpression of there is a unique path from the root of to the root of . If we remove this occurrence of we have a context where we could just as easily have thought of this as the replacement of by a new atom . The rules of the Munich version are

Axioms;

Rules;

###### Lemma 6.1.

(Munich)

If by the Traditional rules then by the Munich rules

###### Proof.

We verify that the Munich rules are closed under the Traditional rules by simulating the Traditional proofs by Munich proofs. First observe that if in Munich and is positive then and if is negative then . Next observe that if we have and in Munich, then , so by idem. . End of proof. ∎

This version is named in honor of Kurt Schutte.

## 7 Evaluating Types in the Tropical Semiring

The tropical semiring is the semiring of integers with 0,1,+,min, and max (and + and - infinity, but we will not need these; ([2]). With each type expression we associate a tropical semiring polynomial . The definition is by recursion over subtype expressions of and is not context free; it depends on the sign of the subtype expression. For each atom a pick a distinct variable and set

The dual of , denoted , is obtained from by interchanging max and min.

Facts; (tropical)
For all natural number values of the variables

1. is monotone.

2. If and are slat. congruent then .

3. if is strictly positive.

¿From these facts we conclude the

If then

###### Proof.

By the Munich axioms and rules. End of proof. ∎

## 8 Proof Theory of BCD

Here we need to strengthen several of the derived rules for BCD stated in ([3]) chapter 14 to proof theoretic statements. For this it is convenient to write proofs in tree form. Indeed, we shall implicitly adopt the natural deduction form of the rules of BCD using the left hand side of sequences to indicate active assumptions. We denote proofs etc.

###### Lemma 8.1.

(dnf)
Suppose that for each and are in dnf, and is provable. Then there is a proof where every type expression is in dnf.

###### Proof.

Let be such a proof. Our proof is by induction on . We write dnf for the basis such that .
Basis; and the axiom . Then
dnf is an axiom.

Induction step;

Case 1; ends in the BCD rule . Since implies dnf this case is obvious.

Case 2: ends in the BCD rule . Since dnf this case is obvious. Remark; the case is similar and could be included here.

Case 3; ends in the BCD rule . So we may suppose that
, and has the form

 P′F⊢U:B→C   P′′F⊢V:B
 F⊢(UV):C

Let dnf where each is dnf and does not begin with . By induction hypothesis there exist proofs , of

 dnf(F)⊢U:(dnf(B)→C1)∧…∧(dnf(B)→Cn)

and resp..Now for , applications of to gives a proof of

 dnf(F)⊢U:dnf(B)→Ci,

which when combined with by gives a proof of

 dnf(F)⊢(UV):Ci.

applications of to the gives the desired proof of

 dnf(F)|−(UV):dnf(C).

Case 4; ends in the BCD rule . Again we may suppose that has the form and has the form

 P′
 F,u:B⊢v:C
 F⊢∖uV:B→C

Now if dnf, where each is dnf and does not begin with , then

 dnf(A)=dnf(B)→C1∧…∧dnf(B)→Cn.

By induction hypothesis there exists a proof of

 dnf(F),u:dnf(B)⊢U:dnf(C)

which after applications of yields a proof of

 dnf(F),u:dnf(B)⊢U:Ci.

Thus for we have proofs

 Qi
 dnf(F),u:dnf(B)  ⊢U:Ci
 dnf(F)⊢∖uU:dnf(B)→Ci

These can be combined by for the desired result. End of proof. ∎

###### Lemma 8.2.

(predicate reduction)
Suppose is a proof of where every type expression is in dnf. Then there exists a similar proof where every application of the BCD rule [ is to a variable as the subject.

###### Proof.

We first recall the criterion for [ on dnfs verified in ([5]) section (19)

If

 A = A1∧…∧An where Ai=A(i,1)→(…(A(i,m(i))→ai)…) ai is an atom, m(i) may be 0, and each A(i,j) is in distributive normal form for i=1,…,n B1∧…∧Bk where Bi=B(i,1)→(…(B(i,l(i))→bi)…) bi is an atom, l(i) may be 0, and each B(i,j) is in distributive normal form for i=1,…,k

then

A [ B iff for each i=1,…, k there exists j=1,…,n such that bi=aj,l(i)=m(j) and for r=1,…,l(i) we have B(i,r)[A(j,r).

Next we consider an application of the BCD rule ([) in immediately following the application of a different rule, and we show how the ([) can be promoted (if you like, permuted).

Case 1;

 P′P′′F⊢U:C→AF⊢V:CF⊢(UV):AF⊢(UV):B.

Now for each we have so we have proofs

 P′P′′F⊢U:C→AF⊢V:CF⊢U:C→BiF⊢V:C
 F⊢(UV):Bi

which can be combined by .

Case 2;

 F,u:CP′⊢U:D
 F⊢∖uU:C→D
 F⊢∖uU:B

Now for each we have and

 D [ B(i,2)→(…(B(i,l(i))→bi)…).

Replacing axioms in by

 G,u:B(i,1)⊢u:B(i,1)
 G,u:B(i,1)|−u:C

gives new proofs

 Pii
 F,u:B(i,1)⊢U:D
 F,u:B(i,1)⊢U:B(i,2)→(…(B(i,l(i))→bi)…)
 F⊢∖uU:Bi

which can be combined by .

Case 3;

 FP′⊢X:C   FP′′⊢X:D
 F⊢X:C∧D
 F⊢X:B

We may suppose and . By the criterion for of dnfs, for each there exists such that . So for each such where we have the proof

 FP′⊢X:C
 F⊢X:Bi

and for each such that we have the proof

 FP′′⊢X:D
 F⊢X:Bi

and these can all be combined with . End of proof.

A sequence of inferences

is said to be “intemperate” and can be replaced by

###### Theorem 8.3.

Suppose that for each :dom and are in dnf, and is provable. Then
there is a proof of such that

1. every type expression is in dnf,

2. every application of the BCD rule [ is to a variable as the subject, and

3. there are no intemperate sequences

###### Proof.

we already know that proofs satisfying (1) and (2) exist for . The proof is by induction on the length of with a subsidiary induction on length of a proof and (1) and (2). We suppose that

and , showing all components, and we distinguish several cases.

Case 1; ends in . By subsidiary induction hypothesis. Otherwise ends in the BCD rule [, in which case we are done, or , or , Thus we can assume that and begins with .
Case 2; Let .
In case (a) has the form

Thus, and for . Now suppose that show all components. By the criterion for [ on dnfs verified in [5] section (19) there exists some such that and with, for . Thus we can alter the proofs above to

 Pj
 G⊢Xj:Cj
 G⊢Xj:Dj([)

and apply the major induction hypothesis to them while we replace the [ inference

appropriately.
The case (b) follows form the main induction hypothesis. End of Proof. ∎

Definition 8.4 A BCD proof satisfying conditions (1),(2), and (3) is said to be “almost minimal” (am)

Definition 8.5 We define the notion of a oscillation in the Bohm tree of a beta normal term as follows. An oscillation is a sequence of pairs of nodes which descend in the tree such that the node

 ∖x1…xk.x

is paired with one of the arguments of this occurrence of which has a non-empty lambda prefix, and the next pair (if it exists) has the head variable of its first coordinate bound by this lambda prefix.

 ∖x1…xk.x…∖…     ∖y1…yl.y  /\vbox...∖∖z1…zm.yi…∖…∖u1…un.u

Definition 8.6 We say that the closed term

 ∖x1…xk.xiX1…Xl

in beta normal form is of class if

(i) every lambda prefix in the Bohm tree of has at most lambdas

(ii) every node in the Bohm tree of has at most immediate descendants

(iii) every oscillation in the Bohm tree of has at most length .

###### Lemma 8.4.

(class)
Let be in beta normal form. If is provable in BCD then then any oscillation beginning with dom has length less than or equal to and other oscillations have length less than

###### Proof.

w.l.o.g we may assume that and all are in dnf. The proof is by induction on an am proof of

Basis; is an axiom. Obvious.

Induction step; we distinguish several cases.

Case 1; ends in . Then and . By induction hypothesis applied to the premise of minimum .

Case 2; ends in . Then and

 P′
 F,u:B⊢U:C
 F⊢∖uU:B→C.

This case follows immediately.

Case 3; ends in Now consider the leftmost path of proceeding up ; i.e. we take left premises of ’s as often as possible, and then possibly the premise of an inference with a variable subject, and end at an axiom for a variable . This is all that is possible since is am. Let the axiom for be

 F′,x:D⊢x:D

If the axiom for is immediately followed by an ([) rule inference

 F′,x:D⊢x:D
 F′x:D⊢x:E

note that or = by tropical fact (4). Now consider one of the inferences on the leftmost path of .

 F′′,x:D⊢xX1…Xi:E′→E′′F′,x:D⊢Xi+1:E′
 F′,x:D⊢xX1…Xi+1:E′′

By induction hypothesis any oscillation in beginning with has length less than or equal to and other oscillations have length less than less than since is negative in E. Such an oscillation extends to one beginning with the with the head variable .

Case 4; ends in . Similar to case 3. End of proof. ∎

###### Corollary 8.5.

For each type there exists an integer n s.t. for any closed beta normal such that in BCD has class .

###### Proof.

by induction on the length of an am proof of using the class lemma. End of proof. ∎

###### Lemma 8.6.

(thinning)
Suppose that is an am proof of where is in beta normal form and the principal atoms of do not occur in either or any for . Then does not occur in .

###### Proof.

By induction on . End of proof. ∎

Defintion 8.10 An intersection type in dnf is said to be functional if each atom occurs at most twice and if twice then with opposite sign, and there is no + occurrence of . The type is co-functional if each atom occurs at most twice and if twice then with opposite sign, and there is no - occurrence of .

Definition 8.11 If is dnf, say with the set of hereditary components of , is defined recursively by

 hc(A)={A1,…,Ak}U U hc(Ai,j).

Defintion 8.12 If is dnf and is a subset of then is obtained by deleting the members of from and the corresponding arrows if entire lhs’s are deleted.

Lemma; (eta normal form)

Suppose that we have a functional type
where
,
and for

Let be in beta eta normal form. Then if , and
,

we have .

###### Proof.

by induction on the length of an am proof . let

 F=x1:Ai,…,xk+1:Ak+1,yk+2:Ak+2,…,yn:An

and suppose that . W.l.o.g and may assume does to end in and does not begin with . Suppose that is not . We then consider the left most path of . Beginning at the top this path consists of 0 or 1 application [, followed by 1 application of followed by applications of . Now write

 D1→(…(Dq→b)…).

Now since , by functionality, has a unique component

 Ei→(…(Eq→b)…)

with principal type . This accounts for the two possible occurrences of so , and we have for
Le

 F, z1:E1,…,zq:Eq.

Then the axiom at the top of the leftmost path is

 G−{zm+1:Em+1,…,zq:Eq}⊢yi:Ai

and for . Now consider the type
where
for and

for .
This is functional, so by induction hyothesis . But . End of proof. ∎

Construction;
Suppose that is in beta normal form with free variables
. We construct co-functional types , and a functional type such that if is the basis such that then . We construct the types by recursion; it will be convenient not to identify different free occurrences of each variable until becomes bound, so that the do not have strictly positive occurrences of until binding. Thus, in may have several types not beginning with . This is only a convenience.

1. if then the atom

2. if then let be the of all the types assigned to the different occurrences of in ; then the type for is

3. if then we have already types such that . We add the new occurrence , for a new atom, to and set the type for .

###### Lemma 8.7.

(uniqueness)
Suppose that is functional and there exists a beta-eta normal such that

then is unique.

###### Proof.

; set ; the proof is by induction on the length of an am proof of . Write as . Then

 B1→(…(Bl→b)…)

where . There are two cases which are determined by alone.

Case 1; is . Let . Then, since is am, has the component

 C=C1→(…(Cn→(Bm+1→(…(Bl→b)…)))…)

where
and the conclusion of the [ on the leftmost path of
(if it exists, otherwise is . Now the lemma applies, and if

,

then since for we have
. Thus, since is eta normal, this case cannot happen for two distinct values of . We have

 G⊢Zj:Cj, for j=1,…,n,

by shorter am proofs than , and

is functional so our induction hppothesis applies.

Case 2; is a . Similar. End of proof. ∎

###### Theorem 8.8.

If is strongly normalizable then there exists a functional type such that if is the beta eta normal form of then and is the unique beta eta normal form such that .

###### Proof.

by the construction of a functional type above and the uniqueness lemma, the theorem follows for already beta normal. We must show that this extends to all strongly normalizable . To this end we will consider a standard reduction from a strongly normalizable to its beta normal form . This is sufficient by eta postponement and the construction above. For one step we will have as an induction hypothesis where for each :dom, is co functional, is functional,and if range(
then

 B1→(…(Bl→A)…)

is functional. We will show that there exists , such that , where for each :dom is co functional, is functional and if range then is functional.Indeed will be related in the following way

1. dom is contained in dom.
Let