Misplaced Pages

Church encoding

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Church numeral) Representation of the natural numbers as higher-order functions
This article's lead section may be too short to adequately summarize the key points. Please consider expanding the lead to provide an accessible overview of all important aspects of the article. (July 2023)

In mathematics, Church encoding is a means of representing data and operators in the lambda calculus. The Church numerals are a representation of the natural numbers using lambda notation. The method is named for Alonzo Church, who first encoded data in the lambda calculus this way.

Terms that are usually considered primitive in other notations (such as integers, Booleans, pairs, lists, and tagged unions) are mapped to higher-order functions under Church encoding. The Church–Turing thesis asserts that any computable operator (and its operands) can be represented under Church encoding. In the untyped lambda calculus the only primitive data type is the function.

Use

A straightforward implementation of Church encoding slows some access operations from O ( 1 ) {\displaystyle O(1)} to O ( n ) {\displaystyle O(n)} , where n {\displaystyle n} is the size of the data structure, making Church encoding impractical. Research has shown that this can be addressed by targeted optimizations, but most functional programming languages instead expand their intermediate representations to contain algebraic data types. Nonetheless Church encoding is often used in theoretical arguments, as it is a natural representation for partial evaluation and theorem proving. Operations can be typed using higher-ranked types, and primitive recursion is easily accessible. The assumption that functions are the only primitive data types streamlines many proofs.

Church encoding is complete but only representationally. Additional functions are needed to translate the representation into common data types, for display to people. It is not possible in general to decide if two functions are extensionally equal due to the undecidability of equivalence from Church's theorem. The translation may apply the function in some way to retrieve the value it represents, or look up its value as a literal lambda term. Lambda calculus is usually interpreted as using intensional equality. There are potential problems with the interpretation of results because of the difference between the intensional and extensional definition of equality.

Church numerals

Church numerals are the representations of natural numbers under Church encoding. The higher-order function that represents natural number n is a function that maps any function f {\displaystyle f} to its n-fold composition. In simpler terms, the "value" of the numeral is equivalent to the number of times the function encapsulates its argument.

f n = f f f n  times . {\displaystyle f^{\circ n}=\underbrace {f\circ f\circ \cdots \circ f} _{n{\text{ times}}}.\,}

All Church numerals are functions that take two parameters. Church numerals 0, 1, 2, ..., are defined as follows in the lambda calculus.

Starting with 0 not applying the function at all, proceed with 1 applying the function once, 2 applying the function twice, 3 applying the function three times, etc.:

Number Function definition Lambda expression 0 0   f   x = x 0 = λ f . λ x . x 1 1   f   x = f   x 1 = λ f . λ x . f   x 2 2   f   x = f   ( f   x ) 2 = λ f . λ x . f   ( f   x ) 3 3   f   x = f   ( f   ( f   x ) ) 3 = λ f . λ x . f   ( f   ( f   x ) ) n n   f   x = f n   x n = λ f . λ x . f n   x {\displaystyle {\begin{array}{r|l|l}{\text{Number}}&{\text{Function definition}}&{\text{Lambda expression}}\\\hline 0&0\ f\ x=x&0=\lambda f.\lambda x.x\\1&1\ f\ x=f\ x&1=\lambda f.\lambda x.f\ x\\2&2\ f\ x=f\ (f\ x)&2=\lambda f.\lambda x.f\ (f\ x)\\3&3\ f\ x=f\ (f\ (f\ x))&3=\lambda f.\lambda x.f\ (f\ (f\ x))\\\vdots &\vdots &\vdots \\n&n\ f\ x=f^{n}\ x&n=\lambda f.\lambda x.f^{\circ n}\ x\end{array}}}

The Church numeral 3 represents the action of applying any given function three times to a value. The supplied function is first applied to a supplied parameter and then successively to its own result. The end result is not the numeral 3 (unless the supplied parameter happens to be 0 and the function is a successor function). The function itself, and not its end result, is the Church numeral 3. The Church numeral 3 means simply to do anything three times. It is an ostensive demonstration of what is meant by "three times".

Calculation with Church numerals

Arithmetic operations on numbers may be represented by functions on Church numerals. These functions may be defined in lambda calculus, or implemented in most functional programming languages (see converting lambda expressions to functions).

The addition function plus ( m , n ) = m + n {\displaystyle \operatorname {plus} (m,n)=m+n} uses the identity f ( m + n ) ( x ) = f m ( f n ( x ) ) {\displaystyle f^{\circ (m+n)}(x)=f^{\circ m}(f^{\circ n}(x))} .

plus λ m . λ n . λ f . λ x . m   f   ( n   f   x ) {\displaystyle \operatorname {plus} \equiv \lambda m.\lambda n.\lambda f.\lambda x.m\ f\ (n\ f\ x)}

The successor function succ ( n ) = n + 1 {\displaystyle \operatorname {succ} (n)=n+1} is β-equivalent to ( plus   1 ) {\displaystyle (\operatorname {plus} \ 1)} .

succ λ n . λ f . λ x . f   ( n   f   x ) {\displaystyle \operatorname {succ} \equiv \lambda n.\lambda f.\lambda x.f\ (n\ f\ x)}

The multiplication function mult ( m , n ) = m n {\displaystyle \operatorname {mult} (m,n)=m*n} uses the identity f ( m n ) ( x ) = ( f n ) m ( x ) {\displaystyle f^{\circ (m*n)}(x)=(f^{\circ n})^{\circ m}(x)} .

mult λ m . λ n . λ f . λ x . m   ( n   f )   x {\displaystyle \operatorname {mult} \equiv \lambda m.\lambda n.\lambda f.\lambda x.m\ (n\ f)\ x}

The exponentiation function exp ( m , n ) = m n {\displaystyle \operatorname {exp} (m,n)=m^{n}} is given by the definition of Church numerals, n   h   x = h n   x {\displaystyle n\ h\ x=h^{n}\ x} . In the definition substitute h m , x f {\displaystyle h\to m,x\to f} to get n   m   f = m n   f {\displaystyle n\ m\ f=m^{n}\ f} and,

exp   m   n = m n = n   m {\displaystyle \operatorname {exp} \ m\ n=m^{n}=n\ m}

which gives the lambda expression,

exp λ m . λ n . n   m {\displaystyle \operatorname {exp} \equiv \lambda m.\lambda n.n\ m}

The pred ( n ) {\displaystyle \operatorname {pred} (n)} function is more difficult to understand.

