Introduced by Alonzo Church in the 1930s, λ-Calculus is a formal system in mathematical logic that expresses computation based on function abstraction and application based on variable binding and substitution.
For example, a function in standard mathematical notation would be written as:
In Lambda Notation, this is expressed using abstraction as:
This is defined as an anonymous function that takes one input and returns the result of expression .
To apply a lambda function to an argument , we write:
This expression is reduced using beta-reduction (β-reduction), which substitutes the input for every instance of in :
Lets use a square function as an example:
Currying
Now what if we want to take in two arguments? The Lambda Notation would not allow this, as it only allows a single argument. Instead, Lambda Functions are first-class, meaning they themselves could be passed in as variables. So in Lambda Calculus, functions and values are essentially equivalent, which is kinda trippy. We can use a method called currying to essentially do this.
Lets use the sum of two squares as an example. The lambda statement can be written as such:
Using β-reduction, we can first take in the variable , yielding a new one argument function:
And then we substitute .