0% found this document useful (0 votes)
109 views

Lambda Calculus and Combinatory Logic

- The document discusses Lambda Calculus and Combinatory Logic as two systems that can serve as abstract programming languages. - Lambda Calculus was invented by Alonzo Church in the 1930s to study functions and recursion. It uses lambda notation for anonymous functions. Combinatory Logic was invented by Schönfinkel and Curry to clarify the role of quantified variables using combinators. - The document defines terms in Lambda Calculus and Combinatory Logic and introduces concepts such as free/bound variables, substitution, β-reduction, and weak reduction. It establishes that β-reduction is Church-Rosser.

Uploaded by

Andrés Ortega
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views

Lambda Calculus and Combinatory Logic

- The document discusses Lambda Calculus and Combinatory Logic as two systems that can serve as abstract programming languages. - Lambda Calculus was invented by Alonzo Church in the 1930s to study functions and recursion. It uses lambda notation for anonymous functions. Combinatory Logic was invented by Schönfinkel and Curry to clarify the role of quantified variables using combinators. - The document defines terms in Lambda Calculus and Combinatory Logic and introduces concepts such as free/bound variables, substitution, β-reduction, and weak reduction. It establishes that β-reduction is Church-Rosser.

Uploaded by

Andrés Ortega
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

Lambda Calculus and Combinatory Logic

Andrés Sicard-Ramı́rez

Universidad EAFIT

Semester 2009-2
Introduction
References
Textbook: Hindley, J. R. and Seldin, J. [2008]. Lambda-Calculus and
Combinators. An Introduction. Cambridge University Press.
Barendregt, Henk and Barendsen, Erik [2000]. Introduction to
Lambda Calculus. Revisited edition, Mar. 2000.
Barendregt, H. P. [2004]. The Lambda Calculus. Its Syntax and
Semantics. Revised edition, 6th impression. Vol. 103. Studies in
Logic and the Foundations of Mathematics. Elsevier.

Introduction 3/106
Lambda Calculus and Combinatory Logic
“Two systems of logic which can also serve as abstract programming
languages.” [Hindley and Seldin 2008, p. ix]
The goal was to use them in the foundation of mathematics.

Introduction 4/106
Lambda Calculus and Combinatory Logic
λ-calculus
Invented by Alonzo Church (around
1930s). Intended for studying func-
tions and recursion.

Introduction 5/106
Lambda Calculus and Combinatory Logic
Combinatory logic

Invented by Moses Schönfinkel (1920) and Haskell Curry (1927). Intended


for clarify the role of quantified variables.

Introduction 6/106
Lambda Calculus
Introduction
λ-calculus is a collection of several formal systems
λ-notation
Anonymous functions
Currying

Definition (λ-terms)

v ∈ V ⇒ v ∈ λ-terms (atom)
c ∈ C ⇒ c ∈ λ-terms (atom)
M, N ∈ λ-terms ⇒ (M N ) ∈ λ-terms (application)
M ∈ λ-terms, x ∈ V ⇒ (λx.M ) ∈ λ-terms (abstraction)

where V /C is a set of variables/constants.

Lambda Calculus 8/106


Introduction
Conventions and syntactic sugar
Application associates to the left
M N1 N2 . . . Nk means (...((M N1 )N2 )...Nk )
Application has higher precedence
λx.P Q means (λx.(P Q))
λx1 x2 . . . xn .M means (λx1 .(λx2 .(. . . (λxn .M ) . . . )))
M ≡ N means the syntactic identity

Example
(λxyz.xz(yz))uvw ≡ ((((λx.(λy.(λz.((xz)(yz)))))u)v)w).

Lambda Calculus 9/106


Term-Structure and Substitution
Definition (P occurs in Q)
P occurs in P
If P occurs in M or in N , then P occurs in (M N )
If P occurs in M or P ≡ x, then P occurs in (λx.M )

Definition (scope)
In λx.M , M is called the scope of λx.

Lambda Calculus 10/106


