random lambda terms: how they look like and how they...

65

Upload: others

Post on 01-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Random lambda terms:

how they look like and how they behave

Katarzyna Grygiel

Joint work with: René David, Jakub Kozik, Christophe Ra�alli,

Guillaume Theyssier, Marek Zaionc

CLA, Lyon, 5th June 2009

Page 2: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Outline

1 Preliminaries: quest for the number

2 Let's make it easier: combinatory logic

3 Measuring trees

4 How does a random term look like?

5 One can judge a random term by its cover

6 What next?

Katarzyna Grygiel Random lambda terms. . .

Page 3: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Outline

1 Preliminaries: quest for the number

2 Let's make it easier: combinatory logic

3 Measuring trees

4 How does a random term look like?

5 One can judge a random term by its cover

6 What next?

Katarzyna Grygiel Random lambda terms. . .

Page 4: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Outline

1 Preliminaries: quest for the number

2 Let's make it easier: combinatory logic

3 Measuring trees

4 How does a random term look like?

5 One can judge a random term by its cover

6 What next?

Katarzyna Grygiel Random lambda terms. . .

Page 5: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Outline

1 Preliminaries: quest for the number

2 Let's make it easier: combinatory logic

3 Measuring trees

4 How does a random term look like?

5 One can judge a random term by its cover

6 What next?

Katarzyna Grygiel Random lambda terms. . .

Page 6: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Outline

1 Preliminaries: quest for the number

2 Let's make it easier: combinatory logic

3 Measuring trees

4 How does a random term look like?

5 One can judge a random term by its cover

6 What next?

Katarzyna Grygiel Random lambda terms. . .

Page 7: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Outline

1 Preliminaries: quest for the number

2 Let's make it easier: combinatory logic

3 Measuring trees

4 How does a random term look like?

5 One can judge a random term by its cover

6 What next?

Katarzyna Grygiel Random lambda terms. . .

Page 8: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Slogan

Probabilistic methods appear to be very powerful in computerscience. A point of view of those methods is that weinvestigate a typical object chosen from the set.

Katarzyna Grygiel Random lambda terms. . .

Page 9: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Enumerating lambda terms

We are dealing with untyped lambda calculus terms.

Size of a lambda term:

|x | = 0

|λx .M| = 1 + |M||MN| = 1 + |M|+ |N|

Problem

How many lambda terms of a given size are there?

Katarzyna Grygiel Random lambda terms. . .

Page 10: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Enumerating lambda terms

We are dealing with untyped lambda calculus terms.Size of a lambda term:

|x | = 0

|λx .M| = 1 + |M||MN| = 1 + |M|+ |N|

Problem

How many lambda terms of a given size are there?

Katarzyna Grygiel Random lambda terms. . .

Page 11: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Enumerating lambda terms

We are dealing with untyped lambda calculus terms.Size of a lambda term:

|x | = 0

|λx .M| = 1 + |M||MN| = 1 + |M|+ |N|

Problem

How many lambda terms of a given size are there?

Katarzyna Grygiel Random lambda terms. . .

Page 12: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Density

Let n ∈ N and let Λn(P) be a set of lambda terms of size nwith a given property P . We say that the density of termswith the property P is equal to d ∈ [0, 1] i� the limit

limn→∞

#Λn(P)

#Λn

exists and is equal to d .

Katarzyna Grygiel Random lambda terms. . .

Page 13: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Motivation

Question

How many programs have the halting property?

In terms of lambda calculus: compute the following limit

limn→∞

#Λn(SN)

#Λn

=?

where SN denotes the property of strong normalization.

Katarzyna Grygiel Random lambda terms. . .

Page 14: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Motivation

Question

How many programs have the halting property?

In terms of lambda calculus: compute the following limit

limn→∞

#Λn(SN)

#Λn

=?

where SN denotes the property of strong normalization.

Katarzyna Grygiel Random lambda terms. . .

Page 15: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Combinatorial view

Lambda tree

A lambda tree is a unary-binary tree in which each leaf can belabelled in as many ways as many vertices with exactly onechild occur on the path from the leaf to the root of the tree.

Problem (once again)

How many lambda trees of a given size are there?

Katarzyna Grygiel Random lambda terms. . .

Page 16: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Combinatorial view

Lambda tree

A lambda tree is a unary-binary tree in which each leaf can belabelled in as many ways as many vertices with exactly onechild occur on the path from the leaf to the root of the tree.

Problem (once again)

How many lambda trees of a given size are there?

Katarzyna Grygiel Random lambda terms. . .

Page 17: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Enumerating combinatory logic terms

The set CL of combinators is de�ned by the followinggrammar:

M := S | K | I | (MM)

