a common notation system for the lambda calculus and
play

A Common Notation System for the Lambda-Calculus and Combinatory - PowerPoint PPT Presentation

A Common Notation System for the Lambda-Calculus and Combinatory Logic Masahiko Sato Graduate School of Informatics, Kyoto University Joint work with Takafumi Sakurai and Helmut Schwichtenberg IFIP WG 2.2 Meeting LaBRI, Bordeaux September 20,


  1. A Common Notation System for the Lambda-Calculus and Combinatory Logic Masahiko Sato Graduate School of Informatics, Kyoto University Joint work with Takafumi Sakurai and Helmut Schwichtenberg IFIP WG 2.2 Meeting LaBRI, Bordeaux September 20, 2017

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

  3. What are the Lambda-Calculus and Combinatory Logic? The Preface of “Lambda-Calculus and Combinators, an Introduction” by J.R. Hindley 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.

  4. What are the Lambda-Calculus and Combinatory Logic? The Preface of “Lambda-Calculus and Combinators, an Introduction” by J.R. Hindley 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.

  5. History of the calculi

  6. 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) . . .

  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) . . . 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.

  8. Today’s Key Phrases

  9. Today’s Key Phrases Semantics of syntax

  10. Today’s Key Phrases Semantics of syntax What you see is (not) what you get

  11. 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.

  12. 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 . β reduction 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

  13. 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.

  14. 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 λ ∗

  15. 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

  16. 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 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.

  17. 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.

  18. 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.

  19. 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

  20. 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

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

  22. 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

  23. 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

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

  25. 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

  26. 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:

  27. α -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!

  28. 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 Combinators I, K and S are definable in M as abbreviations: I := I 0 K := I 1 S := (( I 2 λλ I 0 ) 3 ( λ I 1 λλ I 0 ) 3 ) 3 , or , Atsushi Igarashi remarked , S := ( I 1 λ I 0 ) 3

  29. 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.

  30. 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 Remark Every M ∈ M can be reduced to a unique α -nf, and we will write M α for it.

  31. The datatype L We will write L for the following subset of M . L := { M ∈ M | M is an α -nf } We can also define L directly by the following grammar (inductive defitnition). Definition (The datatypes T and L ) t ∈ T ::= λ i I k | λ i x M, N ∈ L ::= t | ( M N ) i Elements of T are called threads .

  32. α -reduction Definition ( α -reduction on M and α -equality) M 0 → 1 α M 1 M 1 → 1 α M 2 · · · M n − 1 → 1 α M n M 0 → α M n When we have M 0 → α M n by this rule, we say that M 0 α -reduces to M n in n steps . M → α P N → α P M = α N = α is a decidable equivalence relation Theorem Given any M -term M , there uniquely exists an N such that M → α N and N is an α -nf.

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