Enumerating (restricted) -terms Motzkin trees -terms with bounded - - PowerPoint PPT Presentation

enumerating restricted terms
SMART_READER_LITE
LIVE PREVIEW

Enumerating (restricted) -terms Motzkin trees -terms with bounded - - PowerPoint PPT Presentation

Enumerating (restricted) -terms Danile GARDY Enriched trees Enumerating (restricted) -terms Motzkin trees -terms with bounded number of Danile GARDY unary nodes -terms of bounded PRiSM, Universit Versailles St-Quentin en


slide-1
SLIDE 1

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Enumerating (restricted) λ-terms

Danièle GARDY

PRiSM, Université Versailles St-Quentin en Yvelines

and

D.M.G., T.U. Wien In collaboration with O. Bodini, B. Gittenberger and A. Jacquot

slide-2
SLIDE 2

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

1

Enriched trees

2

Motzkin trees

3

λ-terms with bounded number of unary nodes

4

λ-terms of bounded unary height

5

λ-terms of fixed arity

6

Concluding remarks

slide-3
SLIDE 3

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

λ-terms and enriched (Motzkin) trees

slide-4
SLIDE 4

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Definition of λ-terms

T ::= a | (T ∗ T) | λa.T (T ∗ T): application λa.T: abstraction (λx.(x ∗ x) ∗ λy.y) λy.(λx.x ∗ λx.y)

x y x x y

slide-5
SLIDE 5

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Enriched Motzkin trees

y x x x y

Labelling rules:

  • Binary nodes are unlabelled
  • Unary nodes get distinct labels (colors)
  • Leaves get the label (color) of one of their unary

ancestors

slide-6
SLIDE 6

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Free and bound variables

  • Here all variables are bound: closed terms
  • Some variables may be free
slide-7
SLIDE 7

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Enumeration?

  • Recursive definition for λ-terms?
  • L: class of λ-terms with free variables
  • N atomic class of binary node
  • U atomic class of unary node
  • F atomic class of free leaf
  • B atomic class of bound leaf

L = F +

  • N × L2

+ (U × subs(F → F + B, L))

  • Lℓ,n number of λ-terms of size n (total number of nodes)

with ℓ free leaves

  • Generating function L(z, f) =

ℓ,n Lℓ,nf ℓzn satisfies a

functional equation L(z, f) = fz + z L(z, f)2 + z L(z, f + 1).

slide-8
SLIDE 8

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Analytic combinatorics

  • Generating function of a sequence an: A(z) =

n anzn

  • A(z) considered as a function of complex variable z:

domain of analycity? radius of convergence ρ?

  • Type and location of dominant singularity determine the

asymptotic behaviour of the sequence an

  • E.g., ρ algebraic of type (1 − z

ρ)α (α ∈ N) gives

[zn]A(z) ∼ ρn n−α−1 Γ(−α)

  • Extensions to multivariate cases, asymptotic

distributions

slide-9
SLIDE 9

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Enumeration???

  • Generating function enumerating closed λ-terms

(without free variables): L(z, 0)

  • Generating function enumerating all λ-terms:

L(z, 1) = 1

z L(z, 0) − L(z, 0)2

  • L(z, 0) =

1 2z

  • 1 −
  • Λ(z)
  • with Λ(z) equal to

1−2z+2z

  • 1 − 2z − 4z2 + 2z
  • ....
  • 1 − 2z − 4nz2 + 2z√...
  • L(z, 0) has null radius of convergence ⇒ standard tools
  • f analytic combinatorics fail
slide-10
SLIDE 10

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

What can we do?

  • Try to find a way to deal with null radius of

convergence?

  • Ad hoc methods?

(4 − ǫ)n log n n(1−1/ log n) ≤ Ln ≤ (12 + ǫ)n log n n(1−1/3 log n)

[David et al. 10; here leaves have size 0]

  • Consider sub-classes of terms?
  • Restrict the total number of abstractions

[Bodini-G-Gittenberger’14]

  • Restrict the number of abstractions in a path from the

root towards a leaf: bounded unary height

[Bodini-G-Gittenberger’11, Bodini-G-Gittenberger’14]

  • Restrict the number of pointers from an abstraction to a

