SKI combinator calculus is a computational system that is a reduced, untyped version of Lambda calculus. The system states that all operations in Lambda calculus can be expressed in terms of the three combinators
,
, and
.
All functions in this system can be expressed using the alphabet of only
,
,
, and parentheses (used as grouping symbols). Although the most formal representation of this system requires fully balanced parentheses, it is usually simplified for readability by leaving out parentheses on the left (those that do not effect order of operations), as expressions are evaluated left to right.
Informal description
Informally, the combinators in this system are defined as follows (x, y, and z represent expressions made frome the functions
,
, and
, and set values):
takes one argument and returns it:
takes two arguments, throws away the second, and returns the first:
is a substitution operator. It takes three arguments and then returns the first argument applied to the third, which is then applied to the result of the second argument applied to the third. More clearly:
[1]
Note that from these definitions it can be shown that SKI calculus is not the minimum system that can fully perform the computations of Lambda calculus, as
can be expressed in terms of
and
. This can be proven by comparing the following expression to the definition of
above:
-
Formal definition
The terms and derivations in this system can also be more formally defined:
Terms:
The set T of terms is defined recursively by the following rules.
-
,
, and
are terms.
- If τ1 and τ2 are terms, then (τ1τ2) is a term.
- Nothing is a term if not required to be so by the first two rules.
Derivations:
A derivation is a finite sequence of terms defined recursively by the following rules (where all Greek letters represent valid terms or expressions with fully balanced parentheses):
- If Δ is a derivation of the form
, then Δ can also be expressed as the derivation αβι.
- If Δ is a derivation of the form
, then Δ can also be expressed as the derivation αβι.
- If Δ is a derivation of the form
, then Δ can also be expressed as the derivation α((βδ)(γδ))ι.
Assuming a sequence is a valid derivation to begin with, it can be evaluated using these rules. [2]
SKI expressions
Self-application and recursion
is an expression that takes an argument and applies that argument to itself:
-
One interesting property of this is that it makes the expression
irreducible:
-
Another thing that results from this is that it allows you to write a function that applies something to the self application of something else:
-
This function can be used to achieve recursion. If β is the function that applies α to the self application of something else, then self-applying β performs α recursively on ββ. More clearly, if:
-
then:
-
The reversal expression
reverses the following two terms:
-
-
-
-
-
-
-
-
SKI combinator calculus can also implement Boolean logic in the form of an if-then-else structure. An if-then-else structure consists of a Boolean expression that is either
(True) or
(False) and two arguments, such that:
-
and
-
The key is in defining the two Boolean expressions. The first works just like one of our basic combinators:
-
-
The second is also fairly simple:
-
-
Once True and False are defined, all Boolean logic can be implemented in terms of if-then-else structures.
Boolean NOT (which returns the opposite of a given boolean) works the same as the if-then-else structure, with False and True as the second and third values, so it can be implemented as a postfix operation:
-
If this is put in an if-then-else structure, it can be shown that this has the expected result
-
-
Boolean OR (which returns True if either of the two Boolean values surrounding it is True) works the same as an if-then-else structure with True as the second value, so it can be implemented as an infix operation:
-
If this is put in an if-then-else structure, it can be shown that this has the expected result:
-
-
-
-
Boolean AND (which returns True if both of the two Boolean values surrounding it are True) works the same as an if-then-else structure with False as the third value, so it can be implemented as a postfix operation:
-
If this is put in an if-then-else structure, it can be shown that this has the expected result:
-
-
-
-
Because this defines True, False, NOT (as a postfix operator), OR (as an infix operator), and AND (as a postfix operator) in terms of SKI notation, this proves that the SKI system can fully express Boolean logic.
See also
External links