Reduction rules de�ned on CL:

I P = P

K P Q = P

S P Q R = (P R)(Q R)

Katarzyna Grygiel Random lambda terms. . .

Page 18: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Enumerating combinatory logic terms

The set CL of combinators is de�ned by the followinggrammar:

M := S | K | I | (MM)

Reduction rules de�ned on CL:

I P = P

K P Q = P

S P Q R = (P R)(Q R)

Katarzyna Grygiel Random lambda terms. . .

Page 19: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Enumerating combinatory logic terms

Size of a CL term:

|S|, |K|, |I| = 0

|MN| = 1 + |M|+ |N|

Number of CL terms

#CLn = 3n+1 · C (n + 1)

Katarzyna Grygiel Random lambda terms. . .

Page 20: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Enumerating combinatory logic terms

Size of a CL term:

|S|, |K|, |I| = 0

|MN| = 1 + |M|+ |N|

Number of CL terms

#CLn = 3n+1 · C (n + 1)

Katarzyna Grygiel Random lambda terms. . .

Page 21: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

A random combinator does not terminate

Theorem

Let t0 be a combinator. The density of combinators with t0 asa subterm is 1.

Let us take t0 = S I I (S I I).

Since t0 is not strongly normalizing, we get

Corollary

The density of strongly normalizing combinators is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 22: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

A random combinator does not terminate

Theorem

Let t0 be a combinator. The density of combinators with t0 asa subterm is 1.

Let us take t0 = S I I (S I I).

Since t0 is not strongly normalizing, we get

Corollary

The density of strongly normalizing combinators is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 23: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

A random combinator does not terminate

Theorem

Let t0 be a combinator. The density of combinators with t0 asa subterm is 1.

Let us take t0 = S I I (S I I).

Since t0 is not strongly normalizing, we get

Corollary

The density of strongly normalizing combinators is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 24: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Bounds

For ε > 0 and for n big enough we have the following bounds:

Theorem

1 lower bound:

#Λn ≥(

(4− ε)n

ln(n)

)n− n

ln(n)

2 upper bound:

#Λn ≤(

(12 + ε)n

ln(n)

)n− n

3 ln(n)

Katarzyna Grygiel Random lambda terms. . .

Page 25: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Bounds

For ε > 0 and for n big enough we have the following bounds:

Theorem1 lower bound:

#Λn ≥(

(4− ε)n

ln(n)

)n− n

ln(n)

2 upper bound:

#Λn ≤(

(12 + ε)n

ln(n)

)n− n

3 ln(n)

Katarzyna Grygiel Random lambda terms. . .

Page 26: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Bounds

For ε > 0 and for n big enough we have the following bounds:

Theorem1 lower bound:

#Λn ≥(

(4− ε)n

ln(n)

)n− n

ln(n)

2 upper bound:

#Λn ≤(

(12 + ε)n

ln(n)

)n− n

3 ln(n)

Katarzyna Grygiel Random lambda terms. . .

Page 27: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Number of lambdas

Applying both bounds, we can estimate the numberof lambdas in a random term:

Theorem

1 The density of terms with more than 3n

ln(n)λ's is 0.

2 The density of terms with less than n

3 ln(n)λ's is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 28: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Number of lambdas

Applying both bounds, we can estimate the numberof lambdas in a random term:

Theorem

1 The density of terms with more than 3n

ln(n)λ's is 0.

2 The density of terms with less than n

3 ln(n)λ's is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 29: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Number of lambdas

Applying both bounds, we can estimate the numberof lambdas in a random term:

Theorem

1 The density of terms with more than 3n

ln(n)λ's is 0.

2 The density of terms with less than n

3 ln(n)λ's is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 30: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Depth, width. . .

Let t be a lambda tree.

1 The unary height of a term t is the maximal number ofunary nodes in a branch of t.

2 The binary height of a term t is the maximal number ofbinary nodes in a branch of t.

3 Two λ's in t are called incomparable if there is no branchcontaining both of them.The λ-width of t is the maximal number of pairwiseincomparable binding λ's.

Katarzyna Grygiel Random lambda terms. . .

Page 31: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Depth, width. . .

Let t be a lambda tree.

1 The unary height of a term t is the maximal number ofunary nodes in a branch of t.

2 The binary height of a term t is the maximal number ofbinary nodes in a branch of t.

3 Two λ's in t are called incomparable if there is no branchcontaining both of them.The λ-width of t is the maximal number of pairwiseincomparable binding λ's.

Katarzyna Grygiel Random lambda terms. . .

Page 32: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Depth, width. . .

Let t be a lambda tree.

1 The unary height of a term t is the maximal number ofunary nodes in a branch of t.

