Garbage Collection for a calculus with indices Luis Francisco - - PowerPoint PPT Presentation

garbage collection for a calculus with indices
SMART_READER_LITE
LIVE PREVIEW

Garbage Collection for a calculus with indices Luis Francisco - - PowerPoint PPT Presentation

Motivation Different approachs for implementing -calculus Adding garbage collection to Summary Garbage Collection for a calculus with indices Luis Francisco Ziliani Departamento de Computacin Facultad de Ciencias Exactas y Naturales


slide-1
SLIDE 1

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Garbage Collection for a calculus with indices

Luis Francisco Ziliani

Departamento de Computación Facultad de Ciencias Exactas y Naturales Universidad de Buenos Aires

Licenciatura’s Thesis, 2009

L.F. Ziliani Garbage Collection for a calculus with indices

slide-2
SLIDE 2

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Outline

1

Motivation

2

Different approachs for implementing λ-calculus A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

3

Adding garbage collection to λσ

L.F. Ziliani Garbage Collection for a calculus with indices

slide-3
SLIDE 3

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Why study λ-calculus related theories

Invented by A. Church in the ’30. Why study it? λ-calculus is the base of functional programming and theorem provers. Simple and yet powerful. But its naïve implementation is not useful in all cases, and there might be no obvious extension for what is needed. For the Automath theorem prover, de Bruijn created a way to unique identify variables by the use of indices. Also, the need for performance lead to explicit substitutions.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-4
SLIDE 4

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Why study λ-calculus related theories

Invented by A. Church in the ’30. Why study it? λ-calculus is the base of functional programming and theorem provers. Simple and yet powerful. But its naïve implementation is not useful in all cases, and there might be no obvious extension for what is needed. For the Automath theorem prover, de Bruijn created a way to unique identify variables by the use of indices. Also, the need for performance lead to explicit substitutions.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-5
SLIDE 5

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Why study λ-calculus related theories

Invented by A. Church in the ’30. Why study it? λ-calculus is the base of functional programming and theorem provers. Simple and yet powerful. But its naïve implementation is not useful in all cases, and there might be no obvious extension for what is needed. For the Automath theorem prover, de Bruijn created a way to unique identify variables by the use of indices. Also, the need for performance lead to explicit substitutions.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-6
SLIDE 6

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Why study λ-calculus related theories

Invented by A. Church in the ’30. Why study it? λ-calculus is the base of functional programming and theorem provers. Simple and yet powerful. But its naïve implementation is not useful in all cases, and there might be no obvious extension for what is needed. For the Automath theorem prover, de Bruijn created a way to unique identify variables by the use of indices. Also, the need for performance lead to explicit substitutions.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-7
SLIDE 7

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Why study λ-calculus related theories

Invented by A. Church in the ’30. Why study it? λ-calculus is the base of functional programming and theorem provers. Simple and yet powerful. But its naïve implementation is not useful in all cases, and there might be no obvious extension for what is needed. For the Automath theorem prover, de Bruijn created a way to unique identify variables by the use of indices. Also, the need for performance lead to explicit substitutions.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-8
SLIDE 8

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Part of the λ-calculus hierarchy

What we are going to see

λ-calculus λDB indices λx

  • exp. subst.

λes λσ

  • exp. subst.

λσgc

L.F. Ziliani Garbage Collection for a calculus with indices

slide-9
SLIDE 9

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Part of the λ-calculus hierarchy

What we are going to see

λ-calculus

L.F. Ziliani Garbage Collection for a calculus with indices

slide-10
SLIDE 10

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

The terms of F are constructed by

Naturals (0, 1, . . .) with built-in operations +, ×, . . . , >, <, =, . . . Booleans (true, false) with built-in operations if · then · else ·, ∧, ∨, . . . Variables x, y, . . . Functions (for instance, f(x) = x + 1). In this case x is the abstracted variable of f and x + 1 is the body. Application of terms to terms (for instance, f 3). Here, 3 is the argument of f. Application is left-associative: f 2 1 is (f 2) 1.

One computation step (→) is defined to an application f T as the act to replace each occurrence of the abstracted variable in the body with the argument. For example, f 3 → 3 + 1 = 4

L.F. Ziliani Garbage Collection for a calculus with indices

slide-11
SLIDE 11

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

The terms of F are constructed by

