Combinatory logic
Combinatory logic is a notation to eliminate the need for quantified variables in mathematical logic. It was introduced by Moses Schönfinkel and Haskell Curry, and has more recently been used in computer science as a theoretical model of computation and also as a basis for the design of functional programming languages
Combinatory logic is a notation to eliminate the need for quantified variables in mathematical logic. It was introduced by Moses Schönfinkel and Haskell Curry, and has more recently been used in computer science as a theoretical model of computation and also as a basis for the design of functional programming languages. It is based on combinators, which were introduced by Schönfinkel in 1920 with the idea of providing an analogous way to build up functions — and to remove any mention of variables — particularly in predicate logic. A combinator is a higher-order function that uses only function application and earlier defined combinators to define a result from its arguments.
In mathematics
Combinatory logic was originally intended as a 'pre-logic' that would clarify the role of quantified variables in logic, essentially by eliminating them. Another way of eliminating quantified variables is Quine's predicate functor logic. While the expressive power of combinatory logic typically exceeds that of first-order logic, the expressive power of predicate functor logic is identical to that of first-order logic (Quine 1960, 1966, 1976).
The inventor of combinatory logic, Moses Schönfinkel, published nothing on combinatory logic after his original 1924 paper. Haskell Curry rediscovered the combinators while working as an instructor at Princeton University in late 1927. In the late 1930s, Alonzo Church and his students at Princeton invented a rival formalism for functional abstraction, the lambda calculus, which proved more popular than combinatory logic. The upshot of these historical contingencies was that until theoretical computer science began taking an interest in combinatory logic in the 1960s and 1970s, nearly all work on the subject was by Haskell Curry and his students, or by Robert Feys in Belgium. Curry and Feys (1958), and Curry et al. (1972) survey the early history of combinatory logic. For a more modern treatment of combinatory logic and the lambda calculus together, see the book by Barendregt, which reviews the models Dana Scott devised for combinatory logic in the 1960s and 1970s.
In computing
In computer science, combinatory logic is used as a simplified model of computation, used in computability theory and proof theory. Despite its simplicity, combinatory logic captures many essential features of computation.
Combinatory logic can be viewed as a variant of the lambda calculus, in which lambda expressions (representing functional abstraction) are replaced by a limited set of combinators, primitive functions without free variables. It is easy to transform lambda expressions into combinator expressions, and combinator reduction is much simpler than lambda reduction. Hence combinatory logic has been used to model some non-strict functional programming languages and hardware. The purest form of this view is the programming language Unlambda, whose sole primitives are the S and K combinators augmented with character input/output. Although not a practical programming language, Unlambda is of some theoretical interest.
Combinatory logic can be given a variety of interpretations. Many early papers by Curry showed how to translate axiom sets for conventional logic into combinatory logic equations. Dana Scott in the 1960s and 1970s showed how to marry model theory and combinatory logic.
Summary of lambda calculus
Lambda calculus is concerned with objects called lambda-terms, which can be represented by the following three forms of strings:
v
λv.E1
(E1E2)
where v is a variable name drawn from a predefined infinite set of variable names, and E1 and E2 are lambda-terms.
Terms of the form λv.E1 are called abstractions. The variable v is called the formal parameter of the abstraction, and E1 is the body of the abstraction. The term λv.E1 represents the function which, applied to an argument, binds the formal parameter v to the argument and then computes the resulting value of E1 — that is, it returns E1, with every occurrence of v replaced by the argument.
Terms of the form E1E2 are called applications. Applications model function invocation or execution: the function represented by E1 is to be invoked, with E2 as its argument, and the result is computed. If E1 (sometimes called the applicand) is an abstraction, the term may be reduced: E2, the argument, may be substituted into the body of E1 in place of the formal parameter of E1, and the result is a new lambda term which is equivalent to the old one. If a lambda term contains no subterms of the form ((λv.E1)E2) then it cannot be reduced, and is said to be in normal form.
The expression E[v:=a] represents the result of taking the term E and replacing all free occurrences of v in it with a. Thus we write
((λv.E)a)⇒E[v:=a]
By convention, we take (abc) as shorthand for ((ab)c) (i.e., application is left associative).
The motivation for this definition of reduction is that it captures the essential behavior of all mathematical functions. For example, consider the function that computes the square of a number. We might write
The square of x is x∗x
(Using "∗" to indicate multiplication.) x here is the formal parameter of the function. To evaluate the square for a particular argument, say 3, we insert it into the definition in place of the formal parameter:
The square of 3 is 3∗3
To evaluate the resulting expression 3∗3, we would have to resort to our knowledge of multiplication and the number 3. Since any computation is simply a composition of the evaluation of suitable functions on suitable primitive arguments, this simple substitution principle suffices to capture the essential mechanism of computation.
Moreover, in lambda calculus, notions such as '3' and '∗' can be represented without any need for externally defined primitive operators or constants. It is possible to identify terms in lambda calculus, which, when suitably interpreted, behave like the number 3 and like the multiplication operator, q.v. Church encoding.
Lambda calculus is known to be computationally equivalent in power to many other plausible models for computation (including Turing machines); that is, any calculation that can be accomplished in any of these other models can be expressed in lambda calculus, and vice versa. According to the Church–Turing thesis, both models can express any possible computation.
It is perhaps surprising that lambda-calculus can represent any conceivable computation using only the simple notions of function abstraction and application based on simple textual substitution of terms for variables. But even more remarkable is that abstraction is not even required. Combinatory logic is a model of computation equivalent to lambda calculus, but without abstraction. The advantage of this is that evaluating expressions in lambda calculus is quite complicated because the semantics of substitution must be specified with great care to avoid variable capture problems. In contrast, evaluating expressions in combinatory logic is much simpler, because there is no notion of substitution.
Combinatory calculi
Since abstraction is the only way to manufacture functions in the lambda calculus, something must replace it in the combinatory calculus. Instead of abstraction, combinatory calculus provides a limited set of primitive functions out of which other functions may be built.
Combinatory terms
A combinatory term has one of the following forms:
The primitive functions are combinators, or functions that, when seen as lambda terms, contain no free variables.
To shorten the notations, a general convention is that (E1E2E3...En), or even E1E2E3...En, denotes the term (...((E1E2)E3)...En). This is the same general convention (left-associativity) as for multiple application in lambda calculus.
Reduction in combinatory logic
In combinatory logic, each primitive combinator comes with a reduction rule of the form
(P x1…xn)=E
where E is a term mentioning only variables from the set {x1…xn}. It is in this way that primitive combinators behave as functions.
Examples of combinators
The simplest example of a combinator is I, the identity combinator, defined by
(I x)=x
for all terms x. Another simple combinator is K, which manufactures constant functions: (Kx) is the function which, for any argument, returns x, so we say
((K x) y)=x
for all terms x and y. Or, following the convention for multiple application,
(K x y)=x
A third combinator is S, which is a generalized version of application:
(S x y z)=(x z (y z))
S applies x to y after first substituting z into each of them. Or put another way, x is applied to y inside the environment z.
Given S and K, I itself is unnecessary, since it can be built from the other two:
((SKK)x)
=(SKK)x
=Kx(Kx)
=x
for any term x. Note that although ((SKK)x)=(Ix) for any x, (SKK)
Adapted from the Wikipedia article Combinatory logic, available under CC BY-SA 4.0.