Introduction to the Lambda Calculus Alonzo Church 1932, “A set of postulates for the foundation of logic”, a formal system with the aim of providing a foundation for logic which would be more natural than Russell’s type theory or Zermelo’s set theory, and would not contain free variables 1936 Church isolated and published just the portion relevant to computation, what is now called the untyped lambda calculus 1940, he also introduced a computationally weaker, but logically consistent system, known as the simply typed lambda calculus Re-discovered as a versatile tool in Computer Science by people like McCarthy, et al. in the 1960s
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Introduction to the Lambda Calculus
Alonzo Church
1932, “A set of postulates for the foundation of logic”, a formal system with the aim of providing a foundation for logic which would be more natural than Russell’s type theory or Zermelo’s set theory, and would not contain free variables
1936 Church isolated and published just the portion relevant to computation, what is now called the untyped lambda calculus
1940, he also introduced a computationally weaker, but logically consistent system, known as the simply typed lambda calculus
Re-discovered as a versatile tool in Computer Science by people like McCarthy, et al. in the 1960s
representing data and operators in the lambda calculus
Let’s start with the booleans
true = λt. λf. t
false = λt. λf. f
not = λa. a false true
Applying not
(λa. a false true) true
(λa. a false true) (λt. λf. t)
(λt. λf. t) false true
false
(λx.t) v [x v]t↦
(from operational semantic rules)
β-reduction
applying functions to their arguments
Normal order reduction – most well-known languages work from the leftmost, outermost, redex and work in, halting when the outermost argument can no longer be applied
Redex – reducible expression
Full β-reduction – reduce available redexes in any desired order
Full β-reduction
λs.λz. (λs'.λz'. (λb. b) s' ((λt.λb. b) s' z')) s ((λs'.λz'.
(λs''.λz''. (λb. b) s'' ((λt.λb. b) s'' z''))
s' ((λt.λb. b) s' z'))
s z)
Full β-reduction
λs.λz. (λs'.λz'. s' z') s ((λs'.λz'. (λs''.λz''. s'' z'') s' z') s z)
Full β-reduction
λs.λz. s ((λs'.λz'. (λs''.λz''. s'' z'') s' z') s z)
Full β-reduction
λs.λz. s ((λs'.λz'. s' z') s z)
Full β-reduction
λs.λz. s (s z)
Back to the booleans
and = λa. λb. a b fls
or = λa. λb. a tru b
nand = λa. λb. not (and a b)
xor = λa. λb. and (nand a b) (or a b)
cond = λp. λt. λf. p t f /* i.e. if else */
and
(λa. λb. a b fls) tru fls
(λt. λf. t) (λt. λf. f) (λt. λf. f)
λt. λf. f
(λa. λb. a b fls) tru tru
(λt. λf. t) (λt. λf. t) (λt. λf. f)
λt. λf. t
Hooray!
xnor = λa. λb. not (xor a b)
Now we have assertions!
xnor = λa. λb. not (xor a b)
xnor tru (cond fls fls tru)
xnor fls (cond fls tru fls)
Tuples
pair = λf. λs. λb. b f s
fst = λp. p tru
snd = λp. p fls
Numbers
c0 = λs. λz. zc1 = λs. λz. s zc2 = λs. λz. s (s z)c3 = λs. λz. s (s (s z))…
Just like Peano arithmetic
Operations on numbersiszro = λm. m (λx. fls) tru
plus = λm. λn. λs. λz. m s (n s z)mult = λm. λn. m (plus n) c0exp = λm. λn. n (mult m) c1
scc = λn. λs. λz. s (n s z) /* number successor */