Spring 2012 Juyeon Kang qkang@fi.muni.cz B410, Faculty of Informatics, Masaryk University, Brno, Czech Rep. IA165 Combinatory Logic for Computational Semantics 2 Lecture 3 ● Continue about the theory of combinators 3 ● Interesting book ”To mock a Mockingbird and Other LOgic Puzzles: including an Amazing Adventure in Combinatory Logic” by Raymond Smullyan (1985) → combinator Birds B from Bluebird, C from Cardinal, I from Identity Bird, K from Kestrel, S from Starling, and so on. 4 Theory of combinators ● Combinatory base: S and K All combinators can be defined from the two combinators S and K. ● Combinators, called elemantary : I, K, B, W, C, S, Φ, Ψ ● All combinators work with the elimination (e.) and the introduction (i.) rules. ● All combiantors are defined by β-reduction: Xfgx... →β fgx.... 5 Introduction and elimination rules (in Gentzen style) ● Rules analogues to the rules of the natural deduction of Gentzen ● Rules introduce or eliminate the logical constants : => of implication, & of conjonction, v of disjonction Rule of elimination Rule of introduction p p=>q q -------- [e.=>] -------------[i.=>] q p=>q p&q p&q p, q ----[e-&] -----[e-&] ----[i-&] p q p&q 6 Comment: a. With each of the simpler combinators we shall associate a rule of reduction, designated by the symbol for the combinator between parentheses. b. This rule states that when the combinator in question is applied sucessively to a (finite ) series of variables, the resulting combination reduces to a certain combination of those variables. c. This reduction will follow from the definition of the combinator by (β-) rule. d. And we shall use lower case italic letters for unspecified variables. The letters x, y, z will often be used, when in the usual application, the variable is thought of as a function or an argument. 7 ● The combinator B takes two functiors f and g and composes the function g with the argument x. → composition The introduction and elimination rule of the combinator B 8 ● The combinator W takes one functor f and applies the functor f to the argument x by duplicating the argument x. → duplication The introduction and elimination rule of the combiantor W 9 ● The combinator C takes one functor f and two arguments x and y. The elimination of the combinator C by β-reduction allows to converse the position of the arguement x with y. → conversion The introduction and elimination rule of the combinator C 10 ● The combinator Φ takes three functors f, g, and h, and the functor g and h become intricate with the argument x. → intrication The introduction and elimination rule of the combinator Φ 11 ● The combinator C* takes an argument x (operand) and transforms it in functor(operator). → transformation of operand to operator The introduction and elimination rule of the combinator C∗ 12 ● Ψ fgxy →β f(gx)(gy) the combinator Ψ takes two functions f and g and composes with the arguments x and y by distributing the second function g to each of them. → distribution (Ψ f g) x y f (g x) (g y) 13 β-reduction 14 ● Examples of β-reduction : X ≥β Y By the scheme of β-reduction [B] B(fx)gx ≥β fx(gx) X = xy(Bxyz)UT ≥β xy(x(yz))UT =Y By the scheme of β-reduction [W] X= B(Wxy)U ≥β B(xyy)U =Y We use here the infix ≤ to denote the relation converse to ≥. 15 Interdefinability of simple combinators ● Certain of the combinators can be defined by the others. => by the way that the reduction rule for the derived combinator will follow from its definition and the reduction rule for the basic combinators. Important point We shall show that (1) W, S, Φ and ψ can be so defined in terms of B, C and either W or S (see the classwork n°3); (2) that I can be defined in terms of W and K; and (3) that all the combinators on the list can be expressed in terms of S and K (refer to the classwork n°2: completeness of the S-K base). Important point We shall show that (1) W, S, Φ and ψ can be so defined in terms of B, C and either W or S (see the classwork n°3); (2) that I can be defined in terms of W and K; and (3) that all the combinators on the list can be expressed in terms of S and K (refer to the classwork n°2: completeness of the S-K base). 16 Properties of B-Theorems Theorem 1. If x is a regular combinaotr and Y a combinator; then X·Y applied to a sequence of arguments performs upon them first the transoformation X, then the transformation Y. Example: C performs a permutation, W performs a duplication, C·W performs a permutation, then a duplication on the result: (C·W)fxy ≥ C(Wf)xy ≥ Wfyx ≥ fyyx 17 Theorem 2. The product is associative, i.e., X·(Y ·Z)=(X· Y)·Z Proof a. ((X· Y)·Z)f ≥ B(BXY)Zf ≥ BXY(Zf) ≥ X(Y(Zf)) b. (X (Y Z))f ≥ BX(BYZ)f ≥ X(BYZf) ≥ X(Y(Zf)) 18 Theorem 3. The product is distributive with respect to pre-application of B, i.e., B(X ·Y)= BX · BY Proof B(X ·Y)fx ≥(X ·Y)(fx) ≥X(Y(fx) ≤ X(BYfx) ≤ BX(BYf)x ≤ (BX · BY)fx 19 Power of combinators ● Definition: We define the powers of a combinatory composite by natural induction thus: X0 =def I X1 =def X Xn+1 =def X·Xn ● From these definitions, it is possible to deduce the following X, X2 , X3 , that is, X, X·X, X·X·X, … ● Application to the combinators C2 fxy ≥ C(Cf)xy ≥ Cfyx ≥ fxy W2 fx ≥ W(Wfx) ≥ Wfxx ≥ fxxx K2 fxy ≥ K(Kf)xy ≥ Kfy ≥ f given the combinatorial expression X: 20 ● B2 fxyz ≡ B(Bf)xyz ≥ Bf(xy)z ≥ f((xy)z) ≡ f(xyz) Theorem: For any expressions U, X, Y, Z1 ,....,Zn , Bn UXZ1 ...Zn ≥ U(XZ1 ...Zn ), Φn UXYZ1 ...Zn ≥ U(XZ1 ...Zn )(YZ1 ...Zn ) 21 Summing up-combinators combinators β-reduction B for functional composition Bxyz ≥β x(yz) I for identity Ix ≥β x C for conversion Cxyz ≥β x(zy) W for duplication Wxy ≥β xyy S for distribution Sxyz ≥β xz(yz) K for effacement Kxy ≥β x C* for transposition C*xy ≥β yx Φ for intrication Φxyzu ≥β x(yu)(zu) Ψ for distribution ψ xyzu ≥β x(yz)(yu) Summing up-combinators 22 Summing up-theorems S K K x → x S (K S) K x y z → x(yz) S (K (S I)) K x y → (y x) S (K (S I)) (S (K K ) I) x y (y x)→ **Completeness of the S-K base [S K K =I] [S (K S) K=B] [S (K (S I)) K=C] [S (K (S I)) (S (K K ) I)=C] 23 Next week... ● About the Combinators vs λ-conversion and the application of the combinators to natural language analysis