start with a (infinite) set of variables V=a,b,c,...
λ-Calculus is a set of terms formed according to these three rules
naming :: if x∈V, then x is a term in the λ-Calculus
abstraction :: if T is a term and x∈V, then λx.T is a term
application :: if T1 and T2 are terms, then T1T2 is a term
it’s a model for general computation
application and term rewriting:
for T1T2, when T1 is an abstraction, we allow re-write applications by substituting T2 for x through T1
eg for abstraction select-first, λx.λy.x, its application is like
(λx.λy.xa)b→
(λy.a)b→
a
eg: make-pairλx.λy.λz((zx)y)
when applies to a and b
we got: λz((za)b)
its a term that encodesa and b
it expects an abstraction
Alpha Equivalence: free and bound variables
: bound variables are “placeholders” that can be re-named at will without changing the essential meaning of a term.
in a term, there are 3 categories of variable occurrences
binding: on the left side of . in an abstraction
bound
free: in λx.M, x is bound in M
rules: …
it allows λx.(xλx.x)y to make sense: inner x and outer x are different
the operation of renaming: Mx→y denotes the result of replacing every free occurrence of x in M with y
Beta Reduction
: the process of applying a function (an abstraction) to an argument (another term)
(λx.M)N is called a redex (reducible expression)
rule
: substitute every occurrence of the bound variable x inside the function body M with the argument N
notation for substitution: M[x:=N]
the rule can be written as (λx.M)N→βM[x:=N]
β-normal: when is β-reduction done?
We say that a term M is in β-normal form (β-nf) if M contains no redex, ie, there’s no way to perform beta-reduction to reduce it to a simpler form
Simply Typed Lambda Calculus λ→
:
in addition to ordinary variables V in untyped lambda calculus, we now have another set of type variablesV=α,β,γ,..., and we can define the set of all simple types T as:
if α∈V, then α∈T
if α,τ∈V, then α→τ∈T
we write M:σ for “term M has type σ”
we assume each ordinary variable has an unique type
we denote abstraction more fully as λx:σ.M:σ→τ
context: a collection of type statements x:σ, y:τ, z:υ
judgement: a statement Γ⊢M:σ, where they are a context, a term, and a type respectively
derivation
: we can validate a judgement by derivation
3 derivation rules
var: Γ⊢x:σ if x:σ∈Γ
appl: Γ⊢MN:τΓ⊢M:σ→τΓ⊢N:σ
abst: Γ⊢λx:σ.M:σ→τΓ,x:σ⊢M:τ
Each rule tells us what we can conclude so long as we know certain things
A derivation is collection of applications of these rules, arranged in an inverted tree where the “root”, at the bottom, is the statement we are justifying.
Questions we can ask now:
well-typedness / typability: given a term, is it legal in some context?
type checking: given a judgement, is it true?
term finding: is there a term of the given type in the given context?
previous 2 are decidable, this one is undecidable
under Curry-Howard, term finding is equivalent to proof finding
We can now rule out misbehaving terms. All terms are strongly normalizing as their reduction to normal form is guaranteed to terminate.
downside: it’s not very expressive
Second-order Lambda Calculus - λ2 - Polymorphic Lambda Calculus - System F