2 The binary height of a term t is the maximal number ofbinary nodes in a branch of t.

3 Two λ's in t are called incomparable if there is no branchcontaining both of them.The λ-width of t is the maximal number of pairwiseincomparable binding λ's.

Katarzyna Grygiel Random lambda terms. . .

Page 33: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

How high is a lambda tree?

Heights

1 A random lambda tree has the unary height greater thann

3 ln(n).

2 A random lambda tree has the binary height less thann√

ln(ln(n)).

Katarzyna Grygiel Random lambda terms. . .

Page 34: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

How high is a lambda tree?

Heights

1 A random lambda tree has the unary height greater thann

3 ln(n).

2 A random lambda tree has the binary height less thann√

ln(ln(n)).

Katarzyna Grygiel Random lambda terms. . .

Page 35: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

How high is a lambda tree?

Heights

1 A random lambda tree has the unary height greater thann

3 ln(n).

2 A random lambda tree has the binary height less thann√

ln(ln(n)).

Katarzyna Grygiel Random lambda terms. . .

Page 36: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

Let t be a term and u = λx .a be a subterm of t. We say thatλx is in head position if t = λ−→y .u for some, possibly empty,sequence of abstractions λ−→y .

Theorem

Let g(n) ∈ o(√

n/ ln(n)). The density of terms with less than

g(n) head lambdas is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 37: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

Let t be a term and u = λx .a be a subterm of t. We say thatλx is in head position if t = λ−→y .u for some, possibly empty,sequence of abstractions λ−→y .

Theorem

Let g(n) ∈ o(√

n/ ln(n)). The density of terms with less than

g(n) head lambdas is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 38: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

Many head lambdas are useful, i.e. binding:

Theorem

Let g(n) ∈ o(√

n/ ln(n)). The density of terms in which there

is at least one lambda among g(n) head lambdas that doesnot bind any variable is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 39: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

Many head lambdas are useful, i.e. binding:

Theorem

Let g(n) ∈ o(√

n/ ln(n)). The density of terms in which there

is at least one lambda among g(n) head lambdas that doesnot bind any variable is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 40: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

What is more, altogether they bind many occurences ofvariables:

Theorem

Let g(n) ∈ o(ln(n)

). The density of terms in which the total

number of occurrences of variables bound by the �rst threelambdas is at most g(n) is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 41: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

What is more, altogether they bind many occurences ofvariables:

Theorem

Let g(n) ∈ o(ln(n)

). The density of terms in which the total

number of occurrences of variables bound by the �rst threelambdas is at most g(n) is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 42: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

Actually, many head lambdas bind many occurences:

Theorem

For any �xed integers k and k0, the density of terms in whicheach of the �rst k lambdas binds more than k0 variables is 1.

Katarzyna Grygiel Random lambda terms. . .

Page 43: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Head lambdas

Actually, many head lambdas bind many occurences:

Theorem

For any �xed integers k and k0, the density of terms in whicheach of the �rst k lambdas binds more than k0 variables is 1.

Katarzyna Grygiel Random lambda terms. . .

Page 44: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

No closed subterms

Theorem

Let t0 be a term of size k0 with k occurrences of free variables.Assume k0 ≥ k + 1. Then the density of terms with t0 as asubterm is 0.

Corollary

Let t0 be a term. If

1 t0 is closed or

2 there are at least two lambdas in t0

then the density of terms with t0 as a subterm is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 45: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

No closed subterms

Theorem

Let t0 be a term of size k0 with k occurrences of free variables.Assume k0 ≥ k + 1. Then the density of terms with t0 as asubterm is 0.

Corollary

Let t0 be a term. If

1 t0 is closed or

2 there are at least two lambdas in t0

then the density of terms with t0 as a subterm is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 46: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

No closed subterms

Theorem

Let t0 be a term of size k0 with k occurrences of free variables.Assume k0 ≥ k + 1. Then the density of terms with t0 as asubterm is 0.

Corollary

Let t0 be a term. If

1 t0 is closed or

2 there are at least two lambdas in t0

then the density of terms with t0 as a subterm is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 47: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

No closed subterms

Theorem

Let t0 be a term of size k0 with k occurrences of free variables.Assume k0 ≥ k + 1. Then the density of terms with t0 as asubterm is 0.

Corollary

Let t0 be a term. If

1 t0 is closed or

2 there are at least two lambdas in t0

then the density of terms with t0 as a subterm is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 48: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

No closed subterms

Theorem

Let t0 be a term of size k0 with k occurrences of free variables.Assume k0 ≥ k + 1. Then the density of terms with t0 as asubterm is 0.

Corollary

Let t0 be a term. If

