What is beta reduction in lambda calculus?
Beta reduction, essentially a substitution, is a process in lambda calculus for reducing lambda expressions.
Note: Lambda calculus is a computation model that works with lambda expressions. It lays down the foundation of every functional programming language.
Understanding the notation for a lambda expression
The following is a sample lambda expression:
Every lambda expression is interpreted as the following:
Beta reduction works by finding all the occurrences of the parameter () in the output () and substituting the input () for that parameter () in the output () that gives us the reduced result ().
Structure of a lambda function
A lambda function () takes a function as input and outputs a new function. Intuitively, it can be interpreted as the following equation:
Here, is the function name, is the function parameter, and is the expression to be solved by substituting the value of that is .
In a programming language, it can be mapped to the following function:
## Function declaration and definitiondef f(x):return xy## Function callf(z)
The notation for lambda expression doesn’t require function names. It represents the function with lambda ().
Beta reduction demonstration
Let's reduce the following lambda expression using beta reduction.
Notation and rules for beta reduction
- Parameters can also be written as .
- The substitution expression for is written as . We remove the parameter and write the substitution for in notation .
- is evaluated as . We substituted the value of in place of all the occurrences of in the output (a single occurrence of in the output in this case).
The beta reduction simplifies the expression by substituting input into the function. The reduction process for the above lambda expression is demonstrated in the following slide.
Alpha conversion
Alpha conversion is just about changing the names of the same name variables while applying multiple lambda expressions with the same variable name. For example, changes to (. We perform this step before beta reduction if the lambda expressions have the same name and cause name conflict.
Free Resources