leaf [Bodini-G-Jacquot’10; Bodini-G-Gittenberger-Jacquot’13, Bodini-Gittenberger’15]

slide-11
SLIDE 11

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Motzkin trees

slide-12
SLIDE 12

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Motzkin trees

M = Z + (U × M) + (Z × M2) M(z) = 1 2z

  • 1 − z −
  • 1 − 2z − 3z2
  • Dominant singularity at z = 1/3 of square-root type

[zn]M(z) ∼ 3n+ 1

2

2n√πn

slide-13
SLIDE 13

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

q unary nodes

Mq = U × Mq−1 +

q

  • ℓ=0

A × Mℓ × Mq−ℓ. Recurrence equation on the generating functions Mq(z) = zMq−1(z) + z

1≤ℓ≤q−1 Mℓ(z) Mq−ℓ(z)

1 − 2zM0(z) . ⇒ there exist polynomials Pq s.t. Mq(z) = zq+1 Pq(z2) (1 − 4z2)q− 1

2 ,

Straightforward computations give [zn]Mq(z) ∼ [zn]M≤q ∼ √ 2 Pq(1/4) Γ(q − 1

2)

4n nq− 3

2

slide-14
SLIDE 14

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Leaves at same unary height

  • Tree on the left: all leaves have unary height 1
  • Tree on the right: leaves have unary heights 1, 2 and 1
slide-15
SLIDE 15

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Leaves at same unary height

MHk = U × MHk−1 + A × MH2

k

On generating functions

MHk = 1 2   1 −

  • 1 − 2z + 2z
  • 1 − 2z + 2z
  • ... + 2z
  • 1 − 4z2

  

Two singularities

  • z = − 1

2 of type (1 + 2z)

1 2 (negligible)

  • z = 1

2 of type (1 + 2z)

1 2k+1 (dominant, comes from the

innermost radicand) ⇒ [zn]MHk(z) ∼ 2

1 2k+1 2n n−1− 1 2k+1

2k+1Γ(1 −

1 2k+1 )

slide-16
SLIDE 16

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Bounded unary height

Here leaves can have different unary height! MH≤k = Z + U × MH≤k−1 + A × MH2

≤k

Generating function

MH≤k = 1 2    1 −

  • 1 − 2z − 4z2 + 2z
  • 1 − 2z − 4z2 + 2z
  • ... + 2z
  • 1 − 4z2

   

Dominant singularity ρk comes from outermost radicand, decreases towards 1

3

⇒ [zn]MH≤k ∼

  • 1 + 4ρ2

k

4 ρn+1

k

n√πn

slide-17
SLIDE 17

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

λ-terms with bounded number

  • f unary nodes
slide-18
SLIDE 18

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

q unary nodes

Sq =

  • U × subs(F → F + B, Sq−1)
  • +

q

  • ℓ=0

(A, Sℓ, Sq−ℓ) Generating function Sq(z, f) = zSq−1(z, f + 1) + z

q

  • ℓ=0

Sℓ(z, f) Sq−ℓ(z, f). G.F. for closed terms Sq(z, 0)?

S1(z, 0) = 1 2 − √ 1 − 4z2 2 ; S2(z, 0) = z 2(1 − 2z2) + 2z3 √ 1 − 4z2 − z √ 1 − 8z2 2 √ 1 − 4z2 ;

(no terms of size n = q mod 2)

slide-19
SLIDE 19

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

q unary nodes

Sq(z, f) = − zq−1σq(f) 2 q−1

ℓ=0 σℓ(f)

+ Rq(z, σ0(f), ..., σq−1(f)) where

  • σq(f) =
  • 1 − 4(f + q)z2
  • Rq rational, denominator

0≤ℓ<q σℓ(f)αℓ,q

  • αℓ,q > 0, either integer or 1

2+ an integer

slide-20
SLIDE 20

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

q unary nodes

Sq(z, f) = − zq−1σq(f) 2 q−1

ℓ=0 σℓ(f)

+ Rq(z, σ0(f), ..., σq−1(f)) where

  • σq(f) =
  • 1 − 4(f + q)z2
  • Rq rational, denominator

0≤ℓ<q σℓ(f)αℓ,q

  • αℓ,q > 0, either integer or 1

