Lambda Calculus

A function is generically written xf(x). With the same map f, yf(y), is α-equivalent to xf(x). the process of substituting x with y is called α-substitution.

The same function can be written λxf(x).
to apply a function, we need to substitute x with something, and evaluate, which we call β reduction.
for example, (λx.x+1)3β3+1.

In general if a lambda expression maps x to M (which is M(x)), written λx.M, it's β-reduction with some value a is written λx.MβM[x/a], where the slash denotes that a is substitute for x.

This is a complete programming language, called lambda calculus. We can define variables, which can themselves be functions, and the output of functions can also be functions.

Suppose we wanted to capture the map (x,y)(x+y). Well, let's write an abstract two variable function. consider λx.λy.M where M is a function of (x,y). then for a pair of inputs a,b, we have the following β-reductions:

(λx.λy.M)abβλy.M[x/a]βM[x/a][y/b]

Notice we do substitutions from left to right. This method is called currying.
Support/Figures/Pasted image 20241209181536.png

Given two things, True returns the first thing, and false returns the second thing, this encoding works, and one can check it by plugging in True and False for b in the if then. (True and False are functions here as specified in the picture)
Support/Figures/Pasted image 20241209181827.png
Basically, we need to enforce types on the inputs.

Curry - Howard Co-respondence

We can write proofs in simply typed lambda calculus in the following way. suppose A,B are types, then we can think of A and B as propositions. A is true if there exists a variable x of type A. (similarly for B).

Now, the implication A=>B, is equivalent to some function that takes AB. We can map the argument A is true, AB is true, hence B is true to the following lambda calculus statement:
aA,λx.M,M(x)B, hence M(a)B (in other words B is true).

Lambda Calculus Re-write Rules

Lambda calculus is based on a few key re-write rules that help simplify and manipulate lambda expressions. These include beta reduction, alpha conversion, and eta conversion.

1. Beta Reduction (Application)

Beta reduction is the most important re-write rule. It describes how a function (lambda expression) is applied to an argument, by substituting the argument for the function's parameter.

(λx.E)AE[x:=A]

Example:

(λx.x+1)22+1

2. Alpha Conversion (Renaming Variables)

Alpha conversion allows renaming of bound variables (variables within the scope of a lambda) to avoid conflicts. It is used to change the name of the bound variable in a lambda expression.

λx.Eλy.E[x:=y]

Example:

λx.x+1λy.y+1

3. Eta Conversion (Simplifying Functions)

Eta conversion simplifies functions that return another function. It allows you to remove unnecessary function abstractions.

λx.(Fx)FifxFV(F)

Example:

λx.(fx)f