Naturals (0, 1, . . .) with built-in operations +, ×, . . . , >, <, =, . . . Booleans (true, false) with built-in operations if · then · else ·, ∧, ∨, . . . Variables x, y, . . . Functions (for instance, f(x) = x + 1). In this case x is the abstracted variable of f and x + 1 is the body. Application of terms to terms (for instance, f 3). Here, 3 is the argument of f. Application is left-associative: f 2 1 is (f 2) 1.

One computation step (→) is defined to an application f T as the act to replace each occurrence of the abstracted variable in the body with the argument. For example, f 3 → 3 + 1 = 4

L.F. Ziliani Garbage Collection for a calculus with indices

slide-12
SLIDE 12

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

The terms of F are constructed by

Naturals (0, 1, . . .) with built-in operations +, ×, . . . , >, <, =, . . . Booleans (true, false) with built-in operations if · then · else ·, ∧, ∨, . . . Variables x, y, . . . Functions (for instance, f(x) = x + 1). In this case x is the abstracted variable of f and x + 1 is the body. Application of terms to terms (for instance, f 3). Here, 3 is the argument of f. Application is left-associative: f 2 1 is (f 2) 1.

One computation step (→) is defined to an application f T as the act to replace each occurrence of the abstracted variable in the body with the argument. For example, f 3 → 3 + 1 = 4

L.F. Ziliani Garbage Collection for a calculus with indices

slide-13
SLIDE 13

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

The terms of F are constructed by

Naturals (0, 1, . . .) with built-in operations +, ×, . . . , >, <, =, . . . Booleans (true, false) with built-in operations if · then · else ·, ∧, ∨, . . . Variables x, y, . . . Functions (for instance, f(x) = x + 1). In this case x is the abstracted variable of f and x + 1 is the body. Application of terms to terms (for instance, f 3). Here, 3 is the argument of f. Application is left-associative: f 2 1 is (f 2) 1.

One computation step (→) is defined to an application f T as the act to replace each occurrence of the abstracted variable in the body with the argument. For example, f 3 → 3 + 1 = 4

L.F. Ziliani Garbage Collection for a calculus with indices

slide-14
SLIDE 14

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

The terms of F are constructed by

Naturals (0, 1, . . .) with built-in operations +, ×, . . . , >, <, =, . . . Booleans (true, false) with built-in operations if · then · else ·, ∧, ∨, . . . Variables x, y, . . . Functions (for instance, f(x) = x + 1). In this case x is the abstracted variable of f and x + 1 is the body. Application of terms to terms (for instance, f 3). Here, 3 is the argument of f. Application is left-associative: f 2 1 is (f 2) 1.

One computation step (→) is defined to an application f T as the act to replace each occurrence of the abstracted variable in the body with the argument. For example, f 3 → 3 + 1 = 4

L.F. Ziliani Garbage Collection for a calculus with indices

slide-15
SLIDE 15

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

The terms of F are constructed by

Naturals (0, 1, . . .) with built-in operations +, ×, . . . , >, <, =, . . . Booleans (true, false) with built-in operations if · then · else ·, ∧, ∨, . . . Variables x, y, . . . Functions (for instance, f(x) = x + 1). In this case x is the abstracted variable of f and x + 1 is the body. Application of terms to terms (for instance, f 3). Here, 3 is the argument of f. Application is left-associative: f 2 1 is (f 2) 1.

One computation step (→) is defined to an application f T as the act to replace each occurrence of the abstracted variable in the body with the argument. For example, f 3 → 3 + 1 = 4

L.F. Ziliani Garbage Collection for a calculus with indices

slide-16
SLIDE 16

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

The terms of F are constructed by

Naturals (0, 1, . . .) with built-in operations +, ×, . . . , >, <, =, . . . Booleans (true, false) with built-in operations if · then · else ·, ∧, ∨, . . . Variables x, y, . . . Functions (for instance, f(x) = x + 1). In this case x is the abstracted variable of f and x + 1 is the body. Application of terms to terms (for instance, f 3). Here, 3 is the argument of f. Application is left-associative: f 2 1 is (f 2) 1.

One computation step (→) is defined to an application f T as the act to replace each occurrence of the abstracted variable in the body with the argument. For example, f 3 → 3 + 1 = 4

L.F. Ziliani Garbage Collection for a calculus with indices