2+ an integer

⇒ Sq(z, 0) = − zq−1 1 − 4qz2 2 q−1

ℓ=0

√ 1 − 4ℓz2 +Rq(z, 1,

  • 1 − 4z2, ...,
  • 1 − 4(q − 1)z2)

Dominant singularities at ±

1 2√q of square-root type

⇒ [zn]Sq(z, 0) ∼ q

q 2

√q! √ 2 π n3 (4q)

n+1−q 2

slide-21
SLIDE 21

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

λ-terms of bounded unary height

slide-22
SLIDE 22

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

The classes P(i,k)

k: maximal number of abstractions on a path from the root to a leaf

  • P(0,k): λ-terms with bound variables and unary

height ≤ k

  • P(1,k): λ-terms with bound variables, 1 kind of free

variables, and unary height ≤ k − 1

  • ...
  • P(i,k): λ-terms with bound variables, i kinds of free

variables, and unary height ≤ k − i

  • ...
  • P(k,k): λ-terms with bound variables, k kinds of free

variables, and no unary node

slide-23
SLIDE 23

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

The classes P(i,k)

Set up equations on generating functions P(i,k), solve, and take H≤k(z) = P(0,k)(z):

H≤k = 1 −

  • 1 − 2z + 2z
  • 1 − 2z − 4z2 + 2z
  • ...

√ 1 − 4kz2 2z

We can start the asymptotic study of its coefficients!

slide-24
SLIDE 24

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

The classes P(i,k)

Set up equations on generating functions P(i,k), solve, and take H≤k(z) = P(0,k)(z):

H≤k = 1 −

  • 1 − 2z + 2z
  • 1 − 2z − 4z2 + 2z
  • ...

√ 1 − 4kz2 2z

We can start the asymptotic study of its coefficients!

  • H≤k is algebraic and written with k + 1 iterated

radicands

  • Its singularities are the values that cancel its radicands
  • Which radicant has smallest root? (We rank radicands

from the innermost to the outermost)

slide-25
SLIDE 25

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

  • k = 1

H≤1(z) = 1 −

  • 1 − 2z + 2z

√ 1 − 4z2 2z

Dominant singularity: ρ = 1

2 (cancels both radicands)

[zn]H≤1(z) ∼ 1 4 2

1 4 2nn− 5 4

Γ( 3

4)

  • k = 2

H≤2(z) = 1 −

  • 1 − 2z + 2z
  • 1 − 2z − 4z2 + 2z

√ 1 − 8z2 2z

Dominant singularity: ρ = 0.3437999303 (cancels the second innermost radicand) [zn]H≤2(z) ∼ C Γ( 1

2)

n− 3

2 ρ−n

slide-26
SLIDE 26

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Where is the dominant singularity when k grows? Function Radicand Singularity H≤1 {1,2} 0.5 H≤2 2 0.3438 H≤3 2 0.2760 ... ... ... H≤8 {2,3} 0.1667 H≤9 3 0.1571 ... ... ... SH≤134 3 0.0418 H≤135 {3,4} 0.0417 H≤136 4 0.0415 ... ... ... Sometimes, the same value cancels two consecutive radicands.

slide-27
SLIDE 27

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Define uk = u2

k−1 + k for k > 0, u0 = 0

  • u1 = 1, u2 = 3, u3 = 12, u4 = 148, u5 = 21909, ... Doubly

exponential growth: limk→∞ u1/2k

k

≃ χ = 1.36660956...

  • Set Nk = u2

k − u2 k−1: N1 = 1, N2 = 8, N3 = 135, N4 = 21760,

N5 = 479982377, ...

Theorem

i) ∃i, k = Ni: radicands of ranks i and (i + 1) cancel for the same value, are both dominant. Dominant singularity ρNi =

1 2ui is algebraic of type 1/4.

[zn]H≤Ni ∼ Cin−5/4ρn

i