1 t0 is closed or

2 there are at least two lambdas in t0

then the density of terms with t0 as a subterm is 0.

Katarzyna Grygiel Random lambda terms. . .

Page 49: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Width of a tree

Theorem

The lambda width of a random term is at most 2.

Now we know that a random lambda tree:� starts with many useful unary nodes,� ends with many binary nodes,� has many leaves.Thus, it looks a bit like. . .

Katarzyna Grygiel Random lambda terms. . .

Page 50: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Width of a tree

Theorem

The lambda width of a random term is at most 2.

Now we know that a random lambda tree:

� starts with many useful unary nodes,� ends with many binary nodes,� has many leaves.Thus, it looks a bit like. . .

Katarzyna Grygiel Random lambda terms. . .

Page 51: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Width of a tree

Theorem

The lambda width of a random term is at most 2.

Now we know that a random lambda tree:� starts with many useful unary nodes,

� ends with many binary nodes,� has many leaves.Thus, it looks a bit like. . .

Katarzyna Grygiel Random lambda terms. . .

Page 52: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Width of a tree

Theorem

The lambda width of a random term is at most 2.

Now we know that a random lambda tree:� starts with many useful unary nodes,� ends with many binary nodes,

� has many leaves.Thus, it looks a bit like. . .

Katarzyna Grygiel Random lambda terms. . .

Page 53: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Width of a tree

Theorem

The lambda width of a random term is at most 2.

Now we know that a random lambda tree:� starts with many useful unary nodes,� ends with many binary nodes,� has many leaves.

Thus, it looks a bit like. . .

Katarzyna Grygiel Random lambda terms. . .

Page 54: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Width of a tree

Theorem

The lambda width of a random term is at most 2.

Now we know that a random lambda tree:� starts with many useful unary nodes,� ends with many binary nodes,� has many leaves.Thus, it looks a bit like. . .

Katarzyna Grygiel Random lambda terms. . .

Page 55: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

. . . a stone pine

Katarzyna Grygiel Random lambda terms. . .

Page 56: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Safe terms

1 Let t be a term of width 1. We say that t is unfair if thehighest binding lambda in t occurs in its leftmost branch.

2 We say that a term t is safe if

either its width is less than 2

or its width is equal to 2 and its smallest subterm (u v)of width 2 is such that either u or v is not unfair.

Theorem

A safe term is strongly normalizing.

Katarzyna Grygiel Random lambda terms. . .

Page 57: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Safe terms

1 Let t be a term of width 1. We say that t is unfair if thehighest binding lambda in t occurs in its leftmost branch.

2 We say that a term t is safe if

either its width is less than 2

or its width is equal to 2 and its smallest subterm (u v)of width 2 is such that either u or v is not unfair.

Theorem

A safe term is strongly normalizing.

Katarzyna Grygiel Random lambda terms. . .

Page 58: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Safe terms

1 Let t be a term of width 1. We say that t is unfair if thehighest binding lambda in t occurs in its leftmost branch.

2 We say that a term t is safe if

either its width is less than 2

or its width is equal to 2 and its smallest subterm (u v)of width 2 is such that either u or v is not unfair.

Theorem

A safe term is strongly normalizing.

Katarzyna Grygiel Random lambda terms. . .

Page 59: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Di�erent language, di�erent results

Theorem

A random term is safe.

Corollary

A random term is strongly normalizing.

Katarzyna Grygiel Random lambda terms. . .

Page 60: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

Di�erent language, di�erent results

Theorem

A random term is safe.

Corollary

A random term is strongly normalizing.

Katarzyna Grygiel Random lambda terms. . .

Page 61: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

What next?

Other notions of size

Typable terms

Other patterns, e.g. λx .y

. . .Number of terms

Katarzyna Grygiel Random lambda terms. . .

Page 62: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

What next?

Other notions of size

Typable terms

Other patterns, e.g. λx .y

. . .Number of terms

Katarzyna Grygiel Random lambda terms. . .

Page 63: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

What next?

Other notions of size

Typable terms

Other patterns, e.g. λx .y

. . .Number of terms

Katarzyna Grygiel Random lambda terms. . .

Page 64: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

What next?

Other notions of size

Typable terms

Other patterns, e.g. λx .y

. . .Number of terms

Katarzyna Grygiel Random lambda terms. . .

Page 65: Random lambda terms: how they look like and how they behaveperso.ens-lyon.fr/pierre.lescanne/CLA/Talks/Grygiel_cla2009.pdf · Introduction Combinatory logic Measuring trees Shape

Introduction Combinatory logic Measuring trees Shape of a tree Behaviour Future work

The end.

Katarzyna Grygiel Random lambda terms. . .