Chapter 6: Minimal Calculus
Lambda Calculus
All functions in lambda calculus could be reduced into following minimal functions, or combinators:
λ x . x λ x . c λ x . y z \lambda x.x\\
\lambda x.c\\
\lambda x.yz λ x . x λ x . c λ x . yz
The first one returns its parameter unchanged. The second one returns a free variable captured from outer scope, which is considered as constant to the inner function itself. The third one provokes an application.
SKI Calculus
But there is a more famous set of combinators, called SKI Caculus.
let { I = λ x . x K = λ x y . x S = λ x y z . x z ( y z ) then { λ x . x = I λ x . c = K c λ x . y z = S ( λ x . y ) ( λ x . z ) \begin{array}{}
\text{let}&\left\{
\begin{array}{}
I&=&\lambda x.x \\
K&=&\lambda xy.x \\
S&=&\lambda xyz.xz(yz)\\
\end{array}\right.\\
\text{then}&\left\{
\begin{array}{}
\lambda x.x &=& I\\
\lambda x.c &=& Kc\\
\lambda x.yz &=& S (\lambda x.y) (\lambda x.z)\\
\end{array}\right.\\
\end{array} let then ⎩ ⎨ ⎧ I K S = = = λ x . x λ x y . x λ x yz . x z ( yz ) ⎩ ⎨ ⎧ λ x . x λ x . c λ x . yz = = = I Kc S ( λ x . y ) ( λ x . z )
Then we can learn calculus again.
T = K F = S K not = S ( S I ( K F ) ) ( K T ) and = S S ( K ( K F ) ) or = S I ( K T ) ⋮ T=K\\
F=SK\\
\text{not}=S(SI(KF))(KT)\\
\text{and}=SS(K(KF))\\
\text{or}=SI(KT)\\
\vdots T = K F = S K not = S ( S I ( K F )) ( K T ) and = SS ( K ( K F )) or = S I ( K T ) ⋮
Don't wanna enumerate more. You may try it by yourself.
SK Calculus
However, I I I is actually not primitive. It could still be rewritten as:
I = S K K = S K S I=SKK=SKS I = S KK = S K S
Then we get SK Calculus! Can go dive deeper into this? Sure!
Iota Calculus
Don't close your mouth while watching this magic.
let ι = λ f . f S K then { I = ι ι K = ι ( ι I ) = ι ( ι ( ι ι ) ) S = ι ( K ) = ι ( ι ( ι ( ι ι ) ) ) \begin{array}{}
\text{let}&\space\space\space
\iota=\lambda f.fSK\\
\text{then}&\left\{
\begin{array}{}
I &&&=& \iota\iota\\
K &=& \iota(\iota I) &=& \iota(\iota(\iota\iota))\\
S &=& \iota(K) &=& \iota(\iota(\iota(\iota\iota)))\\
\end{array}\right.\\
\end{array} let then ι = λ f . f S K ⎩