Term-Structure and Substitution
Definition (free and bound occurrence of 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, iff it is the x in λx
free otherwise

Definition (bound variable of P )


If x has at least one binding occurrence in P .

Definition (free variable of P )


If x has at least one free occurrence in P .
FV(P ): The set of free variables of P .

Lambda Calculus 11/106


Term-Structure and Substitution
Example
(λy.yx(λx.y(λy.z)x))vw. (whiteboard)

Definition (close term or combinator)


A term without free variables.

Lambda Calculus 12/106


Term-Structure and Substitution
Definition (substitution [N/x]M )
The result of substituting N for every free occurrence of x in M , and
changing bound variables to avoid clashes.

[N/x]x ≡ N
[N/x]a ≡ a for all atoms a 6≡ x
[N/x](P Q) ≡ ([N/x]P [N/x]Q)
[N/x](λx.P ) ≡ (λx.P )
[N/x](λy.P ) ≡ (λy.P ) y 6≡ x, x 6∈ FV(P )
[N/x](λy.P ) ≡ λy.[N/x]P y 6≡ x, x ∈ FV(P ), y 6∈ FV(N )
[N/x](λy.P ) ≡ λz.[N/x][z/y]P y 6≡ x, x ∈ FV(P ), y ∈ FV(N )

where in the last equation, z is chosen to be a variable 6∈ FV(N P ).

Lambda Calculus 13/106


Term-Structure and Substitution
Example
[(λy.vy)/x](y(λv.xv)) ≡ y(λz.(λy.vy)z) (with z 6≡ v, y, x).

Lambda Calculus 14/106


Term-Structure and Substitution
Definition (α-conversion or changed of bound variables)
Replace λx.M by λy.[y/x]M (y 6∈ FV(M )).

Definition (α-congruence (P ≡α Q))


P is changed to Q by a finite (perhaps empty) series of α-conversions.

Lambda Calculus 15/106


Beta Reduction
Definition (β-contraction (P .1β Q))
Replace an occurrence of (λx.M )N (β-redex) in P by [N/x]M (contrac-
tum).

Example
Whiteboard.

Definition (β-reduction (P .β Q))


P is changed to Q by a finite (perhaps empty) series of β-contractions and
α-conversions.

Example
(λx.(λy.yx)z)v .β zv.

Lambda Calculus 16/106


Beta Reduction
Definition (β-normal form)
A term which contains no β-redex.
β-nf: The set of all β-normal forms.

Example
Whiteboard.

Lambda Calculus 17/106


Beta Reduction
Theorem (Church-Rosser theorem for .β )
P .β M P .β N
∃ T.M .β T ∧ N .β T P

} !
M N

! }
∃T
Corollary
If P has a β-normal form, it is unique modulo ≡α ; that is, if P has β-normal
forms M and N , then M ≡α N .

Lambda Calculus 18/106


Beta Equality
Definition (β-equality or β-convertibility (P =β Q))
Exist P0 , . . . , Pn such that
P0 ≡ P
Pn ≡ Q
(∀i ≤ n − 1)(Pi .1β Pi+1 ∨ Pi+1 .1β Pi ∨ Pi ≡α Pi+1 )

Theorem (Church-Rosser theorem for =β )


P =β Q
∃ T.P .β T ∧ Q .β T

Proof.
Whiteboard.

Lambda Calculus 19/106


Beta Equality
Corollary
If P, Q ∈ β-nf and P =β Q, then P ≡α Q.

Corollary
The relation =β is non-trivial (not all terms are β-convertible to each other).

Proof.
Whiteboard.

Lambda Calculus 20/106


Combinatory Logic
Introduction
Idea
To do logic and mathematics without use bound variables.

Combinators
Operators which manipulate expressions by cancellation, duplication, brack-
eting and permutation.

Combinatory Logic 22/106


Introduction
Example (informal)
The commutative law for addition

∀xy.x + y = y + x,

can be written as
A = CA,
where Axy represents x + y and C is a combinator with the property

Cf xy = f yx.

Combinatory Logic 23/106


Introduction
Example (some combinators (informal))

Bf gx = f (gx) composition operator


0
B f gx = g(f x) reversed composition operator
Ix = x identity operator
Kxy = x projection operator
Sf gx = f x(gx) stronger composition operator
Wf x = f xx doubling operator

Combinatory Logic 24/106


Introduction
Definition (CL-terms)

v ∈ V ⇒ v ∈ CL-terms
c ∈ C ⇒ c ∈ CL-terms
X, Y ∈ CL-terms ⇒ (XY ) ∈ CL-terms

where

V : Set of variables
C = {I, K, S, . . . } : Set of atomic constants

FV(X): The set of variables occurring in X.


Definition (atoms, basic combinators and combinator)
An atom is a variable or atomic constant. The basic combinators are I, K
and S. A combinator is a CL-term whose only atoms are basic combinators.
Combinatory Logic 25/106
Introduction
Definition (substitution [U/x]Y )
The result of substituting U for every occurrence of x in Y :

[U/x]x ≡ U
[U/x]a ≡ a for all atoms a 6≡ x
[U/x](V W ) ≡ ([U/x]V [U/x]W )

Combinatory Logic 26/106


Weak Reduction
Definition (weak redex)
The CL-terms IX, KXY and SXY Z.

Definition (weak contraction (U .1w V ))


Replace an occurrence of a weak redex in U using:

IX by X,
KXY by X,
SXY Z by XZ(Y Z).

Definition (weak reduction (U .w V ))


U is changed to V by a finite (perhaps empty) series of weak contractions.

Definition (weak normal form)


A CL-term which contains no weak redex.
Combinatory Logic 27/106
Weak Reduction
Example
Let B ≡ S(KS)K. Then BXY Z .w X(Y Z) (whiteboard).

Example
Let W ≡ SS(KI). Then
i) WXY .w XY Y and
ii) WWW .w WWW .w · · ·

Combinatory Logic 28/106


Weak Reduction
Theorem (substitution theorem for .w )

X .w Y ⇒ [U/x]X .w [U/x]Y.

Theorem (Church-Rosser theorem for .w )


P .w M P .w N
∃ T.M .w T ∧ N .w T

Corollary (uniqueness of nf)


A CL-term can have at most one weak normal form.

Combinatory Logic 29/106


Abstraction
Idea
To define a term [x].M such that

([x].M )N .w [N/x]M.

Definition (abstraction)
For every term M and every variable x

[x].M ≡ KM if x 6∈ FV(M ) (1)


