Notes:Lambda calculus

From Maths
Jump to: navigation, search

This is a NOTES page, so it isn't an actual page in the wiki yet!

Lambda terms

We define λ-terms as follows:[1]
Let the following be given:

  • Variables: an infinite sequence of expressions, v1,,vn [Note 1]
  • Atomic constants: a sequence of expressions again, that may also be finite or empty

The set of expressions called λ-terms is defined inductively as follows:

  1. All variables and atomic constants are λ-terms
    • These are known as atoms
  2. If M and N are λ-terms then (MN) is a λ-term
    • Known as applications
    • this is a short hand for M(N) in our modern terminology[1]
  3. If M is any λ-term and x any variable then (λx.M) is a λ-term
    • Any such expression is called an abstraction

Examples

  • (λv0.(v0v00)) - a function that xx(v00) I think

Here x, y and z are distinct variables:

  • (λx.(xy)) - a function that xx(y) I think
  • ((λy.y)(λx.(xy))) - This is difficult to put into words, but simply results in the function that xx(y)
  • (x(λx.(λx.x))) - This is nasty, it looks like x(x)
  • (λx.(yz)) 'constant' function that xy(z)

Notations

  • Capital letters denote arbitrary λ- terms
  • x,y,z,u,v,w will denote variables
  • Brackets will be skipped where it is understood that things are left associative, that is:
    • MNPQ is understood to mean (((MN)P)Q) (which to us means: ((M(N))(P))(Q) - you can see why this notation is dropped!)
  • (λx.(PQ)) will become λx.PQ
  • (λx1.(λx2.((λxn.M)))). becomes λx1x2xn.M
  • Syntatic identity will be denoted by , so MN will mean that M is exactly the same term as N

Length of a term

The length of a term M is denoted lng(M) and is the total number of occurrences of atoms in M

Occurs in

See page 6 of[1]

Scope

(This is similar to scopes in programming languages)
For a particular occurrence of λx.M in a λ-term P, the occurrence of M is called the scope of the occurrence of λx immediately to the left.

Free and bound variables

An occurrence of a variable x in a term P is called:

  • Bound if it is in the scope of a λx in P
  • Bound and binding if and only if it is the x in λx
  • Free otherwise.

In addition:

  • If x has at least one binding occurrence in P we call it a bound variable of P
    • This requires thought but once it clicks it should be obvious, any variable that is a parameter of a function is a bound variable (at some point, even if unused)
  • If x has at least one free occurrence in P we call it a free variable of P
  • We denote the set of free variables of P as: FV(P)

Substitution

For any M, N and x define:

  • [N/x]M as the result of substituting N for every free occurrence of x in M, and changing the bound variables to avoid name clashes.

The exact definition is given inductively as follows

  1. [N/x]xN
  2. [N/x]aa for all atoms a
  3. [N/x](PQ)\equiv ([N/x]P[N/x]Q)
  4. [N/x](\lambda x.P)\equiv \lambda x.P
    • This demonstrates scoping well, even if x occurs in P it's bound already, and not free.
  5. [N/x](\lambda y.P)\equiv \lambda y.P if x\not\in\text{FV}(P)
  6. [N/x](\lambda y.P)\equiv \lambda y.[N/x]P if x\in\text{FV}(P) and y\not\in\text{FV}(N)
  7. [N/x](\lambda y.P)\equiv \lambda z.[N/x][z/y]P if x\in\text{FV}(P) and x\in\text{FV}(N) where z is the first variable \not\in\text{FV}(NP)

Note:

  • For the last 3 we assume that x\not\equiv y

Notes

  1. Jump up The book uses v_0,v_{00},v_{000},\cdots for some yet unknown reason

References

  1. Jump up to: 1.0 1.1 1.2 Lambda Calculus and Combinators, an introduction, J. Roger Hindley and Jonathan P. Seldin