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