Expressibility in the Lambda Calculus with

Report 2 Downloads 133 Views
Expressibility in the Lambda Calculus with µ Clemens Grabmayer and Jan Rochel Dept. of Philosophy Dept. of Information & Computing Sciences Utrecht University

RTA 2013, TU Eindhoven 25 June 2013

Motivation motivation: ▸

λletrec as an abstraction & the core of functional languages



infinite λ-terms ∼ unfolding semantics of functional programs



optimizing program transformations on λletrec

question: ▸

which infinite λ-terms are λletrec -expressible, i.e. can be obtained from λletrec -terms by infinite unfolding?

Motivation motivation: ▸

λletrec as an abstraction & the core of functional languages



infinite λ-terms ∼ unfolding semantics of functional programs



optimizing program transformations on λletrec

question: ▸

which infinite λ-terms are λµ -expressible, i.e. can be obtained from λµ -terms by infinite unfolding?

we restrict to: ▸

λµ instead of λletrec

we develop: ▸

2 rewriting characterizations of λµ -expressible infinite λ-terms

Which infinite λ-terms are expressible finitely in λµ ? Example µf .λx.λy .f y x

µf λx λy @ @ f

x y

Which infinite λ-terms are expressible finitely in λµ ? Example µf .λx.λy .f y x

λx λy @ @

x y

Which infinite λ-terms are expressible finitely in λµ ? Example ↠ ↠µ

µf .λx.λy .f y x

λxy .(λxy .(λxy .(. . .) y x) y x) y x λx λy @

λx @

λy

↠ ↠▽

@ @

λx

y

λy

x

@

y @ .. .

x y

x

Which infinite λ-terms are expressible finitely in λµ ? Example ↠ ↠µ

µf .λx.λy .f y x

λxy .(λxy .(λxy .(. . .) y x) y x) y x λx

λx

λa

@

λb

@

λy

↠ ↠▽

@ @

λy

λx

@

x y

λc

Ð→ ○ β

@

λy

x

λd

@

y @ .. .

x y

a

b

@ .. .

c

Which infinite λ-terms are expressible finitely in λµ ? Example ↠ ↠µ

µf .λx.λy .f y x

λxy .(λxy .(λxy .(. . .) y x) y x) y x λx

λx

λa

@

λb

@

λy

↠ ↠▽

@ @

λy

λx

y

λc

Ð→ ○ β λd

@

y @ .. .

x y

a

@

λy

x

λa

@

x

b

@ .. .

c

Ð→ ○ β

λb λc λd .. .

Which infinite λ-terms are expressible finitely in λletrec ? Example ↠ ↠µ

µf .λx.λy .f y x

λxy .(λxy .(λxy .(. . .) y x) y x) y x λx

λx

λa

@

λb

@

λy

↠ ↠▽

@ @

λy

λx

y

λc

Ð→ ○ β λd

@

y @ .. .

x y

a

@

λy

x

λa

@

x

b

@ .. .

c

Ð→ ○ β

λb λc

↞ ↞▽ λx

λd .. .

µf .λx.f

Which infinite λ-terms are expressible finitely in λletrec ? Example ↠ ↠letrec

letrec f = λxy .f y x in f

λxy .(λxy .(λxy .(. . .) y x) y x) y x

λx

λx

λa

@

λb

@

λy

↠ ↠▽

@ @

λy

λx

x y

λc

Ð→ ○ β λd

@

y @ .. .

x y

a

@

λy

x

λa

@

b

@ .. .

c

Ð→ ○ β

λb λc

↞ ↞▽ λx

λd .. .

letrec f = λx.f in f

λµ -expressible ‘regular’ λ∞ -term λx

µf .λxy .f y x

λy λx

@

λy

@

@ @

λx x

y

λy

y

@ @ .. .

term graph

x

x y

syntax tree

λµ -expressible ‘regular’ λ∞ -term µf .λxy .f y x λx λy

λ

λy

λ

@

@

@

@ @

λx

λx x

@

y

λ

λy

y

λ

@ @ .. .

term graph

x

@ x

y