slide-17
SLIDE 17

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-18
SLIDE 18

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-19
SLIDE 19

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-20
SLIDE 20

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-21
SLIDE 21

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-22
SLIDE 22

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-23
SLIDE 23

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-24
SLIDE 24

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-25
SLIDE 25

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-26
SLIDE 26

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-27
SLIDE 27

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-28
SLIDE 28

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-29
SLIDE 29

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-30
SLIDE 30

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-31
SLIDE 31

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

The F programming language

Examples

fc(x) = if (x > 1) then x × fc (x − 1) else 1 fc 3 → if (3 > 1) then 3 × fc (3 − 1) else 1 = 3 × fc 2 → . . . → 3 × 2 × 1 = 6 f(x) = x + 1 g(x) = x × 2 h(y) = y 4

  • (x)

= x x h f → f 4 → 4 + 1 = 5 h g → g 4 → 4 × 2 = 8 h h → h 4 → 4 4 = ???

  • o

  • o → o o → . . .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-32
SLIDE 32

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

From F to λ-calculus

Pure λ-calculus is similar to F, but It does not have constants (i.e. naturals and booleans). How do we do arithmetic? Functions are represented as “inline” anonymous functions.

In F the definition and the application of a function are different things: Definition: f(x) = T. Application: f U. In λ-calculus both concepts are joined. f U is written as (λx.T) U. f (f U) is written as (λx.T) ((λx.T) U). How can we do a recursive call?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-33
SLIDE 33

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

From F to λ-calculus

Pure λ-calculus is similar to F, but It does not have constants (i.e. naturals and booleans). How do we do arithmetic? Functions are represented as “inline” anonymous functions.

In F the definition and the application of a function are different things: Definition: f(x) = T. Application: f U. In λ-calculus both concepts are joined. f U is written as (λx.T) U. f (f U) is written as (λx.T) ((λx.T) U). How can we do a recursive call?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-34
SLIDE 34

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

From F to λ-calculus

Pure λ-calculus is similar to F, but It does not have constants (i.e. naturals and booleans). How do we do arithmetic? Functions are represented as “inline” anonymous functions.

In F the definition and the application of a function are different things: Definition: f(x) = T. Application: f U. In λ-calculus both concepts are joined. f U is written as (λx.T) U. f (f U) is written as (λx.T) ((λx.T) U). How can we do a recursive call?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-35
SLIDE 35

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

From F to λ-calculus

Pure λ-calculus is similar to F, but It does not have constants (i.e. naturals and booleans). How do we do arithmetic? Functions are represented as “inline” anonymous functions.

In F the definition and the application of a function are different things: Definition: f(x) = T. Application: f U. In λ-calculus both concepts are joined. f U is written as (λx.T) U. f (f U) is written as (λx.T) ((λx.T) U). How can we do a recursive call?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-36
SLIDE 36

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

From F to λ-calculus

Pure λ-calculus is similar to F, but It does not have constants (i.e. naturals and booleans). How do we do arithmetic? Functions are represented as “inline” anonymous functions.

In F the definition and the application of a function are different things: Definition: f(x) = T. Application: f U. In λ-calculus both concepts are joined. f U is written as (λx.T) U. f (f U) is written as (λx.T) ((λx.T) U). How can we do a recursive call?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-37
SLIDE 37

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Formalization

The computation step, called β-reduction, is defined as (λx.T) U →β T[ [x/U] ] And the substitution is defined as x[ [x/T] ] = T y[ [x/T] ] = y (x = y) (T1 T2)[ [x/U] ] = T1[ [x/U] ] T2[ [x/U] ] (λy.T)[ [x/U] ] = λy.(T[ [x/U] ]) We will use the convention that every abstracted variable is different.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-38
SLIDE 38

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

An introduction on λ-calculus .

Example.

(λx.(λy.x)) T →β (λy.x)[ [x/T] ] = (λy.T) Variables can be bound to a λ, like x in (λx.x y).

  • r free, like y in the same example.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-39
SLIDE 39

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

An introduction on λ-calculus .

Example.

(λx.(λy.x)) T →β (λy.x)[ [x/T] ] = (λy.T) Variables can be bound to a λ, like x in (λx.x y).

  • r free, like y in the same example.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-40
SLIDE 40

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

An introduction on λ-calculus .

Example.

(λx.(λy.x)) T →β (λy.x)[ [x/T] ] = (λy.T) Variables can be bound to a λ, like x in (λx.x y).

  • r free, like y in the same example.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-41
SLIDE 41

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

An introduction on λ-calculus .

Example.