[x].x ≡ I (2)
[x].U x ≡ U if x 6∈ FV(U ) (3)
[x].U V ≡ S([x].U )([x].V ) if neither (1) nor (3) applies (4)

Example
[x].xy ≡ SI(Ky) (whiteboard).
Combinatory Logic 30/106
Abstraction
Theorem
For every term M and every variable x, [x].M is always defined, does not
contain x and ([x].M )x .w M .

Proof.
Whiteboard.
Theorem
For every term M and every variable x,

([x].M )N .w [N/x]M.

Notation
[x1 , x2 , . . . , xn ].M ≡ [x1 ].([x2 ].(. . . ([xn ].M ) . . . )).

Example
[x, y].xyy ≡ SS(KI) ≡ W (whiteboard).
Combinatory Logic 31/106
Weak Equality
Definition (weak equality or weak convertibility (X =w Y ))
Exist X0 , . . . , Xn such that
i) X0 ≡ X
ii) Xn ≡ Y
iii) (∀i ≤ n − 1)(Xi .1w Xi+1 ∨ Xi+1 .1w Xi )

Theorem (Church-Rosser theorem for =w )


X =w Y
∃ T.X .w T ∧ Y .w T

Corollary
If X and Y are distinct weak normal forms, them X 6=w Y ; in particular
S 6=w K. Hence =w is non-trivial in the sense that not all terms are weakly
equal.

Combinatory Logic 32/106


Weak Equality
About the ‘weak’ adjective

X =β Y ⇒ λx.X =β λx.Y,
but
X =w Y 6⇒ [x].X =w [x].Y.

Example
Let X ≡ Sxyz and Y ≡ xz(yz). Then X =w Y , but [x].X 6=w [x].Y ,
where

[x].X ≡ S(SS(Ky))(Kz),
[x].Y ≡ S(SI(Kz))(K(yz)).

Combinatory Logic 33/106


The Power of λ
Introduction

Notation Meaning for λ Meaning for CL


term λ-term CL-term
X≡Y X ≡α Y X is identical to Y
X .β,w Y X .β Y X .w Y
X =β,w Y X =β Y X =w Y
λx λx [x]

The Power of λ and Combinators 35/106


The Fixed-Point Theorem
Idea
For every term X there is a term P such

XP =β,w P.

The term P is called a fixed-point of X.

Theorem (fixed-point theorem)


There is a combinator Y such that for every term X
1. YX =β,w X(YX).
2. YX .β,w X(YX).

Proof.
YTuring ≡ U U , where U ≡ λux.x(uux) (whiteboard).

The Power of λ and Combinators 36/106


The Fixed-Point Theorem
Corollary
For every term Z and n ≥ 0, the equation

xy1 . . . yn = Z

can be solved for x. That is, there is a term X such that

Xy1 . . . yn =β,w [X/x]Z.

Proof.
X ≡ Y(λxy1 . . . yn .Z) (whiteboard).

Definition (fixed-point combinator)


A fixed-point combinator is any combinator Y such Y X =β,w X(YX), for
all terms X.

The Power of λ and Combinators 37/106


The Fixed-Point Theorem
Example
YCurry-Rosenbloom ≡ λx.V V , where V ≡ λy.x(yy) is a fixed-point
combinator. (Whiteboard)

The Power of λ and Combinators 38/106


Böhms’s Theorem
Definition (η-redex)
In λ-calculus, a λ-term of form λx.M x with x 6∈ FV(M ) is called an η-redex
and is said to η-contract to M .

Definition (βη-normal forms)


In λ-calculus, a λ-term which contains no β-redex and no η-redex.
βη-nf: The set of all βη-normal forms.

Example
The λ-term λux.ux is in β-nf but not in βη-nf.

The Power of λ and Combinators 39/106


Böhms’s Theorem
Definition (strong normal forms)
In CL, the class of strong nf is defined inductively by
All atoms other than I, K and S are in strong nf.
If X1 , . . . , Xn are in strong nf, and a is any atom 6≡ I, K, S, then
aX1 . . . Xn is in strong nf.
If X is in strong nf, then so is [x].X.

The Power of λ and Combinators 40/106


Böhms’s Theorem
Theorem (Böhms’s theorem)
Let M and N be combinators, either in βη-normal form (in λ) or in strong
normal form (in CL). If M 6≡ N , then there exists n ≥ 0 and combinators
L1 , . . . , Ln such that

M L1 . . . Ln xy .β,w x,
N L1 . . . Ln xy .β,w y.

Corollary
Let M and N be distinct combinators in βη-normal form (in λ) or in strong
normal form (in CL). If we add the equation M = N as a new axiom to
the definition =β or =w , then all terms become equal.

Proof.
Whiteboard.
The Power of λ and Combinators 41/106
Leftmost-Reduction
Idea
Proving that a given term has no normal form.

Definition (contraction (X .R Y ) )
(X .R Y ): R is an redex in X and Y is the result of contracting R in X.

Example
(λx.(λy.yx)z)v .(λy.yx)z (λx.zx)v.

Definition (reduction)
A reduction ρ is

CL : X1 .R1 X2 .R2 . . .
λ: X1 .R1 Y1 ≡α X2 .R2 . . .

The Power of λ and Combinators 42/106


Leftmost-Reduction
Definition
Length of a reduction: The number of its contractions.
Terminus: The last term of a reduction of length finite.
A reduction ρ has maximal length iff either ρ is infinite or its terminus
contains no redexes.
A redex is called maximal iff it is not contained in any other redex.
It is left-most maximal iff it is the leftmost of the maximal redexes.
Left-most reduction: In every contraction, the contracted redex is the left-
most maximal.

The Power of λ and Combinators 43/106


Leftmost-Reduction
Example
Let X ≡ S(I(Kxy))(Iz).
Redexes: I(Kxy), Kxy, Iz.
Maximal redexes: I(Kxy), Iz.
Leftmost redex: I(Kxy).
Leftmost reduction:

S(I(Kxy))(Iz) .1w
S(Kxy)(Iz) .1w
Sx(Iz) .1w
Sxx

Theorem (left-most reduction theorem)


If a term X has a normal form X ∗ , then the leftmost reduction of X is
finite and ends at X ∗ .
The Power of λ and Combinators 44/106
Representing the Computable
Functions
Representability
Definition
Let X, Y be λ-terms or CL-terms. Then

X 0 Y ≡ Y,
X n+1 Y ≡ X(X n Y ).

Definition (Church numerals)

For λ: n ≡ λxy.xn y,
For CL: n ≡ (SB)n (KI) (B ≡ S(KS)K).

Representing the Computable Functions 46/106


Representability
Definition (representability)
Let ϕ be a partial function ϕ : Nm → N. A term X represents ϕ iff

ϕ(n1 , . . . , nm ) = p ⇒ Xn1 . . . nm =β,w p,


ϕ(n1 , . . . , nm ) does not exist ⇒ Xn1 . . . nm has no nf.

Representing the Computable Functions 47/106


Representability
Example
The successor function σ(n) = n + 1 is represented by

In λ: σ ≡ λuxy.x(uxy) (whiteboard)
In CL: σ ≡ SB

Definition (conditional operator)

D ≡ λxyz.z(Ky)x
For all X, Y

DXY 0 =β,w X (whiteboard)


DXY k + 1 =β,w Y (whiteboard)

DXY n is called if n = 0 then X, else Y .

Representing the Computable Functions 48/106


Recursion Using Fixed-Points
Example (informal)
(From: Peyton Jones [1987])

fac ≡ λn.if n = 0 then 1 else n ∗ fac (n − 1)


fac ≡ λn.(. . . fac . . . )
fac ≡ (λf n.(. . . f . . . ))fac

h ≡ λf n.(. . . f . . . ) (not recursive!)


fac ≡ h fac (fac is a fixed-point of h!)

fac ≡ Yh

Representing the Computable Functions 49/106


Recursion Using Fixed-Points
Example (cont.)

fac 1 ≡ Yh 1
=β,w h(Yh) 1
≡ (λf n.(. . . f . . . ))(Yh) 1
.β,w if 1 = 0 then 1 else 1 ∗ (Yh 0)
.β,w 1 ∗ (Yh 0)
=β,w 1 ∗ (h(Yh) 0)
≡ 1 ∗ ((λf n.(. . . f . . . ))(Yh)0)
.β,w 1 ∗ (if 0 = 0 then 1 else 1 ∗ (Yh (−1)))
.β,w 1 ∗ 1
.β,w 1

Representing the Computable Functions 50/106


Representing the Computable Functions
Theorem (representation of Turing-computable functions)
In λ or CL every Turing-computable function can be represented by a com-
binator.

Representing the Computable Functions 51/106


The Formal Theories λβ and CLw
The Definitions of the Theories
Definition (λβ, formal theory of β-equality)
Formulas: M = N , where M, N ∈ λ-terms.
Axiom-schemes:

(α) λx.M = λy.[y/x]M if y ∈ FV(M ),


(β) (λx.M )N = [N/x]M,
(ρ) M = M.

Rules of inference:

(µ) M = M0
NM = NM0 M = M 0 (τ ) M = N N =P
(ξ) M = P
M = M0 λx.M = λx.M 0
(ν)
M N = M 0N (σ) M = N
N =M

The Formal Theories λβ and CLw 53/106


The Definitions of the Theories
Definition (λβ, formal theory of β-equality)
Deductions: λβ, A1 , . . . , An ` B (There is a deduction of B from the
assumptions A1 , . . . , An in λβ).
Theorems: λβ ` B (The formula B is probable in λβ).

The Formal Theories λβ and CLw 54/106


The Definitions of the Theories
Example
Let M and N be two closed terms

(λx.(λy.x))M = [M/x]λy.x ≡ λy.M


(ν)
(λx.(λy.x))M N = (λy.M )N (λy.M )N = [N/y]M ≡ M

(λx.(λy.x))M N = M
That is to say, λβ ` (λxy.x)M N = M .

Remark
λβ is a equational theory and it is a logic-free theory (there are not logical
connectives or quantifiers in its formulae).

The Formal Theories λβ and CLw 55/106


The Definitions of the Theories
Definition (λβ, formal theory of β-reduction)
(Similar to the formal theory of β-equality, but:
1. Formulas: M .β N .
2. To change ‘=’ by ‘.β .
3. Remove the rule (σ).)

Formulas: M .β N , where M, N ∈ λ-terms.


Axiom-schemes:

(α) λx.M .β λy.[y/x]M if y ∈ FV(M ),


(β) (λx.M )N .β [N/x]M,
(ρ) M .β M.

The Formal Theories λβ and CLw 56/106


The Definitions of the Theories
Definition (λβ, formal theory of β-reduction)
Rules of inference:

M .β M 0 M .β M 0
(µ) (ξ)
N M .β N M 0 λx.M .β λx.M 0

M .β M 0 M .β N N .β P
(ν) (τ )
M N .β M 0 N M .β P

Theorem

M .β N ⇐⇒ λβ ` M .β N,
M =β N ⇐⇒ λβ ` M = N.

The Formal Theories λβ and CLw 57/106


The Definitions of the Theories
Definition (CLw, formal theory of weak equality)
Formulas: M = N , where M, N ∈ CL-terms
Axiom-schemes:

(I) IX = X,
(K) KXY = X,
(S) SXY Z = XZ(Y Z),
(ρ) X = X.

Rules of inference: The same rules than the theory λβ except the rule (ξ).
Deductions: CLw, A1 , . . . , An ` B.
Theorems: CLw ` B.

The Formal Theories λβ and CLw 58/106


The Definitions of the Theories
Definition (CLw, formal theory of weak reduction)
Similar to the formal theory of β-reduction.

Theorem

M .w N ⇐⇒ CLw ` M .w N,
M =w N ⇐⇒ CLw ` M = N.

The Formal Theories λβ and CLw 59/106


Equivalence of Theories
T : Theory
F: Formulas of T
Rule of inference R(ϕ): Given by a partial function ϕ : F n → F
Instance of R(ϕ):

A1 , . . . , A n
B

The Formal Theories λβ and CLw 60/106


Equivalence of Theories
Notation
T , T 0 : Theories with the same formulas
R: Inference rule
C: Formula

Definition (derivable rules)


R is derivable in T iff for each instance of R (with premises A1 , . . . , An
and conclusion B)
T , A1 , . . . , An ` B.

Definition (admissible rules)


R is admissible in T iff adding R to T as a new rule will not increase the
set of theorems of T .

Definition (derivable and admissible formula)

T ` C.
The Formal Theories λβ and CLw 61/106
Equivalence of Theories
Theorem
If R is derivable in T , then R is admissible in T . The implication in the
opposite direction does not hold in general.

Definition (theories theorem-equivalent)


T and T 0 are theorem-equivalent iff every rule and axiom of T is admissible
in T 0 and vice-versa.

Definition (theories rule-equivalent)


T and T 0 are rule-equivalent iff every rule and axiom of T is derivable in T 0
and vice-versa.

The Formal Theories λβ and CLw 62/106


Equivalence of Theories
Definition (equality relation determined by a theory)
T : Formal theory with some equations X = Y .
The equality relation determined by T is =T is:

X =T Y ⇐⇒ T ` X = Y.

The Formal Theories λβ and CLw 63/106


Extensionality in Lambda Calculus
Extensional Equality
For functions: ∀x (f (x) = g(x)) ⇒ f = g.
For programs: It two programs compute the same function, are they
the same program?

Theorem
The theory λβ is not extensional.

Proof.
Let F ≡ y and G ≡ λx.yx. Then for all X

λβ ` F X = GX,

but
λβ 6` F = G.

Extensionality in Lambda Calculus 65/106


Extensional Equality
Rule and axiom-scheme to express extensionality

(ζ) Mx = Nx if x 6∈ FV(M N ),
M =N
(η) λx.M x = M if x 6∈ FV(M ).

Definition (theories λβζ and λβη)

λβζ :λβ + (ζ),


λβη :λβ + (η).

Extensionality in Lambda Calculus 66/106


Extensional Equality
Theorem
The theories λβζ and λβη are rule-equivalents.

Proof.
1. (ζ) is derivable in λβη, i.e.
λβη, M x = N x ` M = N (with x 6∈ FV(M N )). (Whiteboard).
2. (η) is derivable in λβζ, i.e.
λβζ ` λx.M x = M (with x 6∈ FV(M )). (Whiteboard).

Definition (extensional equality in λ)

M =λext N ⇐⇒ λβζ ` M = N.

Extensionality in Lambda Calculus 67/106


Beta-Eta Reduction in Lambda Calculus
Definition (η-redex and contractum)
An η-redex is any λ-term λx.M x with x 6∈ FV(M ). Its contractum is M .

Definition (η-contraction (P .1η Q))


Replace an occurrence of a η-redex in P by its contractum.

Definition (η-reduction (P .η Q))


P is changed to Q by a finite (perhaps empty) series of η-contractions and
α-conversions.

Extensionality in Lambda Calculus 68/106


Beta-Eta Reduction in Lambda Calculus
Definition (βη-redex)
An βη-redex is a β-redex or an η-redex.

Definition (βη-contraction (P .1βη Q))


Replace an occurrence of a βη-redex in P by its contractum.

Definition (βη-reduction (P .βη Q))


P is changed to Q by a finite (perhaps empty) series of βη-contractions and
α-conversions.

Extensionality in Lambda Calculus 69/106


Beta-Eta Reduction in Lambda Calculus
Definition (βη-normal forms)
A λ-term which contains no βη-redex.

Theorem (Church-Rosser theorem for .βη )


P .βη M P .βη N
∃ T.M .βη T ∧ N .β T

Theorem (relation between .βη and =λext )


P =λext Q iff Q can be obtained from P by a finite (perhaps empty) series
of βη-contractions and reversed βη-contractions and α-conversions.

Extensionality in Lambda Calculus 70/106


Beta-Eta Reduction in Lambda Calculus
Theorem (Church-Rosser theorem for =λext )
P =λext Q
∃ T.P .βη T ∧ Q .βη T

Corollary
The relation =λext is non-trivial (not all terms are βη-convertible to each
other).

Extensionality in Lambda Calculus 71/106


Extensionality in Combinatory
Logic
Extensional Equality
Theorem
The theory CLw is not extensional.

Proof.
Let X ≡ S(Ku)I and Y ≡ u, then for all M

CLw ` XM = Y M,

but
CLw 6` X = Y.

Extensionality in Combinatory Logic 73/106


Extensional Equality
Rule and axiom-scheme to express extensionality

(ζ) Xx = Y x if x 6∈ FV(XY ),
X=Y

(ξ) X=Y
[x].X = [x].Y
(η) [x].U x = U if x 6∈ FV(U ).

Definition (theories CLζ and CLξ)

CLζ : CL + (ζ),
CLξ : CL + (ξ).

Exercise
Probe that neither (ζ) nor (ξ) is admissible in CLw. (Whiteboard).
Extensionality in Combinatory Logic 74/106
Extensional Equality
Definition (extensional equality in CL)

X =Cext Y ⇐⇒ CLζ ` X = Y.

Example
SK =Cext KI. (Whiteboard).

Extensionality in Combinatory Logic 75/106


Extensional Equality
Theorem
The theory CLξ determines the same equality-relation =Cext as CLζ does.

Proof.
1. (ζ) is derivable in CLξ, i.e.
CLξ, Xx = Y x ` X = Y (with x 6∈ FV(XY )). (Whiteboard).
2. (ξ) is derivable in CLζ, i.e.
CLζ, X = Y ` [x].X = [x].Y . (Whiteboard).

Extensionality in Combinatory Logic 76/106


Axioms for Extensionality in CL
Definition (formal theory CLextax )
CLextax : CLw + E-ax 1 + · · · + E-ax 5, where
E-ax 1. S(S(KS)(S(KK)(S(KS)K))) = S(KK)
E-ax 2. S(S(KS)K)(KI) = I
E-ax 3. S(KI) = I
E-ax 4. S(KS)(S(KK)) = K
E-ax 5. S(K(S(KS)))(S(KS)(S(KS))) =
S(S(KS)(S(KK)(S(KS)(S(K(S(KS)))S))))(KS)

Extensionality in Combinatory Logic 77/106


Axioms for Extensionality in CL
Definition (other version of E-ax 1, . . . , E-ax 5)
E-ax 1. [x, y, v]. (Kxv)(Kyv) = [x, y, v].xy
E-ax 2. [x, v]. (Kxv)(Iv) = [x, v].xv
E-ax 3. [x, v]. I(xv) = [x, v].xv
E-ax 4. [x, y, v]. K(xv)(yv) = [x, y, v].xv
E-ax 5. [x, y, z, v]. S(xv)(yv)(zv) = [x, y, z, v].xv(zv)(yv(zv))

Motivation
We are looking axioms which will make (ξ) admissible in CLextax :

CLextax ` X = Y =⇒ CLextax ` [x].X = [x].Y.

Theorem
The theory CLextax is theorem-equivalent to CLξ.
Extensionality in Combinatory Logic 78/106
Strong Reduction
Definition (strong reduction  )
The formal theory of strong reduction:
Formulas: X  Y , where X, Y ∈ CL-terms
Axiom-schemes and rules: The same than CLw changed ‘=’ by ‘  ’ and
the rule (σ) omitted.
New rule added:

(ξ) X Y
[x].X  [x].Y

Example
SK  KI. (Whiteboard).

Extensionality in Combinatory Logic 79/106


Strong Reduction
Theorem (Church-Rosser theorem for  )
U X U Y
∃ Z.X  Z ∧ Z  Y

Definition (strong irreducibility)


X is called strongly irreducible iff, for all Y

X  Y =⇒ Y ≡ X.

Theorem
The strongly irreducible CL-terms are exactly the terms in the strong nf
class.

Extensionality in Combinatory Logic 80/106


Models of CL
Applicative Structures
Definition (valuation)
Let D a set. A valuation is a mapping ρ : Vars → D.
(
ρ(y), if y 6= x;
Notation: [d/x]ρ =
d, otherwise.

Definition (applicative structure)


An applicative structure is a structure hD, ·i where
1. |D| ≥ 2.
2. · : D2 → D.

Models of CL 82/106
Combinatory Algebras
Definition (combinatory algebra)
A combinatory algebra is a structure (convention: association to the left
for ·) D = hD, ·i where
1. |D| ≥ 2.
2. · : D2 → D.
3. There are two elements k, s ∈ D such that for all a, b, c ∈ D,

k · a · b = a, (5)
s · a · b · c = a · c · (b · c). (6)

Models of CL 83/106
Combinatory Algebras
Definition (model of CLw)
A model of CLw is a structure hD, ·, i, k, si where
1. hD, ·i is a combinatory algebra.
2. The elements k and s satisfy (5) and (6).
3. The element i satisfies i = s · k · k.

Definition (model of CLextax )


A model of CLextax is a model hD, ·, i, k, si of CLw that satisfies the
extensionality axioms E-ax 1, . . . , E-ax 5.

Models of CL 84/106
Combinatory Algebras
Definition (interpretation of a term)
Let D = hD, ·, i, k, si where hD, ·i is a combinatory algebra and ρ a valua-
tion. The interpretation of X in D under ρ, denoted JXKD ρ , is defined by

JXKD
ρ : CL-term → D
JxKD
ρ = ρ(x),
JIKD
ρ = i,
JKKD
ρ = k,
JSKD
ρ = s,
JXY KD D D
ρ = JXKρ · JY Kρ .

Models of CL 85/106
Combinatory Algebras
Definition (satisfaction)

D, ρ |= X = Y ⇐⇒ JXKD D
ρ = JY Kρ ,
D |= X = Y ⇐⇒ (∀ρ)(D, ρ |= X = Y ).

Models of CL 86/106
Combinatory Algebras
Example (term model)
Let T ∈ {CLw, CLextax }. For each CL-term X,

[X] = {Y : T ` X = Y }.

The TM(T ) (the term model of T ) is hD, ·, i, k, si where

D = {[X] : X is a CL-term},
[X] · [Y ] = [XY ],
i = [I],
k = [K],
s = [S].

Models of CL 87/106
Combinatory Algebras
Example (cont.)
In this model, interpretation is the same as substitution

JXKρ = [[Y1 /x1 , . . . , Yn /xn ]X],

where

FV(X) = {x1 , . . . , xn },
∀xi ∈ FV(X).ρ(xi ) = Yi .

Models of CL 88/106
Combinatory Algebras
Theorem (submodel theorem)
Let T ∈ {CLw, CLextax }. If hD, ·, i, k, si is a model of T and D0 is a subset
of D which contains i, k and s and is closed under ·, then hD0 , ·, i, k, si is a
model of T .

Definition (interiors)
Let T ∈ {CLw, CLextax } and D = hD, ·, i, k, si a model of T . The interior
of D is
D◦ = {JXK : X closed}.

Theorem (interiors)
Let T ∈ {CLw, CLextax }. The interior of a model of T is also a model
of T .

Models of CL 89/106
Models of Lambda Calculus
The Definition of Lambda Model
Definition (λ-model)
A λ-model is a triple D = hD, ·, J Ki where
1. hD, ·i is an applicative structure.
2. J K : λ-terms → D is a mapping such that for each valuation ρ

JxKρ = ρ(x),
JP QKρ = JP KD
ρ · JQKρ .
Jλx.P Kρ · d = JP K[d/x]ρ , for all d ∈ D,
JM Kρ = JM Kσ if ∀x ∈ FVM.ρ(x) = σ(x),
Jλx.P Kρ = Jλy.[y/x]P Kρ if y 6∈ FV(M ),

If (∀d ∈ D)(JP K[d/x]ρ = JQK[d/x]ρ ) then Jλx.P Kρ = Jλx.QKρ .

Models of Lambda Calculus 91/106


The Definition of Lambda Model
Theorem
Every λ-model satisfies all the provable equations if the formal theory λβ.

Models of Lambda Calculus 92/106


The Definition of Lambda Model
Definition (models of λβη)
A model of λβη is a λ-model that satisfies the equation λx.M x = M for
all terms M and all x ∈
/ FV(M ).

Models of Lambda Calculus 93/106


The Definition of Lambda Model
Example (term models)
Let T ∈ {λβ, λβη}. For each λ-term M ,

[M ] = {N : T ` M = N }.

The TM(T ) (the term model of T ) is hD, ·, J Ki where

D = {[M ] : M is a λ-term},
[P ] · [Q] = [P Q],
JM Kρ = [[N1 /x1 , . . . , Nn /xn ]M ],

where

FV(M ) = {x1 , . . . , xn },
∀xi ∈ FV(M ).ρ(xi ) = Ni .

Models of Lambda Calculus 94/106


Scott’s D∞ : Complete Partial Orders
The problem
“In the λ-calculus the objects serve both as arguments and as
functions to be applied to these arguments. Therefore one would
like that a semantics for λ-calculus consist of a domain D such that
its function space DD is isormorphic to D. By Cantor’s theorem
this is impossible”. [Barendregt 2004, p. 86]

Scott’s solution
D∞ : complete partial order
[D∞ → D∞ ]: continuous
functions (under the Scott’s
topology)
D∞ ∼= [D∞ → D∞ ].

Models of Lambda Calculus 95/106


Scott’s D∞ : Complete Partial Orders
Definition (partially ordered sets (poset))
A poset is a structure hD, vi where D is a set and v: D2 → D is transitive,
anti-symmetric, and reflexive.
Let hD, vi a poset and let X ⊆ D.

Definition (upper bound)


An upper bound (u.b) of X is any b ∈ D such

∀a ∈ X.a v b.

Definition (least upper bound (l.u.b.) (or supremum))


F
The l.u.b. of X called X, it is an upper bound b of X such

∀c ∈ D.c is a u.b. of X =⇒ b v c.

Models of Lambda Calculus 96/106


Scott’s D∞ : Complete Partial Orders
Definition (bottom)
D has an element called bottom (denoted ⊥) iff

∀x ∈ D.⊥ v x.

Definition (directed sets)


Let hD, vi a poset. A subset X ⊆ D is said to be directed iff X 6= ∅ and

∀a, b ∈ X.∃c ∈ X.a v c ∧ b v c.

Definition (complete partial orders, c.p.o.s)


A c.p.o. is a poset hD, vi such that
1. D has a ⊥.
2. Every direct subset X ⊆ D has a l.u.b.

Models of Lambda Calculus 97/106


Scott’s D∞ : Complete Partial Orders
Definition (set N+ )

N+ = N ∪ {⊥} (⊥ 6∈ N),
+
∀a, b ∈ N .a v b ⇐⇒ (a = ⊥ ∧ b ∈ N) ∨ a = b.

0 1 2 3 ...

Motivation
The element ⊥ represents an undefined value (partial functions).
a v b represents that b “is more defined” than a or both are equals
(semantic approximation order).
Models of Lambda Calculus 98/106
Scott’s D∞ : Complete Partial Orders
Let hD, vi and hD0 , v0 i be c.p.o.s and ϕ a function ϕ : D → D0 .

Definition (monotonicity)
The function ϕ is monotonic iff

a v b =⇒ ϕ(a) v0 ϕ(b).

Example
Let ϕ : N+ → N+ be a monotonic function. If ϕ(⊥) = 1 then ϕ is a
constant function, i.e. ∀n ∈ N+ .ϕ(n) = 1.

Models of Lambda Calculus 99/106


Scott’s D∞ : Complete Partial Orders
Definition (continuity)
The function ϕ is continua iff, for all directed X ⊆ D
G  G
ϕ X = (ϕ(X)),

where

ϕ(X) = {ϕ(a) : a ∈ X}.

Models of Lambda Calculus 100/106


Scott’s D∞ : Complete Partial Orders
Definition (function-set [D → D0 ])
[D → D0 ]: For c.p.o.s hD, vi and hD0 , v0 i, the set of all continuous func-
tions.
For ϕ, ψ ∈ [D → D0 ], we define

ϕ v ψ ⇐⇒ ∀d ∈ D.ϕ(d) v0 ψ(d).

Theorem
The function ∀d ∈ D.⊥(d) = ⊥0 is the bottom of [D → D0 ].

Theorem
[D → D0 ] is a c.p.o.

Models of Lambda Calculus 101/106


Scott’s D∞ : The Construction
Definition (sequence D0 , D1 , . . . )

D0 = N+ ,
Dn+1 = [Dn → Dn ].

Theorem
Every Dn is a c.p.o.

Models of Lambda Calculus 102/106


Scott’s D∞ : The Construction
Example
From:
http://en.wikibooks.org/wiki/Haskell/Denotational_semantics
The factorial function

f (n) = if n == 0 then 1else n · f (n − 1)

Approximations of the factorial function

fk+1 (n) = if n == 0 then 1 else n · fk (n − 1)

Models of Lambda Calculus 103/106


Scott’s D∞ : The Construction
Example (cont.)
(
1 if n is 0
f0 (n) = ⊥ , f1 (n) = ,
⊥ else


 1 if n is 0
1 if n is 0


 
1 if n is 1
f2 (n) = 1 if n is 1 , f3 (n) = , ...
 2 if n is 2
⊥ else
 


⊥ else

Then, ⊥= f0 v f1 v f2 v . . . .
The idea is
G
∀n. (f0 (n) v f1 (n) v f2 (n) v . . . ) = f (n).

Models of Lambda Calculus 104/106


Scott’s D∞ : The Construction
About the λ-model hD∞ , ·, J Ki
D∞ cannot be a set of functions (no function can be applied to
itself).
Scott’s idea:
Members of D∞ are infinite sequences of functions

ϕ = hϕ0 , ϕ1 , ϕ2 , . . .i, where ϕn ∈ Dn .

Application
ϕ · ψ = hϕ1 (ψ0 ), ϕ2 (ψ1 ), . . .i
Self-application

ϕ · ϕ = hϕ1 (ϕ0 ), ϕ2 (ϕ1 ), . . .i

Models of Lambda Calculus 105/106


References
Barendregt, H. P. (2004). The Lambda Calculus. Its Syntax and Semantics.
Revised edition, 6th impression. Vol. 103. Studies in Logic and the
Foundations of Mathematics. Elsevier (cit. on pp. 3, 95).
Barendregt, Henk and Barendsen, Erik (2000). Introduction to Lambda
Calculus. Revisited edition, Mar. 2000 (cit. on p. 3).
Hindley, J. R. and Seldin, J. (2008). Lambda-Calculus and Combinators. An
Introduction. Cambridge University Press (cit. on pp. 3, 4).
Peyton Jones, Simon L. (1987). The Implementation of Functional
Programming Languages. Prentice-Hall International (cit. on p. 49).

You might also like