syntax tree

@ .. .

bindings

λµ -expressible ‘regular’ λ∞ -term µf .λxy .f y x λx λy

λ

λy

λ

@

@

@

@ @

λx

λx x

@

y

λ

λy

y

λ

@ @ .. .

term graph

x

@ x

y

syntax tree

@ .. .

bindings finite entanglement

λµ -expressible ‘regular’ λ∞ -term λx

µf .λxy .f y x

λy λx

@

λy

@

@ @

λx x

@ @ .. .

x y

syntax tree

λx

λ

λy

@

@

@

y

λy

y

term graph

x

λ

@

λ

λx

λ

λy

@

@

@ .. .

bindings finite entanglement

@ .. .

x y

x y

scopes

λµ -expressible ‘regular’ λ∞ -term λx

µf .λxy .f y x

λy λx

@

λy

@

@ @

λx x

y

@ @ .. .

x y

syntax tree

λx

λ

λy

@

@

λx

λ

λy

@

@

λx

y

y λy

@

@ .. .

x

.. .

x y

y

scopes

x

x

@

@

bindings finite entanglement

λy

@

@

λ

.. .

λx

@

@

λy

y

term graph

x

λ

scope+ s

λµ -expressible ‘regular’ λ∞ -term λx

µf .λxy .f y x

λy λx

@

λy

@

@ @

λx x

y

@ @ .. .

x y

syntax tree

λx

λ

λy

@

@

λx

λ

λy

@

@

λx

y

y λy

@

@ .. .

x

.. .

x y

y

scopes

x

x

@

@

bindings finite entanglement

λy

@

@

λ

.. .

λx

@

@

λy

y

term graph

x

λ

scope+ s finite nesting

Not λµ -expressible ‘regular’ λ∞ -term λx λy @ λx

x

@ λy

y

@ .. .

x

syntax tree

Not λµ -expressible ‘regular’ λ∞ -term λx

λ

λy

λ

@

@

λx

λ

x

@ λy

@ λ

y

@ .. .

@ x

syntax tree

.. .

bindings

Not λµ -expressible ‘regular’ λ∞ -term λx

λ

λy

λ

@

@

λx

λ

x

@ λy

@ λ

y

@ .. .

@ x

syntax tree

.. .

bindings infinitely entangled

Not λµ -expressible ‘regular’ λ∞ -term λx

λ

λx

λx

λy

λ

λy

λy

@

@

@

@

λx

x

@ λy

λx

@

@ λy

λ

y

@ .. .

λ

x

syntax tree

bindings infinitely entangled

.. .

x

@ λy

y

@

@ .. .

λx

x

y

@ x

scopes

.. .

x

scope+ s

Not λµ -expressible ‘regular’ λ∞ -term λx

λ

λx

λx

λy

λ

λy

λy

@

@

@

@

λx

x

@ λy

λx

@

@ λy

λ

y

@ .. .

λ

x

syntax tree

bindings infinitely entangled

.. .

x

@ λy

y

@

@ .. .

λx

x

y

@ x

scopes

.. .

x

scope+ s infinite nesting

Concepts and results We introduce: ▸

generalizations to λ∞ -terms of first-order concept of regularity ▸ ▸



strong regularity regularity

proof systems for regularity and strong regularity

use: ▸

binding–capturing chains for λ∞ -terms [Melli´es, van Oostrom]

Concepts and results We introduce: ▸

generalizations to λ∞ -terms of first-order concept of regularity ▸ ▸



strong regularity regularity

proof systems for regularity and strong regularity

use: ▸

binding–capturing chains for λ∞ -terms [Melli´es, van Oostrom]

and show:

Results ▸

λµ -expressibility = strong regularity



strong regularity = regularity + a binding–capturing chains property

Deconstructing/observing λ∞ -terms ()λx.λy .x x y

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x

(λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti (λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0

(i ∈ {0, 1})

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x

(λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti

(i ∈ {0, 1})

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0 (λx1 . . . xn xn+1 ) T0 →S (λx1 . . . xn ) T0

(if λxn+1 is vacuous)

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@0 (λx) x

(λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti

(i ∈ {0, 1})

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0 (λx1 . . . xn xn+1 ) T0 →S (λx1 . . . xn ) T0

(if λxn+1 is vacuous)

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@0 (λx) x →reg+ -generated subterms of λx.λy .x x y w.r.t. rewrite relation →reg+ : (λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti

(i ∈ {0, 1})

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0 (λx1 . . . xn xn+1 ) T0 →S (λx1 . . . xn ) T0

(if λxn+1 is vacuous)

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@0 (λx) x →reg+ -generated subterms of λx.λy .x x y w.r.t. rewrite relation →reg+ : (λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti

(i ∈ {0, 1})

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0 (λx1 . . . xn xn+1 ) T0 →S (λx1 . . . xn ) T0

(if λxn+1 is vacuous)

formalized as a CRS, e.g. rule: pren ([x1 . . . xn ] abs([xn+1 ] Z (⃗ x ))) → pren+1 ([x1 . . . xn+1 ]Z (⃗ x ))

Deconstructing/observing λ∞ -terms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@1 (λxy ) y

()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@0 (λx) x

()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@1 (λx) x

→reg+ -generated subterms of λx.λy .x x y w.r.t. rewrite relation →reg+ : (λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti

(i ∈ {0, 1})

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0 (λx1 . . . xn xn+1 ) T0 →S (λx1 . . . xn ) T0

(if λxn+1 is vacuous)

formalized as a CRS, e.g. rule: pren ([x1 . . . xn ] abs([xn+1 ] Z (⃗ x ))) → pren+1 ([x1 . . . xn+1 ]Z (⃗ x ))

Generated subterms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@1 (λxy ) y

()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@1 (λx) x

()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@0 (λx) x

→reg+ -generated subterms of λx.λy .x x y w.r.t. rewrite relation →reg+ : (λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti

(i ∈ {0, 1})

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0 (λx1 . . . xn xn+1 ) T0 →S (λx1 . . . xn ) T0

(if λxn+1 is vacuous)

→reg -generated subterms w.r.t. rewrite relation →reg : (λx1 . . . xi . . . xn+1 ) T0 →del (λx1 . . . xi−1 xi+1 . . . xn+1 ) T0

(if λxi is vacuous)

Generated subterms ()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@1 (λxy ) y →del (λy ) y

()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@1 (λx) x

()λx.λy .x x y →λ (λx) λy .x x y →λ (λxy ) x x y →@0 (λxy ) x x →S (λx) x x →@0 (λx) x

→reg+ -generated subterms of λx.λy .x x y w.r.t. rewrite relation →reg+ : (λx1 . . . xn ) T0 T1 →@i (λx1 . . . xn ) Ti

(i ∈ {0, 1})

(λx1 . . . xn ) λxn+1 .T0 →λ (λx1 . . . xn+1 ) T0 (λx1 . . . xn xn+1 ) T0 →S (λx1 . . . xn ) T0

(if λxn+1 is vacuous)

→reg -generated subterms w.r.t. rewrite relation →reg : (λx1 . . . xi . . . xn+1 ) T0 →del (λx1 . . . xi−1 xi+1 . . . xn+1 ) T0

(if λxi is vacuous)

Regularity and strong regularity

An infinite first-order term t is regular if: t has only finitely many subterms.

Definition 1

A λ∞ -term T is strongly regular if: ()T has only finitely many →reg+ -generated subterms.

Regularity and strong regularity

An infinite first-order term t is regular if: t has only finitely many subterms.

Definition 1

A λ∞ -term T is strongly regular if: ()T has only finitely many →reg+ -generated subterms.

2

A λ∞ -term U is regular if: ()U has only finitely many →reg -generated subterms.

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

T = λxy .T y x

.. .

()T

=

()λxy .T y x

x y

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

T = λxy .T y x

.. .

()T

= →λ

()λxy .T y x (λx) λy .T y x

x y

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

T = λxy .T y x

.. .

()T

=

()λxy .T y x

→λ

(λx) λy .T y x

→λ

(λxy ) T y x

x y

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

T = λxy .T y x

.. .

()T

=

()λxy .T y x

→λ

(λx) λy .T y x

→λ

(λxy ) T y x

→@0

(λxy ) T y

x y

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

T = λxy .T y x

.. .

()T

x

=

()λxy .T y x

→λ

(λx) λy .T y x

→λ

(λxy ) T y x

→@0

(λxy ) T y

→@0

(λxy ) T

y

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

T = λxy .T y x

.. .

()T

x y

=

()λxy .T y x

→λ

(λx) λy .T y x

→λ

(λxy ) T y x

→@0

(λxy ) T y

→@0

(λxy ) T

→S

(λx) T

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

T = λxy .T y x

.. .

()T

x y

=

()λxy .T y x

→λ

(λx) λy .T y x

→λ

(λxy ) T y x

→@0

(λxy ) T y

→@0

(λxy ) T

→S

(λx) T

→S

()T

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

()T

x y

=

()λxy .T y x

→λ

(λx) λy .T y x

→λ

(λxy ) T y x

→@0

(λxy ) T y

→@0

(λxy ) T

→S

(λx) T

→S

()T

... @

x y

T = λxy .T y x

.. .

x y

→reg+ -generated subterms

strongly regular λ∞ -term λx

λx

λy

λy

@

@

@ λx

λy

@

@ @

x y

T = λxy .T y x

.. .

λ (λxy) T y x

S x

y

(λxy) T y

@1 (λxy) x

@0 @1 (λxy) T x

y

λ (λx) λy T y x

@0

λx

y

λy

@ .. .

@

x

()T

S (λxy) y (λx) x

S (λx) T

finitely many →reg+ -generated subterms Ô⇒ T is strongly regular

Not strongly regular λ∞ -term

λa

λa

λb

λb

@

@

λc

λc

a

λd

b

()λa.λb.(. . . ) a

a

b

@

@ .. .

=

@

@ λd

U

c

.. .

λ∞ -term U

c

→reg+ -generated subterms

Not strongly regular λ∞ -term

λa

λa

λb

λb

@

@

λc

λc

a

λd

b

→λ

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a

a

b

@

@ .. .

=

@

@ λd

U

c

.. .

λ∞ -term U

c

→reg+ -generated subterms

Not strongly regular λ∞ -term

λb

λb

→λ

(λa) λb.(λc. . . .) a

@

@

→λ

(λab) (λc.(. . .) b) a

λc

a

U

a

@

@ λd

b

b

@

@ .. .

()λa.λb.(. . . ) a

λa

λc λd

=

λa

c

.. .

λ∞ -term U

c

→reg+ -generated subterms

Not strongly regular λ∞ -term

λb

λb

→λ

(λa) λb.(λc. . . .) a

@

@

→λ

(λab) (λc.(. . .) b) a

→@ 0

(λab) λc.(λd. . . .) b

λc

a

U

a

@

@ λd

b

b

@

@ .. .

()λa.λb.(. . . ) a

λa

λc λd

=

λa

c

.. .

λ∞ -term U

c

→reg+ -generated subterms

Not strongly regular λ∞ -term

λb

λb

→λ

(λa) λb.(λc. . . .) a

@

@

→λ

(λab) (λc.(. . .) b) a

→@ 0

(λab) λc.(λd. . . .) b

→λ

(λabc) (λd.(. . .) c) b

λc

a

U

a

@

@ λd

b

b

@

@ .. .

()λa.λb.(. . . ) a

λa

λc λd

=

λa

c

.. .

λ∞ -term U

c

→reg+ -generated subterms

Not strongly regular λ∞ -term

λb

λb

→λ

(λa) λb.(λc. . . .) a

@

@

→λ

(λab) (λc.(. . .) b) a

→@ 0

(λab) λc.(λd. . . .) b

→λ

(λabc) (λd.(. . .) c) b

→@ 0

(λabc) λd.(λe. . . .) c

λc

a

λd

b

U

a

@

@

b

@

@ .. .

()λa.λb.(. . . ) a

λa

λc λd

=

λa

c

.. .

λ∞ -term U

c

→reg+ -generated subterms

Not strongly regular λ∞ -term

λb

λb

→λ

(λa) λb.(λc. . . .) a

@

@

→λ

(λab) (λc.(. . .) b) a

→@ 0

(λab) λc.(λd. . . .) b

→λ

(λabc) (λd.(. . .) c) b

→@ 0

(λabc) λd.(λe. . . .) c

→λ

(λabcd) (λe.(. . .) d) c

λc

a

λd

b

U

a

@

@

b

@

@ .. .

()λa.λb.(. . . ) a

λa

λc λd

=

λa

c

.. .

λ∞ -term U

c

→reg+ -generated subterms

Not strongly regular λ∞ -term

λb

λb

→λ

(λa) λb.(λc. . . .) a

@

@

→λ

(λab) (λc.(. . .) b) a

→@ 0

(λab) λc.(λd. . . .) b

→λ

(λabc) (λd.(. . .) c) b

→@ 0

(λabc) λd.(λe. . . .) c

→λ

(λabcd) (λe.(. . .) d) c

→@ 0

(λabcd) λe.(λf . . . .) d

λc

a

λd

b

b

@

@ c

.. .

λ∞ -term U

c

U

a

@

@

.. .

()λa.λb.(. . . ) a

λa

λc λd

=

λa

...

infinitely many →reg+ -generated subterms Ô⇒ U is not strongly regular

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

b

()λa.λb.(. . . ) a

a

b

@

@ .. .

=

@

@ λd

U

c

λ∞ -term U

.. .

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

b

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a

a

b

@

@ .. .

= →λ

@

@ λd

U

c

λ∞ -term U

.. .

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

b

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a

a

b

@

@ .. .

= →λ →λ

@

@ λd

U

c

λ∞ -term U

.. .

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

b

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b

b

@

@ .. .

a

= →λ →λ →@ 0

@

@ λd

U

c

λ∞ -term U

.. .

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

b

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b (λb) λc.(λd. . . .) b

b

@

@ .. .

a

= →λ →λ →@ 0 →del

@

@ λd

U

c

λ∞ -term U

.. .

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

λd

b

= →λ →λ →@ 0 →del →λ

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b (λb) λc.(λd. . . .) b (λbc) (λd.(. . .) c) b

b

@

@ .. .

a

@

@

U

c

λ∞ -term U

.. .

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

λd

b

b

= →λ →λ →@ 0 →del →λ →@ 0

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b (λb) λc.(λd. . . .) b (λbc) (λd.(. . .) c) b (λbc) λd.(λd. . . .) c

@

@ .. .

a

@

@

U

c

λ∞ -term U

.. .

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

λd

b

b

@

@ .. .

a

@

@

c

λ∞ -term U

.. .

U

= →λ →λ →@ 0 →del →λ →@ 0 →del

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b (λb) λc.(λd. . . .) b (λbc) (λd.(. . .) c) b (λbc) λd.(λd. . . .) c (λc) λd.(λe. . . .) d

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

λd

b

b

@

@ .. .

a

@

@

c

λ∞ -term U

.. .

U

= →λ →λ →@ 0 →del →λ →@ 0 →del →λ

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b (λb) λc.(λd. . . .) b (λbc) (λd.(. . .) c) b (λbc) λd.(λd. . . .) c (λc) λd.(λe. . . .) d (λcd) (λe.(. . .) d) c

c

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

λd

b

b

@

@ .. .

a

@

@

c

λ∞ -term U

.. .

c

U

= →λ →λ →@ 0 →del →λ →@ 0 →del →λ →@ 0

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b (λb) λc.(λd. . . .) b (λbc) (λd.(. . .) c) b (λbc) λd.(λd. . . .) c (λc) λd.(λe. . . .) d (λcd) (λe.(. . .) d) c (λcd) λe.(λf . . . .) d

→reg -generated subterms

Regular λ∞ -term λa

λa

λb

λb

@

@

λc

λc

a

λd

λd

b

b

@

@ .. .

a

@

@

c

λ∞ -term U

.. .

c

U

= →λ →λ →@ 0 →del →λ →@ 0 →del →λ →@ 0 →del ...

()λa.λb.(. . . ) a (λa) λb.(λc. . . .) a (λab) (λc.(. . .) b) a (λab) λc.(λd. . . .) b (λb) λc.(λd. . . .) b (λbc) (λd.(. . .) c) b (λbc) λd.(λd. . . .) c (λc) λd.(λe. . . .) d (λcd) (λe.(. . .) d) c (λcd) λe.(λf . . . .) d (λd) λe.(λf . . . .) d

→reg -generated subterms

Regular λ∞ -term λx

λx

λy

λy

@

@

λx

λx

x

λy

λy

y

.. .

x

.. .

x

λ (λxy) R(y) x @0

y

@

@

λ (λx) R(x) x

@

@

()U

@1

(λxy) R(y)

(λxy) x

del (λy) R(y)

del (λx) x

λ∞ -term U

finitely many →reg -generated subterms

{U = λxy .R(y ) x, R(z) = λu.R(u) z}

Ô⇒ T is regular

Strongly regular ⇒ regular

Proposition ▸

Every strongly regular λ∞ -term is also regular.



Finite λ-terms are both regular and strongly regular.

Proving strong regularity T = λxy .T x y ()T λ (λx) λy T y x λ (λxy) T y x

S

@0 (λxy) T y

@1 (λxy) x

@0 @1 (λxy) T

S (λxy) y (λx) x

S (λx) T

→reg+ -reduction graph

Proving strong regularity T = λxy .T x y (λx) T S (λxy) T @0

(λxy) y (λx) x S @1 (λxy) x

(λxy) T y

@1

@0 S

(λxy) T y x λ (λx) λy T y x λ ()T

→reg+ -reduction graph

Proving strong regularity T = λxy .T x y (λx) T S

(()T )l S (λx) T 0 S (λxy ) T (λxy ) y @ (λxy ) T y (λxy ) T y x (λx) λy .T y x ()λxy .T y x ()T

(λxy) T

0 (λx) x S (λxy ) x @ λ λ FIX, l

@0

(λxy) y (λx) x S @1 (λxy) x

(λxy) T y

@1

@0 S

(λxy) T y x λ (λx) λy T y x λ ()T

proof in Reg+0

→reg+ -reduction graph

Proving strong regularity T = λxy .T x y (λx) T S

(()T )l S (λx) T 0 S (λxy ) T (λxy ) y @ (λxy ) T y (λxy ) T y x (λx) λy .T y x ()λxy .T y x ()T

(λxy) T

0 (λx) x S (λxy ) x @ λ λ FIX, l

@0

(λxy) y (λx) x S @1 (λxy) x

(λxy) T y

@1

@0 S

(λxy) T y x λ (λx) λy T y x λ ()T

proof in Reg+0

→reg+ -reduction graph

Proving strong regularity T = λxy .T x y (λx) T S

(()T )l S (λx)T 0 S (λxy )T (λxy ) y @ (λxy )T y (λxy )T y x (λx)λy .T y x ()λxy .T y x ()T

(λxy) T

0 (λx) x S (λxy ) x @ λ λ FIX, l

@0

(λxy) y (λx) x S @1 (λxy) x

(λxy) T y

@1

@0 S

(λxy) T y x λ (λx) λy T y x λ ()T

proof in Reg+0

→reg+ -reduction graph

λµ -expressibility µ-unfolding rule µf .M(f ) → M(µf .M(f ))

mu([x] Z (x)) → Z (mu([x] Z (x)))

is orthogonal CRS with confluent rewrite relation →µ . µf .λx.λy .f y x →µ λx.λy .(µf .λx.λy .f y x) y x ...

λµ -expressibility µ-unfolding rule µf .M(f ) → M(µf .M(f ))

mu([x] Z (x)) → Z (mu([x] Z (x)))

is orthogonal CRS with confluent rewrite relation →µ . µf .λx.λy .f y x →µ λx.λy .(µf .λx.λy .f y x) y x →µ . . . ↠µ λxy .(λxy .(λxy .(. . .) y x) y x) y x ... ↠ µg .g →µ µg .g →µ . . .

λµ -expressibility µ-unfolding rule µf .M(f ) → M(µf .M(f ))

mu([x] Z (x)) → Z (mu([x] Z (x)))

is orthogonal CRS with confluent rewrite relation →µ . µf .λx.λy .f y x →µ λx.λy .(µf .λx.λy .f y x) y x →µ . . . ↠µ λxy .(λxy .(λxy .(. . .) y x) y x) y x ... ↠ µg .g →µ µg .g →µ . . .

Definition Let M a λµ -term, T a λ∞ -term. M expresses T ⇐⇒ M ↠ ↠µ T

λµ -expressibility µ-unfolding rule µf .M(f ) → M(µf .M(f ))

mu([x] Z (x)) → Z (mu([x] Z (x)))

is orthogonal CRS with confluent rewrite relation →µ . µf .λx.λy .f y x →µ λx.λy .(µf .λx.λy .f y x) y x →µ . . . ↠µ λxy .(λxy .(λxy .(. . .) y x) y x) y x ... ↠ µg .g →µ µg .g →µ . . .

Definition Let M a λµ -term, T a λ∞ -term. M expresses T ⇐⇒ M ↠ ↠µ T

Proposition 1

the λ∞ -term T expressed by a λµ -term M is unique if it exists

2

outermost strategy for →µ is inf. normalizing [Ketema, Simonsen]

λµ -expressibility Theorem (λµ -expressibility) An λ∞ -term is λµ -expressible if and only if it is strongly regular.

λµ -expressibility Theorem (λµ -expressibility) An λ∞ -term is λµ -expressible if and only if it is strongly regular.

Proof. By a sequence of, mainly, proof-theoretic transformations. “⇐” (‘λµ -term-extraction’ direction) For a strongly regular λ∞ -term T obtain: 1 2 3 4

λµ -term extraction: step 1 λx λy @ @ λx

x y

λy @ @ .. .

x y

strongly regular λ-term

λµ -term extraction: step 1 λx λy @ @ λx

x y

λy @ @ .. .

x y

strongly regular λ-term with scope+ s

λµ -term extraction: step 1 ()T λ (λx) λy T y x λ (λxy) T y x

S

@0 (λxy) T y

@1 (λxy) x

@0 @1 (λxy) T

S (λxy) y (λx) x

S (λx) T

→reg+ -reduction graph

λµ -term extraction: step 1 ()T λ (λx) λy T y x λ (λxy) T y x

S

@0 (λxy) T y

@1 (λxy) x

@0 @1 (λxy) T

S (λxy) y (λx) x

S (λx) T

→reg+ -reduction graph (only vertical sharing: expressible by a µ-term [Blom, 2001])

λµ -term extraction: step 2 (λx) T S (λxy) T @0

(λxy) y (λx) x S @1 (λxy) x

(λxy) T y

@1

@0 S

(λxy) T y x λ (λx) λy T y x λ ()T

→reg+ -reduction graph (only vertical sharing: expressible by a µ-term [Blom, 2001])

λµ -term extraction: step 2

(()T )l S (λx) T 0 S (λxy ) T (λxy ) y @ (λxy ) T y (λxy ) T y x (λx) λy .T y x ()λxy .T y x ()T

0 (λx) x S (λxy ) x @ λ λ FIX,l

closed derivation in Reg+0

λµ -term extraction: step 3

(() cl ∶ T )l S (λx) cl ∶ T 0 0 S (λxy ) cl ∶ T (λxy ) y ∶ y (λx) x ∶ x @ S (λxy ) cl y ∶ T y (λxy ) x ∶ x @ (λxy ) cl y x ∶ T y x λ (λx) λy .cl y x ∶ T y x λ () λxy .cl y x ∶ λxy .T y x FIX, l () µf .λxy .f y x ∶ T λµ -term-annotated derivation in Expr

λµ -term extraction: step 3

(() cl ∶ T )l S (λx) cl ∶ T 0 0 S (λxy ) cl ∶ T (λxy ) y ∶ y (λx) x ∶ x @ S (λxy ) cl y ∶ T y (λxy ) x ∶ x @ (λxy ) cl y x ∶ T y x λ (λx) λy .cl y x ∶ T y x λ () λxy .cl y x ∶ λxy .T y x FIX, l () µf .λxy .f y x ∶ T λµ -term-annotated derivation in Expr

f

y @

x @ λy λx µf

λµ -term extraction: step 3

(() cl ∶ T )l S (λx) cl ∶ T 0 0 S (λxy ) cl ∶ T (λxy ) y ∶ y (λx) x ∶ x @ S (λxy ) cl y ∶ T y (λxy ) x ∶ x @ (λxy ) cl y x ∶ T y x λ (λx) λy .cl y x ∶ T y x λ () λxy .cl y x ∶ λxy .T y x FIX, l () µf .λxy .f y x ∶ T λµ -term-annotated derivation in Expr

µf λx λy @ @ f

x y

λµ -term extraction: step 4

µf λx λy @ @ f

x y

λµ -term

λµ -term extraction: step 4

λx λy µf

@

λx

@

λy

↠ ↠µ

λx

@ @ f

y

λy x @ .. .

↞ ↞▽

@ x y

x y

λy

@

@

y

λx x

λµ -expressibility Theorem (λµ -expressibility) An λ∞ -term is λµ -expressible if and only if it is strongly regular.

Proof. “⇐” (‘λµ -term-extraction’ direction) For a strongly regular λ∞ -term T obtain: 1

finite →reg+ -reduction graph G of T

2

derivation D of ()T in Reg+0 (only vertical sharing ⇒ expressible by µ-term [Blom, 2001])

3

the expressing λµ -term M from D by annotation

4

then M ↠ ↠µ T can be shown

Binding–capturing chains λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

.. .

x y

x y

Definition (Melli´es, van Oostrom) For positions p, q, r , s: p ⟜ q ∶ ⇐⇒ binder at p binds variable occurrence at position q r ⇢ s ∶ ⇐⇒ variable occurrence at r is captured by binding at s Binding–capturing chains: p0 ⟜ p1 ⇢ p2 ⟜ p3 ⇢ p4 ⟜ . . .

Binding–capturing chains λx

λx

λy

λy

@

@

@ λx

λx

y

λy

λy

@

@

@ .. .

@

x

@

x y

.. .

x

λx

λx

λy

λy

@

@

λx

λx

x

y

@

@ λy

y

λy

y

.. .

y

@

@

x

x

x

.. .

x

Definition (Melli´es, van Oostrom) For positions p, q, r , s: p ⟜ q ∶ ⇐⇒ binder at p binds variable occurrence at position q r ⇢ s ∶ ⇐⇒ variable occurrence at r is captured by binding at s Binding–capturing chains: p0 ⟜ p1 ⇢ p2 ⟜ p3 ⇢ p4 ⟜ . . .

Main theorem (extended)

Theorem (binding–capturing chains) For all regular λ∞ -term T : T is strongly regular ⇐⇒ T has only finite binding–capturing chains.

Theorem (λµ -expressibility, extended) For all λ∞ -terms T the following are equivalent: (i) T is λµ -expressible. (ii) T is strongly regular. (iii) T is regular, and it only contains finite binding–capturing chains.

Generalization and perspectives ▸

generalization to λletrec ▸

arxiv report Expressibility in the Lambda-Calculus with Letrec ▸ ▸



IWC 2013 talks Friday: ▸ ▸



Confluent unfolding in λletrec Confluent Let-floating

practical relevance ▸ ▸ ▸



same structure of proof more technicalities: unfolding letrec-expressions

recognize limits of optimization transformations test efficiently for unfolding equivalence implement maximal sharing for λletrec -terms

expressing regular λ∞ -terms ▸ ▸

by higher-order rewrite rules Chomsky hierarchy of finitely expressible λ∞ -terms?