(λx.(λy.x)) T →β (λy.x)[ [x/T] ] = (λy.T) Variables can be bound to a λ, like x in (λx.x y).

  • r free, like y in the same example.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-42
SLIDE 42

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

α-congruence

Are these two terms different? (λx.x) (λy.y) Syntactically, yes, but they behave the same way. We will not make that distinction, by use of the α-congruence: Two terms are α-congruent if they only differ in the bounded variables.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-43
SLIDE 43

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Part of the λ-calculus hierarchy

What we are going to see

λ-calculus λx

  • exp. subst.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-44
SLIDE 44

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Explicit substitutions

In traditional λ-calculus the substitution is made all at once. (λx.(λy.x) x)T →β ((λy.x) x)[ [x/T] ] = ((λy.T) T) This can lead to a size explosion when having multiple copies of a variable. In practice, we need more control over what’s going on during the substitution. (λx.(λy.x) x)T →β ((λy.x) x)[ [x/T] ] →β (x[ [y/x] ])[ [x/T] ] → x[ [x/T] ] → T

L.F. Ziliani Garbage Collection for a calculus with indices

slide-45
SLIDE 45

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Explicit substitutions

In traditional λ-calculus the substitution is made all at once. (λx.(λy.x) x)T →β ((λy.x) x)[ [x/T] ] = ((λy.T) T) This can lead to a size explosion when having multiple copies of a variable. In practice, we need more control over what’s going on during the substitution. (λx.(λy.x) x)T →β ((λy.x) x)[ [x/T] ] →β (x[ [y/x] ])[ [x/T] ] → x[ [x/T] ] → T

L.F. Ziliani Garbage Collection for a calculus with indices

slide-46
SLIDE 46

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Explicit substitutions

In traditional λ-calculus the substitution is made all at once. (λx.(λy.x) x)T →β ((λy.x) x)[ [x/T] ] = ((λy.T) T) This can lead to a size explosion when having multiple copies of a variable. In practice, we need more control over what’s going on during the substitution. (λx.(λy.x) x)T →β ((λy.x) x)[ [x/T] ] →β (x[ [y/x] ])[ [x/T] ] → x[ [x/T] ] → T

L.F. Ziliani Garbage Collection for a calculus with indices

slide-47
SLIDE 47

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Presenting λx

Presented by K. Rose in 1993, λx is the shortest, simpler calculus with explicit substitutions: (B) (λx.T) U − → T[x/U] x[x/U] − → U y[x/U] − → y (x = y) (T U)[x/V] − → T[x/V] U[x/V] (λy.T)[x/V] − → λy.T[x/V] Note: The substitution is now part of the terms. We can construct the term x[y/w] and start the computation from there.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-48
SLIDE 48

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Presenting λx

Presented by K. Rose in 1993, λx is the shortest, simpler calculus with explicit substitutions: (B) (λx.T) U − → T[x/U] x[x/U] − → U y[x/U] − → y (x = y) (T U)[x/V] − → T[x/V] U[x/V] (λy.T)[x/V] − → λy.T[x/V] Note: The substitution is now part of the terms. We can construct the term x[y/w] and start the computation from there.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-49
SLIDE 49

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Properties of λx

λx is confluent: T U V W A term is strongly normalizing if there is no infinite computation from it. λx preserves strong normalization: All the terms that are strongly normalizing in λ-calculus are also strongly normalizing in λx. λx is not metaconfluent: If we add metavariables (X, Y, . . .) to the calculus, then confluence is lost.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-50
SLIDE 50

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Properties of λx

λx is confluent: T U V W A term is strongly normalizing if there is no infinite computation from it. λx preserves strong normalization: All the terms that are strongly normalizing in λ-calculus are also strongly normalizing in λx. λx is not metaconfluent: If we add metavariables (X, Y, . . .) to the calculus, then confluence is lost.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-51
SLIDE 51

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Properties of λx

λx is confluent: T U V W A term is strongly normalizing if there is no infinite computation from it. λx preserves strong normalization: All the terms that are strongly normalizing in λ-calculus are also strongly normalizing in λx. λx is not metaconfluent: If we add metavariables (X, Y, . . .) to the calculus, then confluence is lost.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-52
SLIDE 52

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Part of the λ-calculus hierarchy

What we are going to see

λ-calculus λx

  • exp. subst.

λes

L.F. Ziliani Garbage Collection for a calculus with indices

slide-53
SLIDE 53

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

λes essentials

