Airglow: Difference between revisions
en>Bibcode Bot m Adding 1 arxiv eprint(s), 0 bibcode(s) and 0 doi(s). Did it miss something? Report bugs, errors, and suggestions at User talk:Bibcode Bot |
en>BG19bot m WP:CHECKWIKI error fix for #62. Left offf http://. Do general fixes if a problem exists. -, replaced: <ref>www. → <ref>http://www. using AWB (9838) |
||
Line 1: | Line 1: | ||
'''SKI combinator calculus''' is a [[model of computation|computational system]] that may be perceived as a reduced version of untyped [[lambda calculus]]. It can be thought of as a computer programming language, though it is not useful for writing software. Instead, it is important in the mathematical theory of [[algorithm]]s because it is an extremely simple [[Turing complete]] language. | |||
All operations in lambda calculus are expressed in SKI as [[binary trees]] whose leaves are one of the three symbols '''S''', '''K''', and '''I''' (called ''combinators''). In fact, the symbol '''I''' is added only for convenience, and just the other two suffice for all of the purposes of the SKI system. | |||
Although the most formal representation of the objects in this system requires binary trees, they are usually represented, for typesetability, as parenthesized expressions, either with all the subtrees parenthesized, or only the right-side children subtrees parenthesized. So, the tree whose left subtree is the tree '''KS''' and whose right subtree is the tree '''SK''' is usually typed as (('''KS''')('''SK''')), or more simply as '''KS'''('''SK'''), instead of being fully drawn as a tree (as formality and readability would require). | |||
==Informal description== | |||
Informally, and using programming language jargon, a tree (''xy'') can be thought of as a "function" ''x'' applied to an | |||
"argument" ''y''. When "evaluated" (''i.e.'', when the function is "applied" to the argument), the tree "returns a value", ''i.e.'', transforms into another tree. Of course, all three of the "function", the "argument" and the "value" are either combinators, or binary trees, and if they are binary trees they too may be thought of as functions whenever the need arises. | |||
The '''evaluation''' operation is defined as follows: | |||
(''x'', ''y'', and ''z'' represent expressions made from the functions '''S''', '''K''', and '''I''', and set values): | |||
'''I''' returns its argument: | |||
:'''I'''''x'' = ''x'' | |||
'''K''', when applied to any argument ''x'', yields a one-argument constant function '''K'''''x'' , which, when applied to any argument, returns ''x'': | |||
:'''K'''''xy'' = ''x'' | |||
'''S''' 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: | |||
:'''S'''''xyz'' = ''xz''(''yz'') | |||
Example computation: '''SKSK''' evaluates to '''KK'''('''SK''') by the '''S'''-rule. Then if we evaluate '''KK'''('''SK'''), we get '''K''' by the '''K'''-rule. As no further rule can be applied, the computation halts here. | |||
Note that, for all trees ''x'' and all trees ''y'', '''SK'''''xy'' will always evaluate to ''y'' in two steps, '''K'''''y''(''xy'') = ''y'', so the ultimate result of evaluating '''SK'''''xy'' will always equal the result of evaluating ''y''. We say that '''SK'''''x'' and '''I''' are "functionally equivalent" because they always yield the same result when applied to any ''y''. | |||
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 all occurrences of '''I''' in any expression can be replaced by ('''SKK''') or ('''SKS''') or ('''SK''' whatever) and the resulting expression will yield the same result. So the "'''I'''" is merely [[syntactic sugar]]. | |||
In fact, it is possible to define a complete system using only one combinator. An example is Chris Barker's [[Iota and Jot|iota]] combinator, defined as follows: | |||
: ι''x'' = ''x'''''SK''' | |||
==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. | |||
# '''S''', '''K''', and '''I''' are terms. | |||
# If τ<sub>1</sub> and τ<sub>2</sub> are terms, then (τ<sub>1</sub>τ<sub>2</sub>) 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 ending in an expression of the form α('''I'''β)ι, then Δ followed by the term αβι is a derivation. | |||
# If Δ is a derivation ending in an expression of the form α(('''K'''β)γ)ι, then Δ followed by the term αβι is a derivation. | |||
# If Δ is a derivation ending in an expression of the form α((('''S'''β)γ)δ)ι, then Δ followed by the term α((βδ)(γδ))ι is a derivation. | |||
Assuming a sequence is a valid derivation to begin with, it can be extended using these rules. [http://people.cs.uchicago.edu/~odonnell/Teacher/Lectures/Formal_Organization_of_Knowledge/Examples/combinator_calculus/] | |||
==SKI expressions== | |||
===Self-application and recursion=== | |||
'''SII''' is an expression that takes an argument and applies that argument to itself: | |||
: '''SII'''α = '''I'''α('''I'''α) = αα | |||
One interesting property of this is that it makes the expression '''SII'''('''SII''') irreducible: | |||
: '''SII'''('''SII''') = '''I'''('''SII''')('''I'''('''SII''')) = '''I'''('''SII''')('''SII''') = '''SII'''('''SII''') | |||
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: | |||
: ('''S'''('''K'''α)('''SII'''))β = '''K'''αβ('''SII'''β) = α('''SII'''β) = α(ββ) | |||
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: | |||
: β = '''S'''('''K'''α)('''SII''') | |||
then: | |||
: '''SII'''β = ββ = α(ββ) = α(α(ββ)) = <math>\ldots</math> | |||
===The reversal expression=== | |||
'''S'''('''K'''('''SI'''))'''K''' reverses the following two terms: | |||
: '''S'''('''K'''('''SI'''))'''K'''αβ → | |||
: '''K'''('''SI''')α('''K'''α)β → | |||
: '''SI'''('''K'''α)β → | |||
: '''I'''β('''K'''αβ) → | |||
: '''I'''βα | |||
: βα | |||
===Boolean logic=== | |||
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 ('''T''') or false ('''F''') and two arguments, such that: | |||
: '''T'''''xy'' = ''x'' | |||
and | |||
: '''F'''''xy'' = ''y'' | |||
The key is in defining the two Boolean expressions. The first works just like one of our basic combinators: | |||
: '''T''' = '''K''' | |||
: '''K'''''xy'' = ''x'' | |||
The second is also fairly simple: | |||
: '''F''' = '''SK''' | |||
: '''SK'''''xy'' = '''K'''''y(xy)'' = y | |||
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 '''F''' and '''T''' as the second and third values, so it can be implemented as a postfix operation: | |||
: '''NOT''' = ('''F''')('''T''') = ('''SK''')('''K''') | |||
If this is put in an ''if-then-else'' structure, it can be shown that this has the expected result | |||
: ('''T''')'''NOT''' = '''T'''('''F''')('''T''') = '''F''' | |||
: ('''F''')'''NOT''' = '''F'''('''F''')('''T''') = '''T''' | |||
Boolean '''OR''' (which returns '''T''' if either of the two Boolean values surrounding it is '''T''') works the same as an ''if-then-else'' structure with '''T''' as the second value, so it can be implemented as an infix operation: | |||
: '''OR''' = '''T''' = '''K''' | |||
If this is put in an ''if-then-else'' structure, it can be shown that this has the expected result: | |||
: ('''T''')'''OR'''('''T''') = '''T'''('''T''')('''T''') = '''T''' | |||
: ('''T''')'''OR'''('''F''') = '''T'''('''T''')('''F''') = '''T''' | |||
: ('''F''')'''OR'''('''T''') = '''F'''('''T''')('''T''') = '''T''' | |||
: ('''F''')'''OR'''('''F''') = '''F'''('''T''')('''F''') = '''F''' | |||
Boolean '''AND''' (which returns '''T''' if both of the two Boolean values surrounding it are '''T''') works the same as an ''if-then-else'' structure with '''F''' as the third value, so it can be implemented as a postfix operation: | |||
: '''AND''' = '''F''' = '''SK''' | |||
If this is put in an ''if-then-else'' structure, it can be shown that this has the expected result: | |||
: ('''T''')('''T''')'''AND''' = '''T'''('''T''')('''F''') = '''T''' | |||
: ('''T''')('''F''')'''AND''' = '''T'''('''F''')('''F''') = '''F''' | |||
: ('''F''')('''T''')'''AND''' = '''F'''('''T''')('''F''') = '''F''' | |||
: ('''F''')('''F''')'''AND''' = '''F'''('''F''')('''F''') = '''F''' | |||
Because this defines '''T''', '''F''', '''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. | |||
==Connection to intuitionistic logic== | |||
The combinators '''K''' and '''S''' correspond to two well-known axioms of [[sentential logic]]: | |||
'''AK''': ''A'' <math>\to</math> (''B'' <math>\to</math> ''A''),<br> | |||
'''AS''': (''A'' <math>\to</math> (''B'' <math>\to</math> ''C'')) <math>\to</math> ((''A'' <math>\to</math> ''B'') <math>\to</math> (''A'' <math>\to</math> ''C'')). | |||
Function application corresponds to the rule [[modus ponens]]: | |||
'''MP''': from ''A'' and ''A'' <math>\to</math> ''B'', infer ''B''. | |||
The axioms '''AK''' and '''AS''', and the rule '''MP''' are complete for the implicational fragment of [[intuitionistic logic]]. In order for combinatory logic to have as a model: | |||
*The [[implicational propositional calculus|implicational fragment]] of [[classical logic]], would require the combinatory analog to the [[law of excluded middle]], ''e.g.'', [[Peirce's law]]; | |||
*[[sentential logic|Complete classical logic]], would require the combinatory analog to the sentential axiom '''F''' <math>\to</math> ''A''. | |||
==See also== | |||
* [[Combinatory logic]] | |||
* [[B,C,K,W system]] | |||
* [[Fixed point combinator]] | |||
* [[Lambda calculus]] | |||
* [[Functional programming]] | |||
* [[Unlambda]] programming language | |||
* [[To Mock a Mockingbird]] | |||
==References == | |||
* [[Raymond Smullyan|Smullyan, Raymond]], 1985. ''[[To Mock a Mockingbird]]''. Knopf. ISBN 0-394-53491-3. A gentle introduction to combinatory logic, presented as a series of recreational puzzles using bird watching metaphors. | |||
*--------, 1994. ''Diagonalization and Self-Reference''. Oxford Univ. Press. Chpts. 17-20 are a more formal introduction to combinatory logic, with a special emphasis on fixed point results. | |||
==External links== | |||
* O'Donnell, Mike "[http://people.cs.uchicago.edu/~odonnell/Teacher/Lectures/Formal_Organization_of_Knowledge/Examples/combinator_calculus/ The SKI Combinator Calculus as a Universal System.]" | |||
* Keenan, David C. (2001) "[http://dkeenan.com/Lambda/index.htm To Dissect a Mockingbird.]" | |||
* Rathman, Chris, "[http://www.angelfire.com/tx4/cus/combinator/birds.html Combinator Birds.]" | |||
* "[http://cstein.kings.cam.ac.uk/~chris/combinators.html "Drag 'n' Drop Combinators (Java Applet).]" | |||
* [http://www.lfcs.inf.ed.ac.uk/reports/89/ECS-LFCS-89-85/ A Calculus of Mobile Processes, Part I] (PostScript) (by Milner, Parrow, and Walker) shows a scheme for ''combinator [[graph reduction]]'' for the SKI calculus in pages 25–28. | |||
[[Category:Lambda calculus]] | |||
[[Category:Combinatory logic]] | |||
[[de:Kombinatorische Logik]] |
Revision as of 00:28, 7 January 2014
SKI combinator calculus is a computational system that may be perceived as a reduced version of untyped lambda calculus. It can be thought of as a computer programming language, though it is not useful for writing software. Instead, it is important in the mathematical theory of algorithms because it is an extremely simple Turing complete language.
All operations in lambda calculus are expressed in SKI as binary trees whose leaves are one of the three symbols S, K, and I (called combinators). In fact, the symbol I is added only for convenience, and just the other two suffice for all of the purposes of the SKI system.
Although the most formal representation of the objects in this system requires binary trees, they are usually represented, for typesetability, as parenthesized expressions, either with all the subtrees parenthesized, or only the right-side children subtrees parenthesized. So, the tree whose left subtree is the tree KS and whose right subtree is the tree SK is usually typed as ((KS)(SK)), or more simply as KS(SK), instead of being fully drawn as a tree (as formality and readability would require).
Informal description
Informally, and using programming language jargon, a tree (xy) can be thought of as a "function" x applied to an "argument" y. When "evaluated" (i.e., when the function is "applied" to the argument), the tree "returns a value", i.e., transforms into another tree. Of course, all three of the "function", the "argument" and the "value" are either combinators, or binary trees, and if they are binary trees they too may be thought of as functions whenever the need arises.
The evaluation operation is defined as follows:
(x, y, and z represent expressions made from the functions S, K, and I, and set values):
I returns its argument:
- Ix = x
K, when applied to any argument x, yields a one-argument constant function Kx , which, when applied to any argument, returns x:
- Kxy = x
S 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:
- Sxyz = xz(yz)
Example computation: SKSK evaluates to KK(SK) by the S-rule. Then if we evaluate KK(SK), we get K by the K-rule. As no further rule can be applied, the computation halts here.
Note that, for all trees x and all trees y, SKxy will always evaluate to y in two steps, Ky(xy) = y, so the ultimate result of evaluating SKxy will always equal the result of evaluating y. We say that SKx and I are "functionally equivalent" because they always yield the same result when applied to any y.
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 all occurrences of I in any expression can be replaced by (SKK) or (SKS) or (SK whatever) and the resulting expression will yield the same result. So the "I" is merely syntactic sugar.
In fact, it is possible to define a complete system using only one combinator. An example is Chris Barker's iota combinator, defined as follows:
- ιx = xSK
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.
- S, K, and I 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 ending in an expression of the form α(Iβ)ι, then Δ followed by the term αβι is a derivation.
- If Δ is a derivation ending in an expression of the form α((Kβ)γ)ι, then Δ followed by the term αβι is a derivation.
- If Δ is a derivation ending in an expression of the form α(((Sβ)γ)δ)ι, then Δ followed by the term α((βδ)(γδ))ι is a derivation.
Assuming a sequence is a valid derivation to begin with, it can be extended using these rules. [1]
SKI expressions
Self-application and recursion
SII is an expression that takes an argument and applies that argument to itself:
- SIIα = Iα(Iα) = αα
One interesting property of this is that it makes the expression SII(SII) irreducible:
- SII(SII) = I(SII)(I(SII)) = I(SII)(SII) = SII(SII)
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:
- (S(Kα)(SII))β = Kαβ(SIIβ) = α(SIIβ) = α(ββ)
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:
- β = S(Kα)(SII)
then:
The reversal expression
S(K(SI))K reverses the following two terms:
- S(K(SI))Kαβ →
- K(SI)α(Kα)β →
- SI(Kα)β →
- Iβ(Kαβ) →
- Iβα
- βα
Boolean logic
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 (T) or false (F) and two arguments, such that:
- Txy = x
and
- Fxy = y
The key is in defining the two Boolean expressions. The first works just like one of our basic combinators:
- T = K
- Kxy = x
The second is also fairly simple:
- F = SK
- SKxy = Ky(xy) = y
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 F and T as the second and third values, so it can be implemented as a postfix operation:
- NOT = (F)(T) = (SK)(K)
If this is put in an if-then-else structure, it can be shown that this has the expected result
- (T)NOT = T(F)(T) = F
- (F)NOT = F(F)(T) = T
Boolean OR (which returns T if either of the two Boolean values surrounding it is T) works the same as an if-then-else structure with T as the second value, so it can be implemented as an infix operation:
- OR = T = K
If this is put in an if-then-else structure, it can be shown that this has the expected result:
- (T)OR(T) = T(T)(T) = T
- (T)OR(F) = T(T)(F) = T
- (F)OR(T) = F(T)(T) = T
- (F)OR(F) = F(T)(F) = F
Boolean AND (which returns T if both of the two Boolean values surrounding it are T) works the same as an if-then-else structure with F as the third value, so it can be implemented as a postfix operation:
- AND = F = SK
If this is put in an if-then-else structure, it can be shown that this has the expected result:
- (T)(T)AND = T(T)(F) = T
- (T)(F)AND = T(F)(F) = F
- (F)(T)AND = F(T)(F) = F
- (F)(F)AND = F(F)(F) = F
Because this defines T, F, 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.
Connection to intuitionistic logic
The combinators K and S correspond to two well-known axioms of sentential logic:
AK: A (B A),
AS: (A (B C)) ((A B) (A C)).
Function application corresponds to the rule modus ponens:
The axioms AK and AS, and the rule MP are complete for the implicational fragment of intuitionistic logic. In order for combinatory logic to have as a model:
- The implicational fragment of classical logic, would require the combinatory analog to the law of excluded middle, e.g., Peirce's law;
- Complete classical logic, would require the combinatory analog to the sentential axiom F A.
See also
- Combinatory logic
- B,C,K,W system
- Fixed point combinator
- Lambda calculus
- Functional programming
- Unlambda programming language
- To Mock a Mockingbird
References
- Smullyan, Raymond, 1985. To Mock a Mockingbird. Knopf. ISBN 0-394-53491-3. A gentle introduction to combinatory logic, presented as a series of recreational puzzles using bird watching metaphors.
- --------, 1994. Diagonalization and Self-Reference. Oxford Univ. Press. Chpts. 17-20 are a more formal introduction to combinatory logic, with a special emphasis on fixed point results.
External links
- O'Donnell, Mike "The SKI Combinator Calculus as a Universal System."
- Keenan, David C. (2001) "To Dissect a Mockingbird."
- Rathman, Chris, "Combinator Birds."
- ""Drag 'n' Drop Combinators (Java Applet)."
- A Calculus of Mobile Processes, Part I (PostScript) (by Milner, Parrow, and Walker) shows a scheme for combinator graph reduction for the SKI calculus in pages 25–28.