nLab
combinatory logic

Combinatory logic

Idea

Combinator algebra has always struck me as a subject almost impossible to watch: it’s a lousy spectator sport but has a reputation of habit-forming as a participator sport. P. Freyd (1989, p.63)

Combinatory logic is a rephrasing of the lambda calculus that avoids explicit mention of variables and of lambda abstraction. Instead it uses combinators? – in the most common case, they are traditionally called SS, KK, and II – with the only other operation being application.

Since this move circumvents the necessity of variable management, combinatory logic is important for applications in computer science and linguistics.

Under the propositions as types correspondence, combinatory logic corresponds to the presentation of logic using a Hilbert system (instead of natural deduction or sequent calculus). There are versions of combinatory logic corresponding to linear logic and affine logic, generally called BCI logic and BCK logic (after the combinators they use).

Historical remarks

The 1920s gave birth to several formal systems that permitted to base mathematics on the notion of function like e.g. the lambda calculus or von Neumann ‘set’ theory that eventually morphed into Neumann-Bernays-Gödel set theory. Notably the first of such systems was combinatory logic which was introduced by Moses Schönfinkel in 1920 (Schönfinkel 1924) and developed (partly independently) by Haskell Curry by the end of the decade.

Of course, a later such function based approach to mathematics is category theory and there has been in fact some interaction between combinatory logic and category theory (Bunder 1984). In 1972 when the connection between Cartesian closed categories and lambda calculus was an object of active research, Jim Lambek wrote:

Schönfinkel’s original program to base all of mathematics on combinatory logic can now be said to have been carried out by Lawvere in his many articles pursuing a categorical formulation of mathematics. (1972, p.57)

The combinators S, K, and I

The basic combinators can be defined in terms of λ\lambda-calculus as

  • S=λx.λy.λz.(xz)(yz)S = \lambda x. \lambda y. \lambda z. (x z)(y z)
  • K=λx.λy.xK = \lambda x. \lambda y. x
  • I=λx.xI = \lambda x. x

In simply typed lambda-calculus, these combinators are polymorphic with types

  • S:(A(BC))(AB)(AC)S : (A \to (B\to C)) \to (A\to B) \to (A\to C)
  • K:A(BA)K : A\to (B\to A)
  • I:AAI : A\to A

for arbitrary types A,B,CA,B,C.

When combinatory logic is presented on its own rather than in terms of λ\lambda-calculus, the combinators are characterized by reduction rules that mirror their definition in terms of λ\lambda-abstractions:

  • Sxyz(xz)(yz)S x y z \equiv (x z)(y z)
  • KxyxK x y \equiv x
  • IxxI x \equiv x

Sometimes the combinator II is omitted, as it can be defined from SS and KK as I=SKKI=S K K.

Encoding abstraction

The combinators SS, KK, and II are used to encode λ\lambda-abstraction in the following way. If MM is a term in combinatory logic (perhaps containing variables), we define λx.M\lambda x.M by induction over the structure of the term MM.

  • If M=xM=x, then λx.x=I\lambda x.x = I.
  • If MM is a variable yxy\neq x, then λx.y=Ky\lambda x.y = K y.
  • If M=NPM = N P is an application of one term to another, then λx.M=S(λx.N)(λx.P)\lambda x.M = S (\lambda x.N) (\lambda x.P), so we can recursively translate λx.N\lambda x.N and λx.P\lambda x.P.

(It is common to see this described with the second case given as “λx.M=KM\lambda x.M = K M whenever MM does not contain xx as a free variable”. However, this overlaps with the third case and is not structurally recursive. The above definition translates λx.yz\lambda x.y z to S(Ky)(Kz)S(K y)(K z), while the one with the free-variable-check produces K(yz)K(y z); both reduce to yzy z when applied to any argument.)

Using this construction of an “abstraction operator” in the combinatory logic, we can then proceed to translate an arbitrary term of λ\lambda-calculus into combinatory logic by translating all the abstractions “from the inside out”. Formally, we crawl over the term and whenever we find an abstraction, we first recurse into its body, then we apply the above abstraction operator.

The construction of an abstraction operator in combinatory logic is analogous to a cut admissibility theorem; the resulting translation of λ\lambda-calculus into combinatory logic is then analogous to the corresponding cut-elimination theorem.

Linear (BCI) and affine (BCK) combinatory logic

Versions of combinatory logic that correspond to linear logic and affine logic have been studied under the names BCI logic and BCK logic respectively, with the letters indicating the combinators used, where

  • B=λx.λy.λz.x(yz):(BC)(AB)(AC)B = \lambda x.\lambda y.\lambda z. x(yz) : (B\to C) \to (A\to B) \to (A\to C)
  • C=λx.λy.λz.(xz)y:(A(BC))(B(AC))C = \lambda x.\lambda y.\lambda z. (xz)y : (A\to (B\to C)) \to (B \to (A\to C))

The combinator II is also definable as CKKCKK, so it is also available in BCK logic (which might therefore be called BCKI logic). Similarly, traditional combinatory logic could be called “SKI logic”, or just “SK logic”.

Note that BB has the same type as the “composition” operation in a closed category, while CC has the type of a symmetry/exchange for a closed category. Similarly, KK is a sort of weakening rule while SS combines composition, symmetry, and contraction.

Remark

A partial combinatory algebra , also called a Schönfinkel algebra , is an algebraic structure that abstracts the structure of (partial) combinatory logic. They play an important role in the theory of realizability toposes.

References

  • Moses Schönfinkel, Über die Bausteine der mathematischen Logik , Math. Ann. 92 (1924) pp.305-316. (gdz) English translation with comments by Quine pp.355-366 in van Heijenoort (ed.), From Frege to Gödel , Harvard UP 1967.

  • M. W. Bunder, Category Theory Based on Combinatory Logic , Arch. Math. Logik 24 (1984) pp.1-15. (gdz)

  • Peter Freyd, Combinators , Contemp. Math. 92 (1989) pp.63-66.

  • R. Hindley, J. Seldin, Introduction to Combinators and λ\lambda-Calculus , Cambridge UP 1986.

  • Jim Lambek, Deductive systems and categories III. Cartesian closed categories, intuitionist propositional calculus, and combinatory logic , pp.57–82 LNM 274 Springer Heidelberg 1972.

Revised on June 14, 2017 13:42:52 by Urs Schreiber (46.183.103.8)