Untyped lambda-calculus
N ::= x | λx.N | NN
Variable capture
When a term with free variable x is substituted inside λx.N, by which the variable x becomes bound.
Simple type syntax
τ ::= o | τ → τ
Outermost reduction
Innermost reduction
Zip
zip :: [a] -> [b] -> [(a,b)]
zip _ [] = []
zip [] _ = []
zip (x:xs) (y:ys) = (x,y) : zip xs ys
Weakly normalising term
Strongly normalising term
Example term that is neither weakly nor strongly normalizing
(λx.xx)(λx.xx)
Fixed-point combinator
Fixed-point combinator proof
For any lambda-term M, Y M = β M(Y M)
Y M
→ (λx.M(xx))(λx.M(xx))
→ M((λx.M(xx))(λx.M(xx)))
← M(Y M)
Capture-avoiding substitution
M[y/x] = M with x renamed to y
Examples of capture-avoiding substitution
1) Example: (λx.xy)[λz.z/y]
This means change y to λz.z
Therefore = λx.x(λz.z)
2) Example: (λx.xy)[λz.zx/y]
Therefore = λw.w(λz.zx)
The x changes to w to avoid capturing the free x in λz.zx
3) Example: (f(λx.yx)yx)[fy/x]
Therefore = f(λx.yx)y(fy)
The bound x in λx.yx is not substituted
4) Example: (λf.f(λx.yx)yx)[fy/x]
Therefore = λg.g(λx.yx)y(fy)
The bound f is renamed to g avoiding capturing the free f
Church-Rosser Property
Confluence
Whenever M →∗ N1 and M →∗ N2, there is some P such that N1 →∗ P and N2 →∗ P
Local Confluence
Whenever M → N1 and M → N2, there is some P such that N1 →∗ P and N2 →∗ P
Free and bound variables
If the first occurrence of a variable appears when defining a lambda, then it is bound to that lambda.
For example, in λx.x, variable x is bound as it first occurs in λx
Otherwise, it is a free variable. For example, in (λx.x)(λy.yx):
- the variable x in λx.x is bound to
the first lambda
- the variable y in λy.yx is bound to
the second lambda
- the variable x in λy.yx is free
Example 3 - (λx.xy)(λy.y):
Lazy evaluation
Fixed point in the λ-calculus
Simply typed lambda-calculus
M ::= x | λx^τ.M | MM
Typing rules
Referential transparency
Computational effects
Functions that use computational effects