The calculus λes was created in 2007 by Delia Kesner. It gets preservation of strong normalization and metaconfluence by mixing two ideas: Composition of substitutions: When having two substitutions together, put the second in the first one: T[x/U][y/V] → T[y/V][x/U[y/V]] Needed to get metaconfluence. If no restriction is specified, the preservation of strong normalization is lost.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-54
SLIDE 54

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

λes essentials

The calculus λes was created in 2007 by Delia Kesner. It gets preservation of strong normalization and metaconfluence by mixing two ideas: Composition of substitutions: When having two substitutions together, put the second in the first one: T[x/U][y/V] → T[y/V][x/U[y/V]] Needed to get metaconfluence. If no restriction is specified, the preservation of strong normalization is lost.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-55
SLIDE 55

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

λes essentials

Garbage collection: A substitution [x/U] is garbage for the term T if x is not free in T. The idea is that T will remain unchanged after performing the substitution, i. e. T[x/U] → . . . → T Needed to control the composition, avoiding composition of garbage.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-56
SLIDE 56

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Part of the λ-calculus hierarchy

What we are going to see

λ-calculus λDB indices λx

  • exp. subst.

λes

L.F. Ziliani Garbage Collection for a calculus with indices

slide-57
SLIDE 57

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Presenting λDB

Created by N. G. de Bruijn in 1972 for his Automath theorem prover. Motivation: knowing whether two terms are “the same” without making variable replacements. Remember the notion of α-congruence: (λx.(λy.x y)) ≡α (λw.(λz.w z)) Idea: for each variable, count how many λ’s there are in between, and replace the variable by this number. (λx.(λy.x y v)) is translated to (λ(λ2 1 3)) (λw.(λz.w z v)) is translated to (λ(λ2 1 3))

L.F. Ziliani Garbage Collection for a calculus with indices

slide-58
SLIDE 58

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Presenting λDB

Created by N. G. de Bruijn in 1972 for his Automath theorem prover. Motivation: knowing whether two terms are “the same” without making variable replacements. Remember the notion of α-congruence: (λx.(λy.x y)) ≡α (λw.(λz.w z)) Idea: for each variable, count how many λ’s there are in between, and replace the variable by this number. (λx.(λy.x y v)) is translated to (λ(λ2 1 3)) (λw.(λz.w z v)) is translated to (λ(λ2 1 3))

L.F. Ziliani Garbage Collection for a calculus with indices

slide-59
SLIDE 59

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Presenting λDB

Advantages: All the terms of the same class are encoded to the same λDB-term. Disadvantages: Indices need to be updated: Each time we perform a β-reduction. Each time we perform a substitution under a λ.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-60
SLIDE 60

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

A word about λs

λ-calculus λDB indices λs

  • exp. subst.

In 1995, F . Kamareddine and A. Ríos proposed a version of λDB with explicit substitutions, λs. As λx, is a direct translation of the rules into exp. sust. Holds the same properties as λx. Because of the indices updating mechanism, it is hard to extend it with composition of substitutions.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-61
SLIDE 61

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Part of the λ-calculus hierarchy

What we are going to see

λ-calculus λDB indices λx

  • exp. subst.

λes λσ

  • exp. subst.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-62
SLIDE 62

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Indices and composition of substitutions: λσ

λσ was introduced by Abadi, Cardelli, Curien, and Levy in 1991. The main features are: Multiple substitutions: Substitutions are a list (1/a1, 2/a2, . . . , n/an) Born with composition of substitutions in mind. Indices updating is made in an atomic way. But: It does not preserve strong normalization. It is not metaconfluent (but there are extensions that are, or are semi-metaconfluent).

L.F. Ziliani Garbage Collection for a calculus with indices

slide-63
SLIDE 63

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Indices and composition of substitutions: λσ

λσ was introduced by Abadi, Cardelli, Curien, and Levy in 1991. The main features are: Multiple substitutions: Substitutions are a list (1/a1, 2/a2, . . . , n/an) Born with composition of substitutions in mind. Indices updating is made in an atomic way. But: It does not preserve strong normalization. It is not metaconfluent (but there are extensions that are, or are semi-metaconfluent).

L.F. Ziliani Garbage Collection for a calculus with indices

slide-64
SLIDE 64

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Indices and composition of substitutions: λσ

