Church encoding represents data and operations as terms of the lambda calculus. A Church numeral represents a natural number by repeated function application; a Church Boolean selects one of two arguments.
The Church numeral encodes the natural number by iteration.
Church numeral successor, addition, multiplication, and exponentiation are represented by , , , and . The last term takes the base first and the exponent second. Its outer abstractions preserve the usual numeral normal form at exponent zero, implementing , including . At base type , exponentiation uses an exponent at Church type and a base at .
The lambda term
returns the Church Boolean on and on every positive Church numeral. Zero iterations leave the initial true value, while at least one iteration replaces it by false. Normal-order beta reduction evaluates a numeral conditional without evaluating an unchosen branch.
With the Church Booleans and , encode a pair by
Then and the second projection similarly returns . Pairing an iteration counter with a computed value implements primitive recursion using only Church numeral iteration.
A function is lambda-definable when some combinator satisfies
for every tuple of natural numbers.
The successor function is lambda-defined on Church numerals by
because .
Using a fixed-point combinator, Church Boolean conditionals, a zero test, and a predecessor term, lambda-definable and give
Normal-order beta reduction evaluates only the selected conditional branch, so this term implements primitive recursion on Church numerals.
If total functions and are represented by lambda terms , define
and
After iterations the Church pair holds , proved by mathematical induction using the defining recursion equations. Consequently represents the total primitive recursive function . This statement concerns total inputs and total recursion constituents; it is not an unguarded composition theorem for arbitrary partial functions.
A partial function is lambda-definable when one lambda term maps Church numerals in its domain to the numeral of the output and produces no numeral on inputs outside its domain.
Every partial computable function is represented on Church numerals by a closed untyped lambda calculus term. First represent all primitive recursive functions using zero, successor, projections, composition and lambda definition of primitive recursion by pair iteration. Apply the Kleene normal form theorem and search successive history codes with a fixed-point combinator. Test the represented total predicate using a Church numeral zero test; return the decoded output only on the true branch. If no history passes, normal-order head reduction continues the search indefinitely and the term has no head normal form, so cannot be in beta equivalence with a Church numeral. This avoids the incorrect assumption that a lazy outer function must evaluate a divergent argument in an unguarded composition.
Represent total machine configuration transitions and tests on Church numerals and Church pairs, then use a fixed-point combinator to iterate until the halting test selects the output. Normal-order beta reduction follows the computation. A nonhalting machine gives an infinite required reduction, so the normal-order normalization theorem rules out a numeral normal form.
The term beta-reduces to for every Church numeral . If its first argument has no head normal form, the whole application has no head normal form. Nesting this operation forces each represented inner computation before applying an outer function, implementing composition of partial functions even when an outer projection would discard an argument. The same guard makes lambda definition of primitive recursion strict in the preceding recursive value.
For a lambda-definable partial , a fixed-point search term tests and returns the first for which . If no such value is reached, reduction produces no Church numeral. This realizes unbounded minimization and therefore makes every partial recursive function lambda-definable.
At type , the Church Booleans are and .

Articles by others on the same topic (0)

There are currently no matching articles.