Inference rules for lambda calculus
Lambda calculus consists of Ξ»-expressions (Ξ»-terms)
exp := var | app | abs
var := x | y | z "x", "ID", ...
app := exp exp e1 e2
abs := 'Ξ»' x '.' exp (Ξ»x.e)
Inference rules (evaluator)
tβ -> tβ'
--------------- E-App1
tβ tβ -> tβ' tβ
tβ -> tβ'
--------------- E-App2
vβ tβ -> vβ tβ'
(Ξ»x.tββ) vβ -> [x βΌ vβ] tββ E-AppAbs
[x βΌ v] t
means to substitute all occurrences of x
with v
in t
. It is like a let-expression, let x = v in t
, or lambda app (\x -> t) v
. It is a notation of Ξ²-reducing a lambda term, when a lambda abstraction is applied to a lambda term, but in also incorporates the notion of a substitution that is mindful of name capturing.
ββ leftmost term: lambda abstraction βββββββββββββββββββββββββββ
β β
β ββ scope of x βββββββββββββββββββββββββββββββββββββββββ β
β β β β a
β β ββ scope of g βββββββββββββββββββββββββββββββ β β a r
β β β β β β a r g
β β β ββ inner term βββββββββββββββ β β β r g 3
β β β β β β β β g 2 β
β β β β ββ scope g' βββββββββ€ β β β 1 β β
β β β β β β β β β β β β
(Ξ» . ( Ξ» . ( 1 2 2 2 ( Ξ» . ( 1 3 3 3 3 3 ) 1 3 ) 2 3 ) ) ) y f h
(Ξ» x . ( Ξ» g . ( g x x x ( Ξ» g . ( g x x x x x ) g x ) g x ) ) ) y f h
β β β β β β β
β β β β β β β
β β β β β β β
β β β β β application occurrence of g'
β β β β β
β β β β binding occurrence of g (must be renamed to g')
β β β β
β β β application occurrence of g βββββββββ
β β
β β binding occurrence of g
β
β binding occurrence of x
From left to right:
The top level lambda term is an application, distinguished by two lambda terms: the long one on the left, and a short one,
z
, on the right.We first encounter the binder with the binding occurrence of the parameter
g
.which we distinguish in the meta language by subscripting it with the index 1, as
gβ
.The first formal parameter is named
g
, and this is the binding occurrence of the parameter (variable)g
,
binds the argument z
, which means replacing all its application occurrences within its scope
, i.e. gβ
and gβ
.
However, on a closer inspection, we see there is another binding occurrence of g at gβ
that has the application occurrence of g at gβ
in its scope. That is, gβ
is bound by gβ
and gβ
by gβ
. Name capturing would be to allow the first binding occurrence gβ
to also substitute gβ
for parameter z
, aside from the only occurrence it is supposed to substitute, i.e. that of gβ
.
Therefore, we first need to rename (Ξ±-conversion) both occurrences of g that are to be treated as distinct bindings, and only then can we perform Ξ²-reduction i.e. application of the lambda to the argument z
.
(Ξ»g. g x (Ξ»g. g x)) z Ξ²-reduction: [g βΌ z](g x (Ξ»g. g x))
(z x (Ξ»g. z x)) NAME CAPTURE!
We must avoid name capture by first using Ξ±-conversion on the distinct but eponymously named occurrences.
(Ξ»g. g x (Ξ»g. g x)) z
(Ξ»g. g x (Ξ»f. f x)) z Ξ±-conversion
(z x (Ξ»f. f x)) z Ξ²-reduction: [g βΌ z](g x (Ξ»f. f x))
Last updated
Was this helpful?