λσ was introduced by Abadi, Cardelli, Curien, and Levy in 1991. The main features are: Multiple substitutions: Substitutions are a list (1/a1, 2/a2, . . . , n/an) Born with composition of substitutions in mind. Indices updating is made in an atomic way. But: It does not preserve strong normalization. It is not metaconfluent (but there are extensions that are, or are semi-metaconfluent).

L.F. Ziliani Garbage Collection for a calculus with indices

slide-65
SLIDE 65

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Indices and composition of substitutions: λσ

λσ was introduced by Abadi, Cardelli, Curien, and Levy in 1991. The main features are: Multiple substitutions: Substitutions are a list (1/a1, 2/a2, . . . , n/an) Born with composition of substitutions in mind. Indices updating is made in an atomic way. But: It does not preserve strong normalization. It is not metaconfluent (but there are extensions that are, or are semi-metaconfluent).

L.F. Ziliani Garbage Collection for a calculus with indices

slide-66
SLIDE 66

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary A short introduction on λ-calculus . Making the substitution explicit Avoiding the α-congruence: indexing variables Indices and explicit substitution

Indices and composition of substitutions: λσ

λσ was introduced by Abadi, Cardelli, Curien, and Levy in 1991. The main features are: Multiple substitutions: Substitutions are a list (1/a1, 2/a2, . . . , n/an) Born with composition of substitutions in mind. Indices updating is made in an atomic way. But: It does not preserve strong normalization. It is not metaconfluent (but there are extensions that are, or are semi-metaconfluent).

L.F. Ziliani Garbage Collection for a calculus with indices

slide-67
SLIDE 67

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Part of the λ-calculus hierarchy

What we are going to see

λ-calculus λDB indices λx

  • exp. subst.

λes λσ

  • exp. subst.

λσgc

L.F. Ziliani Garbage Collection for a calculus with indices

slide-68
SLIDE 68

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

In the search for PSN: λσgc

Remember the definition of garbage in λes: “The substitution is garbage if the variable to substitute does not appear free in the term” This is difficult to specify in λσ for two reasons: Indices updating (applicable to all calculus with indices): The substitution is in charge of the substitution itself and the process of index updating, so it is not easy to remove. Multiple substitutions: All variables must be taken into account.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-69
SLIDE 69

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

In the search for PSN: λσgc

Remember the definition of garbage in λes: “The substitution is garbage if the variable to substitute does not appear free in the term” This is difficult to specify in λσ for two reasons: Indices updating (applicable to all calculus with indices): The substitution is in charge of the substitution itself and the process of index updating, so it is not easy to remove. Multiple substitutions: All variables must be taken into account.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-70
SLIDE 70

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

In the search for PSN: λσgc

Remember the definition of garbage in λes: “The substitution is garbage if the variable to substitute does not appear free in the term” This is difficult to specify in λσ for two reasons: Indices updating (applicable to all calculus with indices): The substitution is in charge of the substitution itself and the process of index updating, so it is not easy to remove. Multiple substitutions: All variables must be taken into account.

L.F. Ziliani Garbage Collection for a calculus with indices

slide-71
SLIDE 71

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

λσgc: Results and open problems

What we do and what we know: First definition of garbage for λσ. At least, the same good properties as λσ. A known term that is a counterexample for no preservation

  • f strong normalization in λσ is strongly normalizing in

λσgc. Is not metaconfluent. The definition of garbage is too restrictive. What we don’t know: Does it preserve strong normalization? Is there a trivial extension to obtain metaconfluence? Is there a better definition of garbage collection?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-72
SLIDE 72

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

λσgc: Results and open problems

What we do and what we know: First definition of garbage for λσ. At least, the same good properties as λσ. A known term that is a counterexample for no preservation

  • f strong normalization in λσ is strongly normalizing in

λσgc. Is not metaconfluent. The definition of garbage is too restrictive. What we don’t know: Does it preserve strong normalization? Is there a trivial extension to obtain metaconfluence? Is there a better definition of garbage collection?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-73
SLIDE 73

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

Summary

There are a lot of calculi related to λ-calculus . Some of them use indices, others explicit substitutions. Some of them use both concepts. It is not easy to get preservation of strong normalization and metaconfluence. Garbage collection is needed, but for λσ it is hard to add .

L.F. Ziliani Garbage Collection for a calculus with indices

slide-74
SLIDE 74

Motivation Different approachs for implementing λ-calculus Adding garbage collection to λσ Summary

The end

Questions?

L.F. Ziliani Garbage Collection for a calculus with indices

slide-75
SLIDE 75

Understunding λDB by example

(λ(λ1 2 3)) b →β (λ1 2 3)[ [1/b] ] λ @ @ 3 1 2 [ [1/b] ] (λa) b →β a[ [1/b] ]

L.F. Ziliani Garbage Collection for a calculus with indices

slide-76
SLIDE 76

Understunding λDB by example

(λ(λ1 2 3)) b →β (λ1 2 3)[ [1/b] ] λ @ @ 3 1 2 [ [1/b] ] (λa) b →β a[ [1/b] ]

L.F. Ziliani Garbage Collection for a calculus with indices

slide-77
SLIDE 77

Understunding λDB by example

(λ(λ1 2 3)) b →β (λ1 2 3)[ [1/b] ] λ @ @ 3 1 2 [ [1/b] ] (λa) b →β a[ [1/b] ]

L.F. Ziliani Garbage Collection for a calculus with indices

slide-78
SLIDE 78

Understunding λDB by example

(λ(λ1 2 3)) b →β λ(1 2 3)[ [2/b] ] λ @ @ 3 1 2 [ [2/b] ] (λa) b →β a[ [1/b] ] (λa)[ [i/b] ] = λa[ [i + 1/b] ]

L.F. Ziliani Garbage Collection for a calculus with indices

slide-79
SLIDE 79

Understunding λDB by example

(λ(λ1 2 3)) b →β λ((1 2)[ [2/b] ] 3[ [2/b] ]) λ @ @ 3 1 2 [ [2/b] ] [ [2/b] ] (λa) b →β a[ [1/b] ] (λa)[ [i/b] ] = λa[ [i + 1/b] ] (a1 a2)[ [i/b] ] = a1[ [i/b] ] a2[ [i/b] ]

L.F. Ziliani Garbage Collection for a calculus with indices

slide-80
SLIDE 80

Understunding λDB by example

(λ(λ1 2 3)) b →β λ((1 2)[ [2/b] ] 2) λ @ @ 2 1 2 [ [2/b] ] (λa) b →β a[ [1/b] ] (λa)[ [i/b] ] = λa[ [i + 1/b] ] (a1 a2)[ [i/b] ] = a1[ [i/b] ] a2[ [i/b] ] j[ [i/b] ] = j − i (j > i)

L.F. Ziliani Garbage Collection for a calculus with indices

slide-81
SLIDE 81

Understunding λDB by example

(λ(λ1 2 3)) b →β λ(1[ [2/b] ] 2[ [2/b] ] 2) λ @ @ 2 1 2 [ [2/b] ] [ [2/b] ] (λa) b →β a[ [1/b] ] (λa)[ [i/b] ] = λa[ [i + 1/b] ] (a1 a2)[ [i/b] ] = a1[ [i/b] ] a2[ [i/b] ] j[ [i/b] ] = j − i (j > i)

L.F. Ziliani Garbage Collection for a calculus with indices

slide-82
SLIDE 82

Understunding λDB by example

(λ(λ1 2 3)) b →β λ(1 2[ [2/b] ] 2) λ @ @ 2 1 2 [ [2/b] ] (λa) b →β a[ [1/b] ] (λa)[ [i/b] ] = λa[ [i + 1/b] ] (a1 a2)[ [i/b] ] = a1[ [i/b] ] a2[ [i/b] ] j[ [i/b] ] = j − i (j > i) j[ [i/b] ] = j (j < i)

L.F. Ziliani Garbage Collection for a calculus with indices

slide-83
SLIDE 83

Understunding λDB by example

(λ(λ1 2 3)) b →β λ(1 U2

0(b) 2)

λ @ @ 2 1 U2

0(b)

(λa) b →β a[ [1/b] ] (λa)[ [i/b] ] = λa[ [i + 1/b] ] (a1 a2)[ [i/b] ] = a1[ [i/b] ] a2[ [i/b] ] j[ [i/b] ] = j − i (j > i) j[ [i/b] ] = j (j < i) j[ [i/b] ] = Ui

0(b)

(j = i)

L.F. Ziliani Garbage Collection for a calculus with indices

slide-84
SLIDE 84

Understunding λDB

The update operator

The idea of the update operator Ui

k(b) is:

Leave al bounded variables of b untouched. Update the free variables by adding i − 1, the number of λ’s crossed. So The parameter i never changes. The parameter k is increased each time we cross a λ.

L.F. Ziliani Garbage Collection for a calculus with indices