-Calculus


All mathematical objects can be described as a lambda expression, including numbers, data structures etc... It was also proven to be equivalently capable to Turing's machine.

Table of Contents


Syntax and Notation


In lambda calculus, the functions are defined to take only one argument, with a signifier indicating the start of a function definition, followed by a placeholder for the parameter with a '' symbol to separate the parameter with the return expression.

For examples is the identity function.

For any functions and parameters, an application of function to the parameter is denoted as . For multiple application of function, in lambda calculus is equivalent to in mathematics. One could use parenthesis to change the order of function application. would be equivalent to .

This does not provide the ability for multiple parameters, but it could be achieved with curing. For example, . A shorthand notation would be , but it is not a function with two parameters, but instead a function that takes in a function , and returns another function, which takes an argument and returns . The ordering does matter, and in this example, this lambda expression is different from .

-Reduction


The -reduction is a process of reducing a given lambda expression to the "-normal form" (the simplest form). Example:

Combinators


A combinator is a lambda expression that every variable is quantified. For examples, is a combinator while is not, because is not quantified in the second example.

Identity

is the identity, which maps all inputs to themselves.

Mockingbird

is the mockingbird combinator. It applies itself to itself. When is supplied to , can be reduced down to . However, would result in an infinite number of self application when reducing it.

Kestrel

always returns the first curried argument, so could be reduced to . It can be used as a constant, after applying an argument to it once, the result of a second application is not dependent on the second parameter. For example, is a function that always returns no matter the input.

Kite

always returns the second curried argument, so could be reduced to . By expanding this combinator, we obtain .

Cardinal

reverses the arguments of a function application. For example, can be reduced to .

Bluebird

is a combinator that allows composition of functions. It composes the function and .

Y Fixed-Point Combinator

This combinator is defined as , and it is equivalent to . By reducing this combinator we obtain:

and so on. This combinator's behavior is similar to a non-stopping recursion. With some modifications, it is equivalent to recursion in Turing machines.

Boolean


Logical operations can be performed with lambda calculus.

True and False

However, a definition for the logical true and false is required. Recall that everything in lambda calculus are functions, so the true and false can be defined as functions that take two arguments.

  • True: returns the first argument (the combinator)
  • False: returns the second argument (the combinator)

Negation

is the combinator for the logical not operation. When x is true, it would return which represents false. Otherwise, it would return which represents true. Notice that the cardinal combinator is exactly identical, which means that the cardinal is the combinator for boolean negation.

Conjunction

is the combinator for the logical and operation. Consider both cases of , this expression is also equivalent to

Disjunction

is the combinator for the logical or operation. Consider both cases of , this expression is also equivalent to

Data Structure


Data structure are used to hold data to be processed after, so the function would be given and applied after the data is stored. It would hold the data until is given, which will then return the value of the processed data.

For example, let the data structure be , this structure stores a pair of values. If we store the value true and false, we obtain . At this point, is a function that takes in an argument and returns , so applying the logical or operator would give , while supplying the logical or and operator yields .

Since everything in lambda calculus is expressed in functions, there is no data types, so the same combinator can be used for different types of data.

Church Numeral


Everything in lambda calculus are functions, so the natural numbers can be defined as functions that has two arguments:

  1. a function
  2. an argument that will be supplied to

In lambda calculus, a natural number are defined as a combinator that applied time on .

For examples:

Successor

A successor combinator is needed to allow the creation of any natural number by induction. It first applies times on , then an addition application. Notice that this is equivalent to .

Addition

Addition of numbers and can be defined as the succession of , or equivalently, the succession of .

Predecessor

In order to perform subtraction, we would need a combinator for the predecessor of the church numerals. Suppose there is a pair of values, where the second value is one greater than the first value, then the first value is the predecessor of the second.

Definitions:

as defined in Data Structure

returns the first value of a pair

returns the second value of a pair

is the pair

constructs a successor pair of the given pair.

Notice that when is applied times to the pair , the second value of the resultant pair would be , and since the first value is always the predecessor of the second, the first value would be for all . For . Hence, the predecessor combinator for all would be:

This definition of predecessor implies that the predecessor of 0 is 0 itself.

Subtraction

Subtraction of the natural numbers and can be defined as the predecessor of .

For , after or more application of on , the return value would always be 0.

Multiplication

Multiplication of natural numbers is repeated addition.

Power

Exponential of natural numbers is repeated multiplication.

Is Zero

When n is zero, there is no function application. Otherwise, the function , which is the constant function for false, would be called (perhaps repeatedly).

Ordering

This definition uses the property discussed in subtraction.

If and , then .

If , then .

If , then .