ii) k ∈]Ni, Ni+1[: dominant radicand has rank i. Dominant singularity ρk is algebraic of type 1/2. [zn]H≤k ∼ Ckn−3/2ρn

k

slide-28
SLIDE 28

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

λ-terms of fixed arity

slide-29
SLIDE 29

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

λ-terms of fixed arity

Two classes of closed λ-terms:

  • BCI(p) (linear terms): each abstraction binds exactly p

variables

  • BCK(p) (affine terms): each abstraction binds at most

p variables Consider first p = 1, then generalize...

slide-30
SLIDE 30

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

BCI(1) and BCK(1)

1 Class of λ-terms when each abstraction binds exactly

  • ne variable: BCI(1)
  • Size is always 3n + 2
  • Bijection with triangular pointed diagrams enumerated

according to the number of edges (Vidal)

  • Asymptotic equivalent BCI(1)3n+2 ∼ C√n

6n

e

n

2 Adapt this to get

BCK(1)n ∼ C1 n1/6 2n e n/3 e

(2n)2/3 2

− (2n)1/3

6

slide-31
SLIDE 31

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

BCI(p)

  • A BCI(p) term with j abstraction nodes has size (2p + 1)j − 1
  • Smallest terms: j = 1; one unary node above a binary tree
  • Other terms:
  • binary root, two BCI(p) terms as left and right children
  • unary root, one child with p free leaves...
  • ... but a BCI(p) term is closed!
slide-32
SLIDE 32

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

How do we get new, free leaves?

slide-33
SLIDE 33

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

The differential operator ∆p

  • p hits
  • some edges can be hit repeatedly
  • ℓ different edges are hit

αℓ,p =

  • i si=ℓ;

i i si=p

s1!...sp!

  • p
  • m=1

2m m sm ∆p =

  • 1≤ℓ≤p

αℓ,p ℓ! zℓ+2p+1 Dl

Univariate generating function for BCI(p) satisfies Y(z) = Cp−1z2p + zY(z)2 + ∆p Y(z)

slide-34
SLIDE 34

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Solving the differential equation for BCI(p), p ≥ 2? Y = Cp−1z2p + zY 2 + ∆pY We cannot solve explicitly this differential equation, nor find asymptotics by singularity analysis (radius of convergence is null again)...

slide-35
SLIDE 35

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Solving the differential equation for BCI(p), p ≥ 2? Y = Cp−1z2p + zY 2 + ∆pY We cannot solve explicitly this differential equation, nor find asymptotics by singularity analysis (radius of convergence is null again)... ... but we can do asymptotics for an approximate equation Y = Cp−1z2p + 2Cp−1zY + ∆pY with same asymptotic behaviour!

Theorem

Asymptotic number of λ-terms of size (2p + 1)n − 1 : αp βn

p n

p(p−2) 2p+1 +np

(αp and βp are explicit)

slide-36
SLIDE 36

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Concluding remarks

slide-37
SLIDE 37

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Varied asymptotic behaviours

1 Motzkin trees

  • Number of unary nodes = q: one radical, Cq 4nnq− 3

2

  • Shared unary height of leaves = k: iterated radicals;

innermost radical dominates; Ck 2n n−1−

1 2k+1

  • Bounded unary height = k: iterated radicals, outermost

radical dominates; Ck ρn

k n− 3

2

2 λ-terms

  • Number of unary nodes = q: product of radicals;

Cq (4q)

n+1−q 2

n− 3

2

  • Bounded unary height = k: iterated radicals; dominant

radical fluctuates

  • Standard case: Ckn− 3

2 ρn

k

  • Special values: two dominant radicals; Ckn− 5

4 ρn

k

  • Arity = p: αp βn−1

p

n

p(p−2) 2p+1 nnp

  • Unrestricted terms:

c1

  • 4n

e log n n/2 log n n ≤ λn ≤ c2

  • 9(1 + ε)n

e log n n/2 (log n)

n 2 log n

n3/2

slide-38
SLIDE 38

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Statistical properties

  • Asymptotic enumeration of other classes? of

unrestricted λ-terms?

  • Number of nodes of various types?
  • Unary/total height?
  • Number of λ-terms in normal form?

Forbidden pattern

  • ...

Work in progress

slide-39
SLIDE 39

Enumerating (restricted) λ-terms Danièle GARDY Enriched trees Motzkin trees λ-terms with bounded number of unary nodes λ-terms of bounded unary height λ-terms of fixed arity Concluding remarks

Thanks for your attention