pred λ n . λ f . λ x . n   ( λ g . λ h . h   ( g   f ) )   ( λ u . x )   ( λ u . u ) {\displaystyle \operatorname {pred} \equiv \lambda n.\lambda f.\lambda x.n\ (\lambda g.\lambda h.h\ (g\ f))\ (\lambda u.x)\ (\lambda u.u)}

A Church numeral applies a function n times. The predecessor function must return a function that applies its parameter n - 1 times. This is achieved by building a container around f and x, which is initialized in a way that omits the application of the function the first time. See predecessor for a more detailed explanation.

The subtraction function can be written based on the predecessor function.

minus λ m . λ n . ( n pred )   m {\displaystyle \operatorname {minus} \equiv \lambda m.\lambda n.(n\operatorname {pred} )\ m}

Table of functions on Church numerals

Function Algebra Identity Function definition Lambda expressions
Successor n + 1 {\displaystyle n+1} f n + 1   x = f ( f n x ) {\displaystyle f^{n+1}\ x=f(f^{n}x)} succ   n   f   x = f   ( n   f   x ) {\displaystyle \operatorname {succ} \ n\ f\ x=f\ (n\ f\ x)} λ n . λ f . λ x . f   ( n   f   x ) {\displaystyle \lambda n.\lambda f.\lambda x.f\ (n\ f\ x)} ...
Addition m + n {\displaystyle m+n} f m + n   x = f m ( f n x ) {\displaystyle f^{m+n}\ x=f^{m}(f^{n}x)} plus   m   n   f   x = m   f   ( n   f   x ) {\displaystyle \operatorname {plus} \ m\ n\ f\ x=m\ f\ (n\ f\ x)} λ m . λ n . λ f . λ x . m   f   ( n   f   x ) {\displaystyle \lambda m.\lambda n.\lambda f.\lambda x.m\ f\ (n\ f\ x)} λ m . λ n . n succ m {\displaystyle \lambda m.\lambda n.n\operatorname {succ} m}
Multiplication m n {\displaystyle m*n} f m n   x = ( f m ) n   x {\displaystyle f^{m*n}\ x=(f^{m})^{n}\ x} multiply   m   n   f   x = m   ( n   f )   x {\displaystyle \operatorname {multiply} \ m\ n\ f\ x=m\ (n\ f)\ x} λ m . λ n . λ f . λ x . m   ( n   f )   x {\displaystyle \lambda m.\lambda n.\lambda f.\lambda x.m\ (n\ f)\ x} λ m . λ n . λ f . m   ( n   f ) {\displaystyle \lambda m.\lambda n.\lambda f.m\ (n\ f)}
Exponentiation m n {\displaystyle m^{n}} n   m   f = m n   f {\displaystyle n\ m\ f=m^{n}\ f} exp   m   n   f   x = ( n   m )   f   x {\displaystyle \operatorname {exp} \ m\ n\ f\ x=(n\ m)\ f\ x} λ m . λ n . λ f . λ x . ( n   m )   f   x {\displaystyle \lambda m.\lambda n.\lambda f.\lambda x.(n\ m)\ f\ x} λ m . λ n . n   m {\displaystyle \lambda m.\lambda n.n\ m}
Predecessor n 1 {\displaystyle n-1} inc n con = val ( f n 1 x ) {\displaystyle \operatorname {inc} ^{n}\operatorname {con} =\operatorname {val} (f^{n-1}x)} if ( n == 0 )   0   else   ( n 1 ) {\displaystyle \operatorname {if} (n==0)\ 0\ \operatorname {else} \ (n-1)}

λ n . λ f . λ x . n   ( λ g . λ h . h   ( g   f ) )   ( λ u . x )   ( λ u . u ) {\displaystyle \lambda n.\lambda f.\lambda x.n\ (\lambda g.\lambda h.h\ (g\ f))\ (\lambda u.x)\ (\lambda u.u)}

Subtraction (Monus) m n {\displaystyle m-n} f m n   x = ( f 1 ) n ( f m x ) {\displaystyle f^{m-n}\ x=(f^{-1})^{n}(f^{m}x)} minus   m   n = ( n pred )   m {\displaystyle \operatorname {minus} \ m\ n=(n\operatorname {pred} )\ m} ... λ m . λ n . n pred m {\displaystyle \lambda m.\lambda n.n\operatorname {pred} m}

Notes:

  1. This formula is the definition of a Church numeral n with f m , x f {\displaystyle f\to m,x\to f} .
  2. ^ In the Church encoding,
    • pred ( 0 ) = 0 {\displaystyle \operatorname {pred} (0)=0}
    • m n m n = 0 {\displaystyle m\leq n\to m-n=0}

Derivation of predecessor function

The predecessor function used in the Church encoding is,

