7. Grimm Brothers
• (Grand) Mother tells a story to
her (grand) children
• Very beginnings of culture
• Find and collect stories that
passed through the sieve of
history
8. Germany before unification
• A collection of different
• People mostly spoke German,
English, France
• Collect stories to bind the
German speaking peoples
together
9. The Story of a Boy Who Went Forth to Learn Fear
David Hockey
10. JFK Moon Speech
We choose to go to the moon. We choose to go to
the moon in this decade and do the other things,
not because they are easy, but because they are
hard, because that goal will serve to organize and
measure the best of our energies and skills,
because that challenge is one that we are willing
to accept, one we are unwilling to postpone, and
one which we intend to win, and the others, too.
11. • 1920s: Birth of Combinatory Logic
• Schonfinkel to eliminate bound variables
• Briefly covered high order functions
• Von Neumann's doctoral thesis on set theory
• Curry's combinators
History of Lambda Calculus
12. • 1930s: Birth of Lambda calculus
• Alonzo Church invented Lambda calculus
(explicit formal convertion rules)
• Representation of positive integers — Church
numerals
• Turing published first fixed-point combinator
History of Lambda Calculus
13. History of Lambda Calculus
• 1940s and 1950s:
• Research sort of is frozen, though - - -
• Simple type theory
• Weak reduction
14. History of Lambda Calculus
• 1960+:
• John McCarthy Computer language LISP
• Peter Landin — abstract machine
• Bohm's CuCh language
• Types
22. Abstract Machine
• How does one design an abstract machine?
• Why do some abstract machines operate on λ-
terms directly whereas others operate on
compiled λ-terms?
• How does one prove the correctness of an
abstract machine?
23.
24. Abstract Machine
• Does not need tree-shaped data structure to interpreter
code — much better performance
• Does not compile code to a native machine instructions
— freedom and architecture-independent
• AM compiles code to a sequence of (abstract)
instructions, defines reduction strategy, evaluation order
and data representations
• Call-by-name (lazy) and call-by-value (eager) defined by
an evaluation strategy that results into different machines
25. Abstract Machine
• Landin invented SECD machine
• Plotkin proved its correctness
• Felleisen invented CEK machine
• Many others proposed modifications and other
discoverables
26.
27. Abstract Machine for
Arithmetic Expressions
• Arithmetic expression:
• a ::= N | a1 + a2 | a1 − a2 | . . .
• Instruction set:
• C(N) — push integer N on stack
• ADD — pop two integers, push their sum
• SUB — pop two integers, push their difference
31. SECD Machine
S — Stack (holding intermediate results and return
addresses)
E — Environment (giving values to symbols)
C — Code (instructions yet to be executed)
D — Dump (S.E.C)
32. SECD Machine
• Instruction set (forget for a moment about Wikipedia):
• ACCESS(n) — push n-th field of the environment
• CLOSURE(c) — push closure of code c with current environment
• APPLY — pop function closure and argument, perform
application
• RETURN — terminate current function, jump back to caller
• LET* — pop value and add it to environment
• ENDLET* — discard first entry of environment
37. Tail call optimization
• tail call optimization drops extra RETURN
instruction enabling function to return result
directly to function and saving stack space
• E(λa) = CLOSURE(E(a); RETURN)
38. Evaluation scheme
• T(let a in b) = E(a); LET; T(b)
• T(a b) = E(a); E(b); TAILAPPLY
• T(a) = E(a); RETURN
• E(n) = ACCESS(n)
• E(λa) = CLOSURE(T(a))
• E(let a in b) = E(a); LET; E(b); ENDLET
• E(a b) = E(a); E(b); APPLY
40. K Machine
S — Stack (holding intermediate results and return
addresses)
E — Environment (giving thunks to symbols)
C — Code (instructions yet to be executed)
41. Evaluation scheme
• E(n) = ACCESS(n)
• E(λa) = GRAB; E(a)
• E(a b) = PUSH(E(b)); E(a)
• ACCESS — start evaluating the N-th thunk in the environment
• PUSH(c) — push a thunk for code c
• GRAB — pop one argument and add it to environment
Example: (λx. x+1) 2 = PUSH(C(2)); GRAB; ACCESS(1); C(1); ADD