unification of the lambda calculus and combinatory logic
play

Unification of the Lambda-Calculus and Combinatory Logic Masahiko - PowerPoint PPT Presentation

Unification of the Lambda-Calculus and Combinatory Logic Masahiko Sato Graduate School of Informatics, Kyoto University j.w.w. Takafumi Sakurai and Helmut Schwichtenberg TPP 2018 RIEC, Tohoku University November 21, 2018 Objects, Concepts


  1. Unification of the Lambda-Calculus and Combinatory Logic Masahiko Sato Graduate School of Informatics, Kyoto University j.w.w. Takafumi Sakurai and Helmut Schwichtenberg TPP 2018 RIEC, Tohoku University November 21, 2018

  2. Objects, Concepts and Notations Natural numbers: 0, 1, 2+3, · · · Rational numbers: 1/3, 2/6, · · · Real numbers: Gray-code, Signed digit code, · · · Computable functions: λ x x , I, λ xy x , K, · · ·

  3. What are the Lambda-Calculus and Combinatory Logic?

  4. What are the Lambda-Calculus and Combinatory Logic? The Preface of “Lambda-Calculus and Combinators, an Introduction” by J.R. Hindley and J.P. Seldin says: The λ -calculus and combinatory logic are two systems of logic which can also serve as abstract programming languages. They both aim to describe some very general properties of programs that can modify other programs, in an abstract setting not cluttered by details. In some ways they are rivals, in others they support each other.

  5. What are the Lambda-Calculus and Combinatory Logic? The Preface of “Lambda-Calculus and Combinators, an Introduction” by J.R. Hindley and J.P. Seldin says: The λ -calculus and combinatory logic are two systems of logic which can also serve as abstract programming languages. They both aim to describe some very general properties of programs that can modify other programs, in an abstract setting not cluttered by details. In some ways they are rivals, in others they support each other. In this talk, I will argue that they are, in fact, one and the same calculus.

  6. History of the calculi

  7. History of the calculi Again from the Preface of “Lambda-Calculus and Combinators, an Introduction”. The λ -calculus was invented around 1930 by an American logician Alonzo Church, as part of a comprehensive logical system which included higher-order operators (operators which act on other operators) . . .

  8. History of the calculi Again from the Preface of “Lambda-Calculus and Combinators, an Introduction”. The λ -calculus was invented around 1930 by an American logician Alonzo Church, as part of a comprehensive logical system which included higher-order operators (operators which act on other operators) . . . Combinatory logic has the same aims as λ -calculus, and can express the same computational concepts, but its grammar is much simpler. Its basic idea is due to two people: Moses Sh¨ onfinkel, who first thought of it in 1920, and Haskell Curry, who independently re-discovered it seven years later and turned it into a workable technique.

  9. The syntax of the Lambda Calculus and Combinatory Logic X ::= x, y, z, · · · M, N ∈ Λ ::= x | λ x M | ( M N ) 0 M, N ∈ CL ::= x | I | K | S | ( M N ) 0 ( M N ) 0 stands for the application of the function M to its argument N . It is often written simply MN , but we will always use the notation ( M N ) 0 for the application.

  10. The Lambda Calculus M, N ∈ Λ ::= x | λ x M | ( M N ) 0 λ x M stands for the function obtained from M by abstracting x in M . β -conversion rule ( λ x M N ) 0 → [ x := N ] M Example ( λ x x M ) 0 → [ x := M ] x = M (( λ xy x M ) 0 N ) 0 → ( [ x := M ] λ y x N ) 0 = ( λ y M N ) 0 → [ y := N ] M = M

  11. Combinatory Logic M, N ∈ CL ::= x | I | K | S | ( M N ) 0 Weak reduction rules ( I M ) 0 → M (( K M ) 0 N ) 0 → M ((( S M ) 0 N ) 0 P ) 0 → (( M P ) 0 ( N P ) 0 ) 0 These rules suggest the following identities. I = λ x x K = λ xy x S = λ xyz (( x z ) 0 ( y z ) 0 ) 0 By this identification, every combinatory term becomes a lambda term. Moreover, the above rewriting rules all hold in the lambda calculus.

  12. Combinatory Logic (cont.) What about the converse direction? We can translate every lambda term to a combinatory term as follow. x ∗ = x ( λ x M ) ∗ = λ ∗ x M ∗ ∗ = ( M ∗ N ∗ ) 0 ( ( M N ) 0 ) We used λ ∗ : X × CL → CL above, which we define by: λ ∗ x x := I x y := ( K y ) 0 if x � = y λ ∗ x ( M N ) 0 := (( S λ ∗ x M ) 0 λ ∗ x N ) 0 λ ∗

  13. Combinatory Logic (cont.) The abstraction operator λ ∗ enjoys the following property. x M N ) 0 → [ x := N ] M ( λ ∗ So, CL can simulate the β -reduction rule of the λ -calculus. However, the simulation does not provide isomorphism. Therefore, for example, the Church-Rosser property for CL does not imply the CR property for the λ -calculus. Recall the syntax of Λ and CL. X ::= x, y, z, · · · M, N ∈ Λ ::= x | λ x M | ( M N ) 0 M, N ∈ CL ::= x | I | K | S | ( M N ) 0

  14. Differences between λ -calculus and Combinatory Logic In combinatory logic, if M is a normal term, then ( S M ) 0 is also normal. But, in the λ -calculus, it can be simplified as follows: ( S M ) 0 → λ yz (( M z ) 0 ( y z ) 0 ) 0 . This means that the λ -calculus has a finer computational granularity. While (free) variables are indispensable in the definition of closed λ -terms, closed CL-terms can be constructed without using variables. In Λ we cannot avoid the notion of bound variables, but we don’t have the notion in CL.

  15. Our Claim Our claim is that, albeit the differences in the surface syntax of λ -calculus and Combinatory Logic, they are actually one and the same calculus (or algebra) which formalizes the abstract concept of computable function.

  16. Our Claim Our claim is that, albeit the differences in the surface syntax of λ -calculus and Combinatory Logic, they are actually one and the same calculus (or algebra) which formalizes the abstract concept of computable function. We reconcile the diffrences in the syntax by introducing a common syntactic extesion of the two calculi.

  17. Church’s syntax and Quine-Bourbaki notation (1) λ x λ y ( λ z ( z x ) 0 ( x y ) 0 ) 0 λ x λ λ y λ @ @ λ z @ λ @ @ x y @ z x

  18. Church’s syntax and Quine-Bourbaki notation (2) λ y ( λ z ( z x ) 0 ( x y ) 0 ) 0 λ y λ @ @ @ @ λ z λ @ x y @ x z x x

  19. Quine-Bourbaki notation and de Bruijn notation λ λ λ λ @ @ @ @ λ λ @ @ 1 0 0 2

  20. Generalized de Bruijn notation (1) λ 1 λ 1 λ 1 @ 1 λ 2 λ 2 @ 0 @ 0 @ 2 @ 1 @ 0 @ 1 @ 0 λ 3 λ 2 λ 2 λ 2 λ 2 @ 0 1 0 λ 3 λ 3 1 0 λ 3 λ 3 1 0 0 2 0 2 0 2

  21. Generalized de Bruijn notation (2) @ 2 λ 1 λ 1 @ 1 @ 3 @ 2 λ 2 @ 0 @ 2 @ 1 λ 1 λ 1 λ 1 λ 1 @ 1 @ 0 λ 2 λ 2 λ 2 λ 2 λ 2 λ 2 λ 2 λ 2 1 0 1 0 1 0 λ 3 λ 3 λ 3 λ 3 λ 3 λ 3 0 2 0 2 0 2

  22. Nameless binder and distributive law λ ( D E ) n = ( λD λE ) n +1

  23. Generalized Church’s syntax (1) λ x λ x λ x @ 1 λ y λ y @ 0 @ 0 @ 2 @ 1 @ 0 @ 1 @ 0 λ z λ y λ y λ y λ y @ 0 x y λ z λ z x y λ z λ z x y z x z x z x

  24. Generalized Church’s syntax (2) @ 2 λ x λ x @ 1 @ 3 @ 2 λ y @ 0 @ 2 @ 1 λ x λ x λ x λ x @ 1 @ 0 λ y λ y λ y λ y λ y λ y λ y λ y λ z λ z x y λ z λ z x y λ z λ z x y z x z x z x λ x ( D E ) n = ( λ x D λ x E ) n +1 . Distributive Law:

  25. α -reduction @ 2 @ 2 λ x @ 3 @ 2 @ 3 @ 2 λ y @ 0 I 2 I 1 λ x λ x λ x λ x λ λ @ 0 I 0 λ z λ y λ y λ y λ y λ @ 0 x y λ z λ z x y I 0 z x z x λ x x → α I 0 , λ x λ y x → α I 1 , λ x λ y λ z x → α I 2 , . . . λ x I k → α λ I k , λ x λ I k → α λλ I k , λ x λλ I k → α λλλ I k , . . . α -reduction rules can compute α normal form. To achieve this, we must extend Church’s syntax!

  26. Common extension of lambda calculus and combinatory logic Definition (The datatypes M , Λ and CL) M, N ∈ M ::= x | I k | λ x M | λM | ( M N ) i ( i, k ∈ N ) M, N ∈ Λ ::= x | λ x M | ( M N ) 0 M, N ∈ CL ::= x | I | K | S | ( M N ) 0 We will write M 0 for the subset { M ∈ M | M is closed } of M . Combinators I, K and S are definable in M 0 as abbreviations: I := I 0 K := I 1 S := (( I 2 λλ I 0 ) 3 ( λ I 1 λλ I 0 ) 3 ) 3

  27. M as an extension of combinatory logic In order to make M, N ∈ M ::= x | I k | λ x M | λM | ( M N ) i an extension of combinatory logic, we embedded the S combinator in M by the following informal computation. S = λ xyz (( x z ) 0 ( y z ) 0 ) 0 = (( λ xyz x λ xyz z ) 3 ( λ xyz y λ xyz z ) 3 ) 3 = (( I 2 λλ I 0 ) 3 ( λ I 1 λλ I 0 ) 3 ) 3

  28. α -reduction Definition (One step α -reduction on M ) E 1 λ x λ i I k → 1 α λ i +1 I k x � = y E 2 λ x λ i y → 1 α λ i +1 y E 3 λ x λ i x → 1 α I i M → 1 α M ′ λ ∗ ( M N ) i → 1 α ( λ ∗ M λ ∗ N ) i +1 D λ ∗ M → 1 α λ ∗ M ′ C 1 M → 1 α M ′ N → 1 α N ′ ( M N ) i → 1 α ( M ′ N ) i C 2 ( M N ) i → 1 α ( M N ′ ) i C 3 Definition ( α -nf) M is an α -nf if M cannot be simplified by one step α -reduction.

  29. α -reduction (cont.) Example This example shows how the variable-binders λ x and λ y are eliminated by one step α -reductions. λ x λ y ( y x ) 0 → 1 α λ x ( λ y y λ y x ) 1 → 1 α λ x ( I λ y x ) 1 → 1 α λ x ( I λx ) 1 → 1 α ( λ x I λ x λx ) 2 → 1 α ( λ I λ x λx ) 2 → 1 α ( λ I K ) 2

  30. α -reduction (cont.) Remark Every M ∈ M can be reduced to a unique α -nf, and we will write M α for it. We have α -equality = α by writing M = α N for M α = N α . The α -normalizing function ( − ) α : M → M is idempotent, and we will write L for its image. Traditional λ -calculus studied the structure of the setoid (Λ , = α ) . We will work on L which is a pure datatype, free from the concept of α -equality.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend