Save
Lambda Calculus
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Dewey Duey
Visit profile
Cards (58)
lambda calculus is a fully expressive (Turing
complete
) language of
computable
functions
definition of
λ
\lambda
λ
-terms:
M
:
:
=
M ::=
M
::=
x
∣
λ
.
x
∣
M
M
x | \lambda.x|MM
x
∣
λ
.
x
∣
MM
where x is a
variable
,
λ
.
x
\lambda.x
λ
.
x
is an
abstraction
, MN is the
application
of function M to argument N .
redex means
reducible expression
, which can be reduced within a term, ie
(
λ
x
.
M
)
N
(\lambda x.M)N
(
λ
x
.
M
)
N
free variable: a variable that is
not bound
to any other variable in the program
bound variable: a variable that is
used
in a calculation but is not
stored
in memory
alpha-conversion
: how to rename variables
This technique is used to avoid variable capture
ie M
[
y
/
x
] is “
M
with
x
renamed to
y
”
β
\beta
β
-reduction:
Substitution
of terms
Proof
by Induction
(To prove that something ( P ) holds for every lambda-term N)
Base case: P holds for
x
Inductive step 1: if P holds for N , then it holds for
λx.N
.
Inductive step 2: prove it holds for MN
Church’s
thesis: A function of positive integers is computable if and only if
lambda-definable
Turing’s
thesis: Something is computable if and only if a
Turing Machine
can compute it.
Turing shows
: Something is
lambda-definable
if and only if a Turing Machine can compute it
True
t
r
u
e
≜
λ
x
.
λ
y
.
x
,
f
a
l
s
e
≜
λ
x
.
λ
y
.
y
true≜\lambda x.\lambda y.x, false≜\lambda x.\lambda y.y
t
r
u
e
≜
λ
x
.
λ
y
.
x
,
f
a
l
se
≜
λ
x
.
λ
y
.
y
if...then...else...
i
f
t
h
e
n
e
l
s
e
≜
λ
b
.
λ
x
.
λ
y
.
b
x
y
ifthenelse≜\lambda b. \lambda x. \lambda y. bxy
i
f
t
h
e
n
e
l
se
≜
λb
.
λ
x
.
λ
y
.
b
x
y
Conjunction (and):
λ
b
1
.
λ
b
2
.
i
f
t
h
e
n
e
l
s
e
\lambda b_1.\lambda b_2.ifthenelse
λ
b
1
.
λ
b
2
.
i
f
t
h
e
n
e
l
se
b
1
b
2
f
a
l
s
e
b_1b_2false
b
1
b
2
f
a
l
se
Disjunction (or):
λ
b
1
.
λ
b
2
.
i
f
t
h
e
n
e
l
s
e
\lambda b_1.\lambda b_2.ifthenelse
λ
b
1
.
λ
b
2
.
i
f
t
h
e
n
e
l
se
b
1
t
r
u
e
b_1true
b
1
t
r
u
e
b
2
b_2
b
2
Church numerals:
0
≜
λ
f
.
λ
x
.
x
0≜\lambda f.\lambda x.x
0
≜
λ
f
.
λ
x
.
x
1
≜
λ
f
.
λ
x
.
f
x
1≜\lambda f.\lambda x.fx
1
≜
λ
f
.
λ
x
.
f
x
2
≜
λ
f
.
λ
x
.
f
(
f
x
)
2≜\lambda f.\lambda x.f(fx)
2
≜
λ
f
.
λ
x
.
f
(
f
x
)
...
successor
s
u
c
c
≜
λ
n
.
λ
f
.
λ
x
.
f
(
n
f
x
)
succ≜\lambda n.\lambda f.\lambda x.f(nfx)
s
u
cc
≜
λn
.
λ
f
.
λ
x
.
f
(
n
f
x
)
preceder
p
r
e
d
≜
λ
n
.
λ
f
.
λ
x
.
n
(
λ
g
.
λ
h
.
h
(
g
f
)
)
(
λ
u
.
x
)
(
λ
u
.
u
)
pred≜\lambda n.\lambda f.\lambda x.n(\lambda g.\lambda h.h(gf))(\lambda u.x)(\lambda u.u)
p
re
d
≜
λn
.
λ
f
.
λ
x
.
n
(
λ
g
.
λh
.
h
(
g
f
))
(
λ
u
.
x
)
(
λ
u
.
u
)
fixed point
for F is a λ-term M such that
M
=
M=
M
=
β
F
M
_\beta FM
β
FM
Y-combinator:
Y
≜
λ
f
.
(
λ
x
.
f
(
x
x
)
)
(
λ
x
.
f
(
x
x
)
)
Y≜\lambda f.(\lambda x.f(xx))(\lambda x.f(xx))
Y
≜
λ
f
.
(
λ
x
.
f
(
xx
))
(
λ
x
.
f
(
xx
))
multiply
m
u
l
≜
λ
m
.
λ
n
.
λ
f
.
λ
x
.
m
(
n
f
)
x
mul≜\lambda m.\lambda n.\lambda f.\lambda x.m(nf)x
m
u
l
≜
λm
.
λn
.
λ
f
.
λ
x
.
m
(
n
f
)
x
exponentiation
e
x
p
≜
λ
m
.
λ
n
.
λ
f
.
λ
x
.
n
m
f
x
exp≜\lambda m.\lambda n.\lambda f.\lambda x.nmfx
e
x
p
≜
λm
.
λn
.
λ
f
.
λ
x
.
nm
f
x
Y-combinator exploits
self-application
to deliver
fixed points
Types for λ-terms:
τ
:
:
=
\tau ::=
τ
::=
o
∣
τ
→
τ
o | \tau \to \tau
o
∣
τ
→
τ
o is a
fixed type
called the
base case
Types for λ-terms are
right-associative
simply-typed
lambda-calculus:
M
:
:
=
M::=
M
::=
x
∣
λ
x
τ
.
x
∣
M
M
x|\lambda x^{\tau}.x|MM
x
∣
λ
x
τ
.
x
∣
MM
computation
of simply-typed lambda-calculus:
(
λ
x
τ
.
M
)
N
→
β
M
[
N
/
x
]
(\lambda x^{\tau}.M)N \to_{\beta} M[N/x]
(
λ
x
τ
.
M
)
N
→
β
M
[
N
/
x
]
A (typing)
context
Γ is a
finite
function from variables to types
Γ
=
\Gamma =
Γ
=
x
1
:
τ
1
,
x
2
:
τ
2
,
.
.
.
,
x
n
:
τ
n
x_1:\tau_1, x_2:\tau_2,..., x_n:\tau_n
x
1
:
τ
1
,
x
2
:
τ
2
,
...
,
x
n
:
τ
n
By
Γ
,
x
:
τ
\Gamma, x:\tau
Γ
,
x
:
τ
means the
context
that is the same as
Γ
, but extended so that
x
has type
τ
A (typing)
judgement
Γ
⊢
M
:
τ
\Gamma\vdash M:\tau
Γ
⊢
M
:
τ
says that M has type τ in
context Γ : “if each variable
x
i
x_i
x
i
has type
τ
i
\tau_i
τ
i
then M has type τ
true typing judgements:
Γ
,
x
:
τ
⊢
x
:
τ
\over{\Gamma , x: \tau \vdash x: \tau}
Γ
,
x
:
τ
⊢
x
:
τ
Γ
,
x
:
τ
⊢
M
:
σ
Γ
,
λ
x
τ
.
M
:
τ
→
σ
{\Gamma , x: \tau \vdash M: \sigma}\over{\Gamma , \lambda x^\tau.M: \tau \to\sigma}
Γ
,
λ
x
τ
.
M
:
τ
→
σ
Γ
,
x
:
τ
⊢
M
:
σ
Γ
,
M
:
τ
→
σ
,
Γ
,
M
:
τ
Γ
,
M
N
:
σ
{\Gamma , M: \tau \to\sigma , \space\space\space\space\space\space\space\space\Gamma , M: \tau}\over{\Gamma , MN: \sigma}
Γ
,
MN
:
σ
Γ
,
M
:
τ
→
σ
,
Γ
,
M
:
τ
A term M is
well-typed
if there is a
true judgement
Γ ⊢M : τ
and all
subterms
of M are also
well-typed
addition
a
d
d
≜
λ
m
.
λ
n
.
λ
f
.
λ
x
.
m
f
(
n
f
x
)
add≜\lambda m.\lambda n.\lambda f.\lambda x.mf(nfx)
a
dd
≜
λm
.
λn
.
λ
f
.
λ
x
.
m
f
(
n
f
x
)
Proof by Induction(To prove that something ( P ) holds for every lambda-term N)
Base case: P holds for any
variable
Inductive step 1: if P holds for N, then it holds for
abstraction
Inductive step 2: prove it holds for
application
transitive
closure
→
β
+
\to_\beta ^ +
→
β
+
have
at least one
reduction step
reflexive–transitive
closure
→
β
∗
\to_\beta ^ *
→
β
∗
have reduction steps with
zero
or more
reflexive–transitive–symmetric
closure
=
=
=
R
_R
R
reduction steps can go
forward
or
backwards
An equivalence (relation) or equational theory is a relation that is
reflexive
,
symmetric
, and
transitive.
alpha -equivalence : terms equivalent modulo
variable names
beta -equivalence : terms equivalent modulo
computation
A beta-expansion is a beta-reduction in reverse
Terms M and N are α -equivalent, written M =α N , if N can be obtained from M by renaming bound variables.
See all 58 cards