pred ( n ) = { 0 if  n = 0 , n 1 otherwise {\displaystyle \operatorname {pred} (n)={\begin{cases}0&{\mbox{if }}n=0,\\n-1&{\mbox{otherwise}}\end{cases}}} .

We need a way of applying the function 1 fewer times to build the predecessor. A numeral n applies the function f n times to x. The predecessor function must use the numeral n to apply the function n-1 times.

Before implementing the predecessor function, here is a scheme that wraps the value in a container function. We will define new functions to use in place of f and x, called inc and init. The container function is called value. The left-hand side of the table shows a numeral n applied to inc and init.

Number Using init Using const 0 init = value   x 1 inc   init = value   ( f   x ) inc   const = value   x 2 inc   ( inc   init ) = value   ( f   ( f   x ) ) inc   ( inc   const ) = value   ( f   x ) 3 inc   ( inc   ( inc   init ) ) = value   ( f   ( f   ( f   x ) ) ) inc   ( inc   ( inc   const ) ) = value   ( f   ( f   x ) ) n n inc   init = value   ( f n   x ) = value   ( n   f   x ) n inc   const = value   ( f n 1   x ) = value   ( ( n 1 )   f   x ) {\displaystyle {\begin{array}{r|r|r}{\text{Number}}&{\text{Using init}}&{\text{Using const}}\\\hline 0&\operatorname {init} =\operatorname {value} \ x&\\1&\operatorname {inc} \ \operatorname {init} =\operatorname {value} \ (f\ x)&\operatorname {inc} \ \operatorname {const} =\operatorname {value} \ x\\2&\operatorname {inc} \ (\operatorname {inc} \ \operatorname {init} )=\operatorname {value} \ (f\ (f\ x))&\operatorname {inc} \ (\operatorname {inc} \ \operatorname {const} )=\operatorname {value} \ (f\ x)\\3&\operatorname {inc} \ (\operatorname {inc} \ (\operatorname {inc} \ \operatorname {init} ))=\operatorname {value} \ (f\ (f\ (f\ x)))&\operatorname {inc} \ (\operatorname {inc} \ (\operatorname {inc} \ \operatorname {const} ))=\operatorname {value} \ (f\ (f\ x))\\\vdots &\vdots &\vdots \\n&n\operatorname {inc} \ \operatorname {init} =\operatorname {value} \ (f^{n}\ x)=\operatorname {value} \ (n\ f\ x)&n\operatorname {inc} \ \operatorname {const} =\operatorname {value} \ (f^{n-1}\ x)=\operatorname {value} \ ((n-1)\ f\ x)\\\end{array}}}

The general recurrence rule is,

inc   ( value   v ) = value   ( f   v ) {\displaystyle \operatorname {inc} \ (\operatorname {value} \ v)=\operatorname {value} \ (f\ v)}

If there is also a function to retrieve the value from the container (called extract),

extract   ( value   v ) = v {\displaystyle \operatorname {extract} \ (\operatorname {value} \ v)=v}

Then extract may be used to define the samenum function as,

samenum = λ n . λ f . λ x . extract   ( n inc init ) = λ n . λ f . λ x . extract   ( value   ( n   f   x ) ) = λ n . λ f . λ x . n   f   x = λ n . n {\displaystyle \operatorname {samenum} =\lambda n.\lambda f.\lambda x.\operatorname {extract} \ (n\operatorname {inc} \operatorname {init} )=\lambda n.\lambda f.\lambda x.\operatorname {extract} \ (\operatorname {value} \ (n\ f\ x))=\lambda n.\lambda f.\lambda x.n\ f\ x=\lambda n.n}

The samenum function is not intrinsically useful. However, as inc delegates calling of f to its container argument, we can arrange that on the first application inc receives a special container that ignores its argument allowing to skip the first application of f. Call this new initial container const. The right-hand side of the above table shows the expansions of n inc const. Then by replacing init with const in the expression for the same function we get the predecessor function,

pred = λ n . λ f . λ x . extract   ( n inc const ) = λ n . λ f . λ x . extract   ( value   ( ( n 1 )   f   x ) ) = λ n . λ f . λ x . ( n 1 )   f   x = λ n . ( n 1 ) {\displaystyle \operatorname {pred} =\lambda n.\lambda f.\lambda x.\operatorname {extract} \ (n\operatorname {inc} \operatorname {const} )=\lambda n.\lambda f.\lambda x.\operatorname {extract} \ (\operatorname {value} \ ((n-1)\ f\ x))=\lambda n.\lambda f.\lambda x.(n-1)\ f\ x=\lambda n.(n-1)}

As explained below the functions inc, init, const, value and extract may be defined as,

value = λ v . ( λ h . h   v ) extract k = k   λ u . u inc = λ g . λ h . h   ( g   f ) init = λ h . h   x const = λ u . x {\displaystyle {\begin{aligned}\operatorname {value} &=\lambda v.(\lambda h.h\ v)\\\operatorname {extract} k&=k\ \lambda u.u\\\operatorname {inc} &=\lambda g.\lambda h.h\ (g\ f)\\\operatorname {init} &=\lambda h.h\ x\\\operatorname {const} &=\lambda u.x\end{aligned}}}

Which gives the lambda expression for pred as,

pred = λ n . λ f . λ x . n   ( λ g . λ h . h   ( g   f ) )   ( λ u . x )   ( λ u . u ) {\displaystyle \operatorname {pred} =\lambda n.\lambda f.\lambda x.n\ (\lambda g.\lambda h.h\ (g\ f))\ (\lambda u.x)\ (\lambda u.u)}

Value container

The value container applies a function to its value. It is defined by,

value   v   h = h   v {\displaystyle \operatorname {value} \ v\ h=h\ v}

so,

value = λ v . ( λ h . h   v ) {\displaystyle \operatorname {value} =\lambda v.(\lambda h.h\ v)}

Inc

The inc function should take a value containing v, and return a new value containing f v.

inc   ( value   v ) = value   ( f   v ) {\displaystyle \operatorname {inc} \ (\operatorname {value} \ v)=\operatorname {value} \ (f\ v)}

Letting g be the value container,

g = value   v {\displaystyle g=\operatorname {value} \ v}

then,

g   f = value   v   f = f   v {\displaystyle g\ f=\operatorname {value} \ v\ f=f\ v}

so,

inc   g = value   ( g   f ) {\displaystyle \operatorname {inc} \ g=\operatorname {value} \ (g\ f)}
inc = λ g . λ h . h   ( g   f ) {\displaystyle \operatorname {inc} =\lambda g.\lambda h.h\ (g\ f)}

Extract

The value may be extracted by applying the identity function,

I = λ u . u {\displaystyle I=\lambda u.u}

Using I,

value   v   I = v {\displaystyle \operatorname {value} \ v\ I=v}

so,

extract   k = k   I {\displaystyle \operatorname {extract} \ k=k\ I}

Const

To implement pred the init function is replaced with the const that does not apply f. We need const to satisfy,

inc   const = value   x {\displaystyle \operatorname {inc} \ \operatorname {const} =\operatorname {value} \ x}
λ h . h   ( const   f ) = λ h . h   x {\displaystyle \lambda h.h\ (\operatorname {const} \ f)=\lambda h.h\ x}

Which is satisfied if,

const   f = x {\displaystyle \operatorname {const} \ f=x}

Or as a lambda expression,

const = λ u . x {\displaystyle \operatorname {const} =\lambda u.x}

Another way of defining pred

Pred may also be defined using pairs:

f =   λ p .   pair   ( second   p )   ( succ   ( second   p ) ) zero =   ( λ f . λ x .   x ) pc0 =   pair   zero   zero pred =   λ n .   first   ( n   f   pc0 ) {\displaystyle {\begin{aligned}\operatorname {f} =&\ \lambda p.\ \operatorname {pair} \ (\operatorname {second} \ p)\ (\operatorname {succ} \ (\operatorname {second} \ p))\\\operatorname {zero} =&\ (\lambda f.\lambda x.\ x)\\\operatorname {pc0} =&\ \operatorname {pair} \ \operatorname {zero} \ \operatorname {zero} \\\operatorname {pred} =&\ \lambda n.\ \operatorname {first} \ (n\ \operatorname {f} \ \operatorname {pc0} )\\\end{aligned}}}

This is a simpler definition but leads to a more complex expression for pred. The expansion for pred three {\displaystyle \operatorname {pred} \operatorname {three} } :

pred three =   first   ( f   ( f   ( f   ( pair   zero   zero ) ) ) ) =   first   ( f   ( f   ( pair   zero   one ) ) ) =   first   ( f   ( pair   one   two ) ) =   first   ( pair   two   three ) =   two {\displaystyle {\begin{aligned}\operatorname {pred} \operatorname {three} =&\ \operatorname {first} \ (\operatorname {f} \ (\operatorname {f} \ (\operatorname {f} \ (\operatorname {pair} \ \operatorname {zero} \ \operatorname {zero} ))))\\=&\ \operatorname {first} \ (\operatorname {f} \ (\operatorname {f} \ (\operatorname {pair} \ \operatorname {zero} \ \operatorname {one} )))\\=&\ \operatorname {first} \ (\operatorname {f} \ (\operatorname {pair} \ \operatorname {one} \ \operatorname {two} ))\\=&\ \operatorname {first} \ (\operatorname {pair} \ \operatorname {two} \ \operatorname {three} )\\=&\ \operatorname {two} \end{aligned}}}

Division

Division of natural numbers may be implemented by,

n / m = if   n m   then   1 + ( n m ) / m   else   0 {\displaystyle n/m=\operatorname {if} \ n\geq m\ \operatorname {then} \ 1+(n-m)/m\ \operatorname {else} \ 0}

Calculating n m {\displaystyle n-m} takes many beta reductions. Unless doing the reduction by hand, this doesn't matter that much, but it is preferable to not have to do this calculation twice. The simplest predicate for testing numbers is IsZero so consider the condition.

IsZero   ( minus   n   m ) {\displaystyle \operatorname {IsZero} \ (\operatorname {minus} \ n\ m)}

But this condition is equivalent to n m {\displaystyle n\leq m} , not n < m {\displaystyle n<m} . If this expression is used then the mathematical definition of division given above is translated into function on Church numerals as,

divide1   n   m   f   x = ( λ d . IsZero   d   ( 0   f   x )   ( f   ( divide1   d   m   f   x ) ) )   ( minus   n   m ) {\displaystyle \operatorname {divide1} \ n\ m\ f\ x=(\lambda d.\operatorname {IsZero} \ d\ (0\ f\ x)\ (f\ (\operatorname {divide1} \ d\ m\ f\ x)))\ (\operatorname {minus} \ n\ m)}

As desired, this definition has a single call to minus   n   m {\displaystyle \operatorname {minus} \ n\ m} . However the result is that this formula gives the value of ( n 1 ) / m {\displaystyle (n-1)/m} .

This problem may be corrected by adding 1 to n before calling divide. The definition of divide is then,

divide   n = divide1   ( succ   n ) {\displaystyle \operatorname {divide} \ n=\operatorname {divide1} \ (\operatorname {succ} \ n)}

divide1 is a recursive definition. The Y combinator may be used to implement the recursion. Create a new function called div by;

  • In the left hand side divide1 div   c {\displaystyle \operatorname {divide1} \rightarrow \operatorname {div} \ c}
  • In the right hand side divide1 c {\displaystyle \operatorname {divide1} \rightarrow c}

to get,

div = λ c . λ n . λ m . λ f . λ x . ( λ d . IsZero   d   ( 0   f   x )   ( f   ( c   d   m   f   x ) ) )   ( minus   n   m ) {\displaystyle \operatorname {div} =\lambda c.\lambda n.\lambda m.\lambda f.\lambda x.(\lambda d.\operatorname {IsZero} \ d\ (0\ f\ x)\ (f\ (c\ d\ m\ f\ x)))\ (\operatorname {minus} \ n\ m)}

Then,

divide = λ n . divide1   ( succ   n ) {\displaystyle \operatorname {divide} =\lambda n.\operatorname {divide1} \ (\operatorname {succ} \ n)}

where,

divide1 = Y   div succ = λ n . λ f . λ x . f   ( n   f   x ) Y = λ f . ( λ x . f   ( x   x ) )   ( λ x . f   ( x   x ) ) 0 = λ f . λ x . x IsZero = λ n . n   ( λ x . false )   true {\displaystyle {\begin{aligned}\operatorname {divide1} &=Y\ \operatorname {div} \\\operatorname {succ} &=\lambda n.\lambda f.\lambda x.f\ (n\ f\ x)\\Y&=\lambda f.(\lambda x.f\ (x\ x))\ (\lambda x.f\ (x\ x))\\0&=\lambda f.\lambda x.x\\\operatorname {IsZero} &=\lambda n.n\ (\lambda x.\operatorname {false} )\ \operatorname {true} \end{aligned}}}
true λ a . λ b . a false λ a . λ b . b {\displaystyle {\begin{aligned}\operatorname {true} &\equiv \lambda a.\lambda b.a\\\operatorname {false} &\equiv \lambda a.\lambda b.b\end{aligned}}}
minus = λ m . λ n . n pred m pred = λ n . λ f . λ x . n   ( λ g . λ h . h   ( g   f ) )   ( λ u . x )   ( λ u . u ) {\displaystyle {\begin{aligned}\operatorname {minus} &=\lambda m.\lambda n.n\operatorname {pred} m\\\operatorname {pred} &=\lambda n.\lambda f.\lambda x.n\ (\lambda g.\lambda h.h\ (g\ f))\ (\lambda u.x)\ (\lambda u.u)\end{aligned}}}

Gives,

divide = λ n . ( ( λ f . ( λ x . x   x )   ( λ x . f   ( x   x ) ) )   ( λ c . λ n . λ m . λ f . λ x . ( λ d . ( λ n . n   ( λ x . ( λ a . λ b . b ) )   ( λ a . λ b . a ) )   d   ( ( λ f . λ x . x )   f   x )   ( f   ( c   d   m   f   x ) ) )   ( ( λ m . λ n . n ( λ n . λ f . λ x . n   ( λ g . λ h . h   ( g   f ) )   ( λ u . x )   ( λ u . u ) ) m )   n   m ) ) )   ( ( λ n . λ f . λ x . f   ( n   f   x ) )   n ) {\displaystyle \scriptstyle \operatorname {divide} =\lambda n.((\lambda f.(\lambda x.x\ x)\ (\lambda x.f\ (x\ x)))\ (\lambda c.\lambda n.\lambda m.\lambda f.\lambda x.(\lambda d.(\lambda n.n\ (\lambda x.(\lambda a.\lambda b.b))\ (\lambda a.\lambda b.a))\ d\ ((\lambda f.\lambda x.x)\ f\ x)\ (f\ (c\ d\ m\ f\ x)))\ ((\lambda m.\lambda n.n(\lambda n.\lambda f.\lambda x.n\ (\lambda g.\lambda h.h\ (g\ f))\ (\lambda u.x)\ (\lambda u.u))m)\ n\ m)))\ ((\lambda n.\lambda f.\lambda x.f\ (n\ f\ x))\ n)}

Or as text, using \ for λ,

divide = (\n.((\f.(\x.x x) (\x.f (x x))) (\c.\n.\m.\f.\x.(\d.(\n.n (\x.(\a.\b.b)) (\a.\b.a)) d ((\f.\x.x) f x) (f (c d m f x))) ((\m.\n.n (\n.\f.\x.n (\g.\h.h (g f)) (\u.x) (\u.u)) m) n m))) ((\n.\f.\x. f (n f x)) n))

For example, 9/3 is represented by

divide (\f.\x.f (f (f (f (f (f (f (f (f x))))))))) (\f.\x.f (f (f x)))

Using a lambda calculus calculator, the above expression reduces to 3, using normal order.

\f.\x.f (f (f (x)))

Signed numbers

One simple approach for extending Church Numerals to signed numbers is to use a Church pair, containing Church numerals representing a positive and a negative value. The integer value is the difference between the two Church numerals.

A natural number is converted to a signed number by,

convert s = λ x . pair   x   0 {\displaystyle \operatorname {convert} _{s}=\lambda x.\operatorname {pair} \ x\ 0}

Negation is performed by swapping the values.

neg s = λ x . pair   ( second   x )   ( first   x ) {\displaystyle \operatorname {neg} _{s}=\lambda x.\operatorname {pair} \ (\operatorname {second} \ x)\ (\operatorname {first} \ x)}

The integer value is more naturally represented if one of the pair is zero. The OneZero function achieves this condition,

OneZero = λ x . IsZero   ( first   x )   x   ( IsZero   ( second   x )   x   ( OneZero   ( pair   ( pred   ( first   x ) )   ( pred   ( second   x ) ) ) ) ) {\displaystyle \operatorname {OneZero} =\lambda x.\operatorname {IsZero} \ (\operatorname {first} \ x)\ x\ (\operatorname {IsZero} \ (\operatorname {second} \ x)\ x\ (\operatorname {OneZero} \ (\operatorname {pair} \ (\operatorname {pred} \ (\operatorname {first} \ x))\ (\operatorname {pred} \ (\operatorname {second} \ x)))))}

The recursion may be implemented using the Y combinator,

OneZ = λ c . λ x . IsZero   ( first   x )   x   ( IsZero   ( second   x )   x   ( c   ( pair   ( pred   ( first   x ) )   ( pred   ( second   x ) ) ) ) ) {\displaystyle \operatorname {OneZ} =\lambda c.\lambda x.\operatorname {IsZero} \ (\operatorname {first} \ x)\ x\ (\operatorname {IsZero} \ (\operatorname {second} \ x)\ x\ (c\ (\operatorname {pair} \ (\operatorname {pred} \ (\operatorname {first} \ x))\ (\operatorname {pred} \ (\operatorname {second} \ x)))))}
OneZero = Y OneZ {\displaystyle \operatorname {OneZero} =Y\operatorname {OneZ} }

Plus and minus

Addition is defined mathematically on the pair by,

x + y = [ x p , x n ] + [ y p , y n ] = x p x n + y p y n = ( x p + y p ) ( x n + y n ) = [ x p + y p , x n + y n ] {\displaystyle x+y=+=x_{p}-x_{n}+y_{p}-y_{n}=(x_{p}+y_{p})-(x_{n}+y_{n})=}

The last expression is translated into lambda calculus as,

plus s = λ x . λ y . OneZero   ( pair   ( plus   ( first   x )   ( first   y ) )   ( plus   ( second   x )   ( second   y ) ) ) {\displaystyle \operatorname {plus} _{s}=\lambda x.\lambda y.\operatorname {OneZero} \ (\operatorname {pair} \ (\operatorname {plus} \ (\operatorname {first} \ x)\ (\operatorname {first} \ y))\ (\operatorname {plus} \ (\operatorname {second} \ x)\ (\operatorname {second} \ y)))}

Similarly subtraction is defined,

x y = [ x p , x n ] [ y p , y n ] = x p x n y p + y n = ( x p + y n ) ( x n + y p ) = [ x p + y n , x n + y p ] {\displaystyle x-y=-=x_{p}-x_{n}-y_{p}+y_{n}=(x_{p}+y_{n})-(x_{n}+y_{p})=}

giving,

minus s = λ x . λ y . OneZero   ( pair   ( plus   ( first   x )   ( second   y ) )   ( plus   ( second   x )   ( first   y ) ) ) {\displaystyle \operatorname {minus} _{s}=\lambda x.\lambda y.\operatorname {OneZero} \ (\operatorname {pair} \ (\operatorname {plus} \ (\operatorname {first} \ x)\ (\operatorname {second} \ y))\ (\operatorname {plus} \ (\operatorname {second} \ x)\ (\operatorname {first} \ y)))}

Multiply and divide

Multiplication may be defined by,

x y = [ x p , x n ] [ y p , y n ] = ( x p x n ) ( y p y n ) = ( x p y p + x n y n ) ( x p y n + x n y p ) = [ x p y p + x n y n , x p y n + x n y p ] {\displaystyle x*y=*=(x_{p}-x_{n})*(y_{p}-y_{n})=(x_{p}*y_{p}+x_{n}*y_{n})-(x_{p}*y_{n}+x_{n}*y_{p})=}

The last expression is translated into lambda calculus as,

mult s = λ x . λ y . pair   ( plus   ( mult   ( first   x )   ( first   y ) )   ( mult   ( second   x )   ( second   y ) ) )   ( plus   ( mult   ( first   x )   ( second   y ) )   ( mult   ( second   x )   ( first   y ) ) ) {\displaystyle \operatorname {mult} _{s}=\lambda x.\lambda y.\operatorname {pair} \ (\operatorname {plus} \ (\operatorname {mult} \ (\operatorname {first} \ x)\ (\operatorname {first} \ y))\ (\operatorname {mult} \ (\operatorname {second} \ x)\ (\operatorname {second} \ y)))\ (\operatorname {plus} \ (\operatorname {mult} \ (\operatorname {first} \ x)\ (\operatorname {second} \ y))\ (\operatorname {mult} \ (\operatorname {second} \ x)\ (\operatorname {first} \ y)))}

A similar definition is given here for division, except in this definition, one value in each pair must be zero (see OneZero above). The divZ function allows us to ignore the value that has a zero component.

divZ = λ x . λ y . IsZero   y   0   ( divide   x   y ) {\displaystyle \operatorname {divZ} =\lambda x.\lambda y.\operatorname {IsZero} \ y\ 0\ (\operatorname {divide} \ x\ y)}

divZ is then used in the following formula, which is the same as for multiplication, but with mult replaced by divZ.

divide s = λ x . λ y . pair   ( plus   ( divZ   ( first   x )   ( first   y ) )   ( divZ   ( second   x )   ( second   y ) ) )   ( plus   ( divZ   ( first   x )   ( second   y ) )   ( divZ   ( second   x )   ( first   y ) ) ) {\displaystyle \operatorname {divide} _{s}=\lambda x.\lambda y.\operatorname {pair} \ (\operatorname {plus} \ (\operatorname {divZ} \ (\operatorname {first} \ x)\ (\operatorname {first} \ y))\ (\operatorname {divZ} \ (\operatorname {second} \ x)\ (\operatorname {second} \ y)))\ (\operatorname {plus} \ (\operatorname {divZ} \ (\operatorname {first} \ x)\ (\operatorname {second} \ y))\ (\operatorname {divZ} \ (\operatorname {second} \ x)\ (\operatorname {first} \ y)))}

Rational and real numbers

Rational and computable real numbers may also be encoded in lambda calculus. Rational numbers may be encoded as a pair of signed numbers. Computable real numbers may be encoded by a limiting process that guarantees that the difference from the real value differs by a number which may be made as small as we need. The references given describe software that could, in theory, be translated into lambda calculus. Once real numbers are defined, complex numbers are naturally encoded as a pair of real numbers.

The data types and functions described above demonstrate that any data type or calculation may be encoded in lambda calculus. This is the Church–Turing thesis.

Translation with other representations

Most real-world languages have support for machine-native integers; the church and unchurch functions convert between nonnegative integers and their corresponding Church numerals. The functions are given here in Haskell, where the \ corresponds to the λ of Lambda calculus. Implementations in other languages are similar.

type Church a = (a -> a) -> a -> a
church :: Integer -> Church Integer
church 0 = \f -> \x -> x
church n = \f -> \x -> f (church (n-1) f x)
unchurch :: Church Integer -> Integer
unchurch cn = cn (+ 1) 0

Church Booleans

Church Booleans are the Church encoding of the Boolean values true and false. Some programming languages use these as an implementation model for Boolean arithmetic; examples are Smalltalk and Pico.

Boolean logic may be considered as a choice. The Church encoding of true and false are functions of two parameters:

  • true chooses the first parameter.
  • false chooses the second parameter.

The two definitions are known as Church Booleans:

true λ a . λ b . a false λ a . λ b . b {\displaystyle {\begin{aligned}\operatorname {true} &\equiv \lambda a.\lambda b.a\\\operatorname {false} &\equiv \lambda a.\lambda b.b\end{aligned}}}

This definition allows predicates (i.e. functions returning logical values) to directly act as if-clauses. A function returning a Boolean, which is then applied to two parameters, returns either the first or the second parameter:

p r e d i c a t e - x   t h e n - c l a u s e   e l s e - c l a u s e {\displaystyle \operatorname {predicate-} x\ \operatorname {then-clause} \ \operatorname {else-clause} }

evaluates to then-clause if predicate-x evaluates to true, and to else-clause if predicate-x evaluates to false.

Because true and false choose the first or second parameter they may be combined to provide logic operators. Note that there are multiple possible implementations of not.

and = λ p . λ q . p   q   p or = λ p . λ q . p   p   q not 1 = λ p . λ a . λ b . p   b   a not 2 = λ p . p   ( λ a . λ b . b )   ( λ a . λ b . a ) = λ p . p false true xor = λ a . λ b . a   ( not   b )   b if = λ p . λ a . λ b . p   a   b {\displaystyle {\begin{aligned}\operatorname {and} &=\lambda p.\lambda q.p\ q\ p\\\operatorname {or} &=\lambda p.\lambda q.p\ p\ q\\\operatorname {not} _{1}&=\lambda p.\lambda a.\lambda b.p\ b\ a\\\operatorname {not} _{2}&=\lambda p.p\ (\lambda a.\lambda b.b)\ (\lambda a.\lambda b.a)=\lambda p.p\operatorname {false} \operatorname {true} \\\operatorname {xor} &=\lambda a.\lambda b.a\ (\operatorname {not} \ b)\ b\\\operatorname {if} &=\lambda p.\lambda a.\lambda b.p\ a\ b\end{aligned}}}

Some examples:

and true false = ( λ p . λ q . p   q   p )   true   false = true false true = ( λ a . λ b . a ) false true = false or true false = ( λ p . λ q . p   p   q )   ( λ a . λ b . a )   ( λ a . λ b . b ) = ( λ a . λ b . a )   ( λ a . λ b . a )   ( λ a . λ b . b ) = ( λ a . λ b . a ) = true not 1   true = ( λ p . λ a . λ b . p   b   a ) ( λ a . λ b . a ) = λ a . λ b . ( λ a . λ b . a )   b   a = λ a . λ b . ( λ c . b )   a = λ a . λ b . b = false not 2   true = ( λ p . p   ( λ a . λ b . b ) ( λ a . λ b . a ) ) ( λ a . λ b . a ) = ( λ a . λ b . a ) ( λ a . λ b . b ) ( λ a . λ b . a ) = ( λ b . ( λ a . λ b . b ) )   ( λ a . λ b . a ) = λ a . λ b . b = false {\displaystyle {\begin{aligned}\operatorname {and} \operatorname {true} \operatorname {false} &=(\lambda p.\lambda q.p\ q\ p)\ \operatorname {true} \ \operatorname {false} =\operatorname {true} \operatorname {false} \operatorname {true} =(\lambda a.\lambda b.a)\operatorname {false} \operatorname {true} =\operatorname {false} \\\operatorname {or} \operatorname {true} \operatorname {false} &=(\lambda p.\lambda q.p\ p\ q)\ (\lambda a.\lambda b.a)\ (\lambda a.\lambda b.b)=(\lambda a.\lambda b.a)\ (\lambda a.\lambda b.a)\ (\lambda a.\lambda b.b)=(\lambda a.\lambda b.a)=\operatorname {true} \\\operatorname {not} _{1}\ \operatorname {true} &=(\lambda p.\lambda a.\lambda b.p\ b\ a)(\lambda a.\lambda b.a)=\lambda a.\lambda b.(\lambda a.\lambda b.a)\ b\ a=\lambda a.\lambda b.(\lambda c.b)\ a=\lambda a.\lambda b.b=\operatorname {false} \\\operatorname {not} _{2}\ \operatorname {true} &=(\lambda p.p\ (\lambda a.\lambda b.b)(\lambda a.\lambda b.a))(\lambda a.\lambda b.a)=(\lambda a.\lambda b.a)(\lambda a.\lambda b.b)(\lambda a.\lambda b.a)=(\lambda b.(\lambda a.\lambda b.b))\ (\lambda a.\lambda b.a)=\lambda a.\lambda b.b=\operatorname {false} \end{aligned}}}

Predicates

A predicate is a function that returns a Boolean value. The most fundamental predicate is IsZero {\displaystyle \operatorname {IsZero} } , which returns true {\displaystyle \operatorname {true} } if its argument is the Church numeral 0 {\displaystyle 0} , and false {\displaystyle \operatorname {false} } if its argument is any other Church numeral:

IsZero = λ n . n   ( λ x . false )   true {\displaystyle \operatorname {IsZero} =\lambda n.n\ (\lambda x.\operatorname {false} )\ \operatorname {true} }

The following predicate tests whether the first argument is less-than-or-equal-to the second:

LEQ = λ m . λ n . IsZero   ( minus   m   n ) {\displaystyle \operatorname {LEQ} =\lambda m.\lambda n.\operatorname {IsZero} \ (\operatorname {minus} \ m\ n)} ,

Because of the identity,

x = y ( x y y x ) {\displaystyle x=y\equiv (x\leq y\land y\leq x)}

The test for equality may be implemented as,

EQ = λ m . λ n . and   ( LEQ   m   n )   ( LEQ   n   m ) {\displaystyle \operatorname {EQ} =\lambda m.\lambda n.\operatorname {and} \ (\operatorname {LEQ} \ m\ n)\ (\operatorname {LEQ} \ n\ m)}

Church pairs

See also: Cons

Church pairs are the Church encoding of the pair (two-tuple) type. The pair is represented as a function that takes a function argument. When given its argument it will apply the argument to the two components of the pair. The definition in lambda calculus is,

pair λ x . λ y . λ z . z   x   y first λ p . p   ( λ x . λ y . x ) second λ p . p   ( λ x . λ y . y ) {\displaystyle {\begin{aligned}\operatorname {pair} &\equiv \lambda x.\lambda y.\lambda z.z\ x\ y\\\operatorname {first} &\equiv \lambda p.p\ (\lambda x.\lambda y.x)\\\operatorname {second} &\equiv \lambda p.p\ (\lambda x.\lambda y.y)\end{aligned}}}

For example,

first   ( pair   a   b ) = ( λ p . p   ( λ x . λ y . x ) )   ( ( λ x . λ y . λ z . z   x   y )   a   b ) = ( λ p . p   ( λ x . λ y . x ) )   ( λ z . z   a   b ) = ( λ z . z   a   b )   ( λ x . λ y . x ) = ( λ x . λ y . x )   a   b = a {\displaystyle {\begin{aligned}&\operatorname {first} \ (\operatorname {pair} \ a\ b)\\=&(\lambda p.p\ (\lambda x.\lambda y.x))\ ((\lambda x.\lambda y.\lambda z.z\ x\ y)\ a\ b)\\=&(\lambda p.p\ (\lambda x.\lambda y.x))\ (\lambda z.z\ a\ b)\\=&(\lambda z.z\ a\ b)\ (\lambda x.\lambda y.x)\\=&(\lambda x.\lambda y.x)\ a\ b=a\end{aligned}}}

List encodings

An (immutable) list is constructed from list nodes. The basic operations on the list are;

Function Description
nil Construct an empty list.
isnil Test if list is empty.
cons Prepend a given value to a (possibly empty) list.
head Get the first element of the list.
tail Get the rest of the list.

We give four different representations of lists below:

  • Build each list node from two pairs (to allow for empty lists).
  • Build each list node from one pair.
  • Represent the list using the right fold function.
  • Represent the list using Scott's encoding that takes cases of match expression as arguments

Two pairs as a list node

A nonempty list can be implemented by a Church pair;

  • First contains the head.
  • Second contains the tail.

However this does not give a representation of the empty list, because there is no "null" pointer. To represent null, the pair may be wrapped in another pair, giving three values:

  • First - the null pointer (empty list).
  • Second.First contains the head.
  • Second.Second contains the tail.

Using this idea the basic list operations can be defined like this:

Expression Description
nil pair   true   true {\displaystyle \operatorname {nil} \equiv \operatorname {pair} \ \operatorname {true} \ \operatorname {true} } The first element of the pair is true meaning the list is null.
isnil first {\displaystyle \operatorname {isnil} \equiv \operatorname {first} } Retrieve the null (or empty list) indicator.
cons λ h . λ t . pair false   ( pair h   t ) {\displaystyle \operatorname {cons} \equiv \lambda h.\lambda t.\operatorname {pair} \operatorname {false} \ (\operatorname {pair} h\ t)} Create a list node, which is not null, and give it a head h and a tail t.
head λ z . first   ( second z ) {\displaystyle \operatorname {head} \equiv \lambda z.\operatorname {first} \ (\operatorname {second} z)} second.first is the head.
tail λ z . second   ( second z ) {\displaystyle \operatorname {tail} \equiv \lambda z.\operatorname {second} \ (\operatorname {second} z)} second.second is the tail.

In a nil node second is never accessed, provided that head and tail are only applied to nonempty lists.

One pair as a list node

Alternatively, define

cons pair head first tail second nil false isnil λ l . l ( λ h . λ t . λ d . false ) true {\displaystyle {\begin{aligned}\operatorname {cons} &\equiv \operatorname {pair} \\\operatorname {head} &\equiv \operatorname {first} \\\operatorname {tail} &\equiv \operatorname {second} \\\operatorname {nil} &\equiv \operatorname {false} \\\operatorname {isnil} &\equiv \lambda l.l(\lambda h.\lambda t.\lambda d.\operatorname {false} )\operatorname {true} \end{aligned}}}

where the last definition is a special case of the general

p r o c e s s - l i s t λ l . l ( λ h . λ t . λ d . h e a d - a n d - t a i l - c l a u s e ) n i l - c l a u s e {\displaystyle \operatorname {process-list} \equiv \lambda l.l(\lambda h.\lambda t.\lambda d.\operatorname {head-and-tail-clause} )\operatorname {nil-clause} }

Represent the list using right fold

As an alternative to the encoding using Church pairs, a list can be encoded by identifying it with its right fold function. For example, a list of three elements x, y and z can be encoded by a higher-order function that when applied to a combinator c and a value n returns c x (c y (c z n)).

nil λ c . λ n . n isnil λ l . l   ( λ h . λ t . false )   true cons λ h . λ t . λ c . λ n . c   h   ( t   c   n ) head λ l . l   ( λ h . λ t . h )   false tail λ l . λ c . λ n . l   ( λ h . λ t . λ g . g   h   ( t   c ) )   ( λ t . n )   ( λ h . λ t . t ) {\displaystyle {\begin{aligned}\operatorname {nil} &\equiv \lambda c.\lambda n.n\\\operatorname {isnil} &\equiv \lambda l.l\ (\lambda h.\lambda t.\operatorname {false} )\ \operatorname {true} \\\operatorname {cons} &\equiv \lambda h.\lambda t.\lambda c.\lambda n.c\ h\ (t\ c\ n)\\\operatorname {head} &\equiv \lambda l.l\ (\lambda h.\lambda t.h)\ \operatorname {false} \\\operatorname {tail} &\equiv \lambda l.\lambda c.\lambda n.l\ (\lambda h.\lambda t.\lambda g.g\ h\ (t\ c))\ (\lambda t.n)\ (\lambda h.\lambda t.t)\end{aligned}}}

This list representation can be given type in System F.

Represent the list using Scott encoding

An alternative representation is Scott encoding, which uses the idea of continuations and can lead to simpler code. (see also Mogensen–Scott encoding).

In this approach, we use the fact that lists can be observed using pattern matching expression. For example, using Scala notation, if list denotes a value of type List with empty list Nil and constructor Cons(h, t) we can inspect the list and compute nilCode in case the list is empty and consCode(h, t) when the list is not empty:

list match {
  case Nil        => nilCode
  case Cons(h, t) => consCode(h,t)
}

The list is given by how it acts upon nilCode and consCode. We therefore define a list as a function that accepts such nilCode and consCode as arguments, so that instead of the above pattern match we may simply write:

list   nilCode   consCode {\displaystyle \operatorname {list} \ \operatorname {nilCode} \ \operatorname {consCode} }

Let us denote by n the parameter corresponding to nilCode and by c the parameter corresponding to consCode. The empty list is the one that returns the nil argument:

nil λ n . λ c .   n {\displaystyle \operatorname {nil} \equiv \lambda n.\lambda c.\ n}

The non-empty list with head h and tail t is given by

cons   h   t         λ n . λ c .   c   h   t {\displaystyle \operatorname {cons} \ h\ t\ \ \equiv \ \ \lambda n.\lambda c.\ c\ h\ t}

More generally, an algebraic data type with m {\displaystyle m} alternatives becomes a function with m {\displaystyle m} parameters. When the i {\displaystyle i} th constructor has n i {\displaystyle n_{i}} arguments, the corresponding parameter of the encoding takes n i {\displaystyle n_{i}} arguments as well.

Scott encoding can be done in untyped lambda calculus, whereas its use with types requires a type system with recursion and type polymorphism. A list with element type E in this representation that is used to compute values of type C would have the following recursive type definition, where '=>' denotes function type:

type List = 
  C =>                    // nil argument
  (E => List => C) =>     // cons argument
  C                       // result of pattern matching

A list that can be used to compute arbitrary types would have a type that quantifies over C. A list generic in E would also take E as the type argument.

See also

References

  1. ^ Trancón y Widemann, Baltasar; Parnas, David Lorge (2008). "Tabular Expressions and Total Functional Programming". In Olaf Chitil; Zoltán Horváth; Viktória Zsók (eds.). Implementation and Application of Functional Languages. 19th International Workshop, IFL 2007, Freiburg, Germany, September 27–29, 2007 Revised Selected Papers. Lecture Notes in Computer Science. Vol. 5083. pp. 228–229. doi:10.1007/978-3-540-85373-2_13. ISBN 978-3-540-85372-5.
  2. Jansen, Jan Martin; Koopman, Pieter W. M.; Plasmeijer, Marinus J. (2006). "Efficient interpretation by transforming data types and patterns to functions". In Nilsson, Henrik (ed.). Trends in functional programming. Volume 7. Bristol: Intellect. pp. 73–90. CiteSeerX 10.1.1.73.9841. ISBN 978-1-84150-188-8.
  3. "Predecessor and lists are not representable in simply typed lambda calculus". Lambda Calculus and Lambda Calculators. okmij.org.
  4. Allison, Lloyd. "Lambda Calculus Integers".
  5. Bauer, Andrej. "Andrej's answer to a question; "Representing negative and complex numbers using lambda calculus"".
  6. "Exact real arithmetic". Haskell. Archived from the original on 2015-03-26.
  7. Bauer, Andrej (26 September 2022). "Real number computational software". GitHub.
  8. Pierce, Benjamin C. (2002). Types and Programming Languages. MIT Press. p. 500. ISBN 978-0-262-16209-8.
  9. Tromp, John (2007). "14. Binary Lambda Calculus and Combinatory Logic". In Calude, Cristian S (ed.). Randomness And Complexity, From Leibniz To Chaitin. World Scientific. pp. 237–262. ISBN 978-981-4474-39-9.
    As PDF: Tromp, John (14 May 2014). "Binary Lambda Calculus and Combinatory Logic" (PDF). Retrieved 2017-11-24.
  10. Jansen, Jan Martin (2013). "Programming in the λ-Calculus: From Church to Scott and Back". In Achten, Peter; Koopman, Pieter W. M. (eds.). The Beauty of Functional Code - Essays Dedicated to Rinus Plasmeijer on the Occasion of His 61st Birthday. Lecture Notes in Computer Science. Vol. 8106. Springer. pp. 168–180. doi:10.1007/978-3-642-40355-2_12. ISBN 978-3-642-40354-5.
Mathematical logic
General
Theorems (list)
 and paradoxes
Logics
Traditional
Propositional
Predicate
Set theory
Types of sets
Maps and cardinality
Set theories
Formal systems (list),
language and syntax
Example axiomatic
systems
 (list)
Proof theory
Model theory
Computability theory
Related
icon Mathematics portal
Alonzo Church
Notable ideas
Students
Institutions
Family
Category: