SlideShare a Scribd company logo
1 of 46
Download to read offline
Abstract Machines for
Great Good
A Gentle Introduction
_epicmonkey
epicmonkey
mail@epicmonkey.org
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
Germany before unification
• A collection of different
• People mostly spoke German,
English, France
• Collect stories to bind the
German speaking peoples
together
The Story of a Boy Who Went Forth to Learn Fear
David Hockey
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.
• 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
• 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
History of Lambda Calculus
• 1940s and 1950s:
• Research sort of is frozen, though - - -
• Simple type theory
• Weak reduction
History of Lambda Calculus
• 1960+:
• John McCarthy Computer language LISP
• Peter Landin — abstract machine
• Bohm's CuCh language
• Types
Lambda Calculus
λx.x
argument body
}
lambda term
applicationabstraction
λx.λy.x
λx.λy.y
λf.λx.x
λf.λx.f x
λf.λx.f (f x)
λm.λn.λf.λx.((m f) ((n f) x))
λp.λq.((p (λx.λy.x)) q)
Basic Lambda
True
False
Zero
One
Two
Add
Or
((λ (l) (((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (l) ((((λ (p) (λ (x) (λ (y) ((p x)
y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) l)) (λ (x) (λ (x) (λ (y) x)))) ((λ (p) ((λ (s) (((λ (x) (λ (y) ((((λ
(f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (x) (λ (y) ((((λ (p) (λ (x) (λ (y) ((p x)
y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) x)) y) (((λ (p) (λ (q) (λ (h) ((h p) q)))) ((λ (p) (p (λ (x) (λ (y)
x)))) x)) ((r ((λ (p) (p (λ (x) (λ (y) y)))) x)) y))))))) x) y))) (((λ (x) (λ (y) ((((λ (f) ((λ (g) (f (λ (x) ((g g) x))))
(λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (x) (λ (y) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x)
(λ (y) y)))))) x)) y) (((λ (p) (λ (q) (λ (h) ((h p) q)))) ((λ (p) (p (λ (x) (λ (y) x)))) x)) ((r ((λ (p) (p (λ (x) (λ
(y) y)))) x)) y))))))) x) y))) (r (((λ (p) (λ (l) ((((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x))))))
(λ (r) (λ (p) (λ (l) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) l)) (λ (x) (λ (x)
(λ (y) x)))) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) (p ((λ (p) (p (λ (x) (λ (y) x)))) l))) (((λ (p) (λ (q) (λ (h) ((h p)
q)))) ((λ (p) (p (λ (x) (λ (y) x)))) l)) ((r p) ((λ (p) (p (λ (x) (λ (y) y)))) l)))) ((r p) ((λ (p) (p (λ (x) (λ (y) y))))
l)))))))) p) l))) (λ (x) (((λ (x) (λ (y) ((λ (n) ((n (λ (x) (λ (x) (λ (y) y)))) (λ (x) (λ (y) x)))) (((λ (m) (λ (n) ((n
(λ (n) (λ (f) (λ (x) (((n (λ (g) (λ (h) (h (g f))))) (λ (u) x)) (λ (u) u)))))) m))) x) y)))) x) p))) s))) (((λ (p) (λ (q)
(λ (h) ((h p) q)))) p) (λ (x) (λ (x) (λ (y) x)))))) (r (((λ (p) (λ (l) ((((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f
(λ (x) ((g g) x)))))) (λ (r) (λ (p) (λ (l) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y)
y)))))) l)) (λ (x) (λ (x) (λ (y) x)))) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) (p ((λ (p) (p (λ (x) (λ (y) x)))) l))) (((λ
(p) (λ (q) (λ (h) ((h p) q)))) ((λ (p) (p (λ (x) (λ (y) x)))) l)) ((r p) ((λ (p) (p (λ (x) (λ (y) y)))) l)))) ((r p) ((λ
(p) (p (λ (x) (λ (y) y)))) l)))))))) p) l))) (λ (x) (((λ (x) (λ (y) ((λ (p) ((p (λ (x) (λ (y) y))) (λ (x) (λ (y) x))))
(((λ (x) (λ (y) ((λ (n) ((n (λ (x) (λ (x) (λ (y) y)))) (λ (x) (λ (y) x)))) (((λ (m) (λ (n) ((n (λ (n) (λ (f) (λ (x) (((n
(λ (g) (λ (h) (h (g f))))) (λ (u) x)) (λ (u) u)))))) m))) x) y)))) x) y)))) x) p))) s)))) ((λ (p) (p (λ (x) (λ (y) y))))
l))) ((λ (p) (p (λ (x) (λ (y) x)))) l)))))) l))
(((λ (p) (λ (q) (λ (h) ((h p) q)))) (λ (f) (λ (x) (f (f (f x)))))) (((λ (p) (λ (q) (λ (h) ((h p) q)))) (λ (f) (λ (x) (f
x)))) (((λ (p) (λ (q) (λ (h) ((h p) q)))) (λ (f) (λ (x) (f (f x))))) (λ (x) (λ (x) (λ (y) x)))))))
Not so Basic Lambda /
Quicksort
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?
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
Abstract Machine
• Landin invented SECD machine
• Plotkin proved its correctness
• Felleisen invented CEK machine
• Many others proposed modifications and other
discoverables
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
Evaluation scheme
• E(N) = C(N)
• E(a1 + a2) = E(a1); E(a2); ADD
• E(a1 - a2) = E(a1); E(a2); SUB
• Example: E(3+(2-1)) = C(3); C(2); C(1); SUB; ADD
Transitions
Machine state afterMachine state before
Evaluation
Example: E(3 + (2 - 1))
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)
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
De Bruijn Indices
λx.λy.x
λx.λy.y
λf.λx.x
λf.λx.f x
λf.λx.f (f x)
True
False
Zero
One
Two
λx1.λx0.x0
λx1.λx0.x1
λx1.λx0.x0
λx1.λx0.x1 x0
λx1.λx0.x1 (x1 x0)
Evaluation scheme
• E(n) = ACCESS(n)
• E(λa) = CLOSURE(E(a); RETURN)
• E(let a in b) = E(a); LET; E(b); ENDLET
• E(a b) = E(a); E(b); APPLY
Transitions
Machine state afterMachine state before
Evaluation
Example: (λx. x+1) 2 = CLOSURE(c); C(2); APPLY
where c = ACCESS(1); C(1) ; ADD; RETURN
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)
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
Evaluation
Machine state afterMachine state before
K Machine
S — Stack (holding intermediate results and return
addresses)
E — Environment (giving thunks to symbols)
C — Code (instructions yet to be executed)
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
Is it any good?
Yes
Wanna know more?
• ZAM-, B-, G- machines
• BLC
• Cata-, Hylo-, Ana- morphisms as a reduction
• P-numerals vs Church version
• Ultimately, Read T.S.Eliot
Thank you!
_epicmonkey
epicmonkey
mail@epicmonkey.org

More Related Content

What's hot

Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsAlexander Yakushev
 
Generating and Analyzing Events
Generating and Analyzing EventsGenerating and Analyzing Events
Generating and Analyzing Eventsztellman
 
Coq for ML users
Coq for ML usersCoq for ML users
Coq for ML userstmiya
 
تصنيف المصادر حسب المعايير1
تصنيف المصادر حسب المعايير1تصنيف المصادر حسب المعايير1
تصنيف المصادر حسب المعايير1Dalia Mooftah
 
Price of anarchy is independent of network topology
Price of anarchy is independent of network topologyPrice of anarchy is independent of network topology
Price of anarchy is independent of network topologyAleksandr Yampolskiy
 
StrataGEM: A Generic Petri Net Verification Framework
StrataGEM: A Generic Petri Net Verification FrameworkStrataGEM: A Generic Petri Net Verification Framework
StrataGEM: A Generic Petri Net Verification FrameworkEdmundo López Bóbeda
 
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkCrystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkJivan Nepali
 
Bayesian learning
Bayesian learning Bayesian learning
Bayesian learning EngReads
 
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...MITSUNARI Shigeo
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Peng Cheng
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To LispDamien Garaud
 
SciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with AgilitySciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with AgilityESUG
 
Symbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo TheoriesSymbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo TheoriesQuoc-Sang Phan
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Piotr Paradziński
 

What's hot (20)

R/C++ talk at earl 2014
R/C++ talk at earl 2014R/C++ talk at earl 2014
R/C++ talk at earl 2014
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular Expressions
 
Python grass
Python grassPython grass
Python grass
 
Generating and Analyzing Events
Generating and Analyzing EventsGenerating and Analyzing Events
Generating and Analyzing Events
 
Coq for ML users
Coq for ML usersCoq for ML users
Coq for ML users
 
تصنيف المصادر حسب المعايير1
تصنيف المصادر حسب المعايير1تصنيف المصادر حسب المعايير1
تصنيف المصادر حسب المعايير1
 
Price of anarchy is independent of network topology
Price of anarchy is independent of network topologyPrice of anarchy is independent of network topology
Price of anarchy is independent of network topology
 
Rcpp11 genentech
Rcpp11 genentechRcpp11 genentech
Rcpp11 genentech
 
StrataGEM: A Generic Petri Net Verification Framework
StrataGEM: A Generic Petri Net Verification FrameworkStrataGEM: A Generic Petri Net Verification Framework
StrataGEM: A Generic Petri Net Verification Framework
 
Rcpp11 useR2014
Rcpp11 useR2014Rcpp11 useR2014
Rcpp11 useR2014
 
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkCrystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
 
Bayesian learning
Bayesian learning Bayesian learning
Bayesian learning
 
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and...
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
 
Clojure night
Clojure nightClojure night
Clojure night
 
Jan 2012 HUG: RHadoop
Jan 2012 HUG: RHadoopJan 2012 HUG: RHadoop
Jan 2012 HUG: RHadoop
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To Lisp
 
SciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with AgilitySciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with Agility
 
Symbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo TheoriesSymbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo Theories
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
 

Viewers also liked

The whole picture of Wisdom & Compassion
The whole picture of Wisdom & CompassionThe whole picture of Wisdom & Compassion
The whole picture of Wisdom & CompassionHitoshi Tsuchiyama
 
Prueba Matemática
Prueba MatemáticaPrueba Matemática
Prueba Matemáticakr3ng
 
Alimentos transgénicos
Alimentos transgénicosAlimentos transgénicos
Alimentos transgénicosPatricia Rojas
 
Ismael Plascencia Nuñez - Curriculum empresarial
Ismael Plascencia Nuñez - Curriculum empresarial Ismael Plascencia Nuñez - Curriculum empresarial
Ismael Plascencia Nuñez - Curriculum empresarial Ismael Plascencia Nuñez
 
Guia2016 2017tercerobloque2
Guia2016 2017tercerobloque2Guia2016 2017tercerobloque2
Guia2016 2017tercerobloque2Erendi SB
 
Verb to be: multiple choice
Verb to be: multiple choiceVerb to be: multiple choice
Verb to be: multiple choiceA. Simoes
 

Viewers also liked (8)

The whole picture of Wisdom & Compassion
The whole picture of Wisdom & CompassionThe whole picture of Wisdom & Compassion
The whole picture of Wisdom & Compassion
 
Prueba Matemática
Prueba MatemáticaPrueba Matemática
Prueba Matemática
 
Alimentos transgénicos
Alimentos transgénicosAlimentos transgénicos
Alimentos transgénicos
 
Ismael Plascencia Nuñez - Curriculum empresarial
Ismael Plascencia Nuñez - Curriculum empresarial Ismael Plascencia Nuñez - Curriculum empresarial
Ismael Plascencia Nuñez - Curriculum empresarial
 
Guia2016 2017tercerobloque2
Guia2016 2017tercerobloque2Guia2016 2017tercerobloque2
Guia2016 2017tercerobloque2
 
Verb to be: multiple choice
Verb to be: multiple choiceVerb to be: multiple choice
Verb to be: multiple choice
 
Guia 2 Zonas Climáticas 3NB
Guia 2 Zonas Climáticas 3NBGuia 2 Zonas Climáticas 3NB
Guia 2 Zonas Climáticas 3NB
 
English verb to be present tense
English verb to be present tenseEnglish verb to be present tense
English verb to be present tense
 

Similar to Abstract machines for great good

Otter 2016-11-28-01-ss
Otter 2016-11-28-01-ssOtter 2016-11-28-01-ss
Otter 2016-11-28-01-ssRuo Ando
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Languagevsssuresh
 
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐานภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐานNoppanon YourJust'one
 
OTTER 2017-12-03
OTTER 2017-12-03OTTER 2017-12-03
OTTER 2017-12-03Ruo Ando
 
Semantic Parsing with Combinatory Categorial Grammar (CCG)
Semantic Parsing with Combinatory Categorial Grammar (CCG)Semantic Parsing with Combinatory Categorial Grammar (CCG)
Semantic Parsing with Combinatory Categorial Grammar (CCG)shakimov
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that LetterKevlin Henney
 
Unit 1-logic
Unit 1-logicUnit 1-logic
Unit 1-logicraksharao
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that LetterKevlin Henney
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture gVlad Patryshev
 
Declarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsDeclarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsBertram Ludäscher
 
Lecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceLecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceasimnawaz54
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogrammingdudarev
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talkJohn Stevenson
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchAhmed BESBES
 
A Proposition for Business Process Modeling
A Proposition for Business Process ModelingA Proposition for Business Process Modeling
A Proposition for Business Process ModelingAng Chen
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data ManagementAlbert Bifet
 

Similar to Abstract machines for great good (20)

Otter 2016-11-28-01-ss
Otter 2016-11-28-01-ssOtter 2016-11-28-01-ss
Otter 2016-11-28-01-ss
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...
QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...
QMC Program: Trends and Advances in Monte Carlo Sampling Algorithms Workshop,...
 
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐานภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
 
OTTER 2017-12-03
OTTER 2017-12-03OTTER 2017-12-03
OTTER 2017-12-03
 
Semantic Parsing with Combinatory Categorial Grammar (CCG)
Semantic Parsing with Combinatory Categorial Grammar (CCG)Semantic Parsing with Combinatory Categorial Grammar (CCG)
Semantic Parsing with Combinatory Categorial Grammar (CCG)
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Unit 1-logic
Unit 1-logicUnit 1-logic
Unit 1-logic
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture g
 
9.class-notesr9.ppt
9.class-notesr9.ppt9.class-notesr9.ppt
9.class-notesr9.ppt
 
Declarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsDeclarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere Mortals
 
Clojure presentation
Clojure presentationClojure presentation
Clojure presentation
 
Lecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceLecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inference
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 
Archipelagos
ArchipelagosArchipelagos
Archipelagos
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from Scratch
 
A Proposition for Business Process Modeling
A Proposition for Business Process ModelingA Proposition for Business Process Modeling
A Proposition for Business Process Modeling
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
 

More from Александр Ежов

Борьба с багами: RailsClub на DevConf 2015
Борьба с багами: RailsClub на DevConf 2015Борьба с багами: RailsClub на DevConf 2015
Борьба с багами: RailsClub на DevConf 2015Александр Ежов
 
Rubt on Rails: 1000 запросов в секунду
Rubt on Rails: 1000 запросов в секундуRubt on Rails: 1000 запросов в секунду
Rubt on Rails: 1000 запросов в секундуАлександр Ежов
 
Liquor, Liquid и другие безопасные языки разметки в RoR
Liquor, Liquid и другие безопасные языки разметки в RoRLiquor, Liquid и другие безопасные языки разметки в RoR
Liquor, Liquid и другие безопасные языки разметки в RoRАлександр Ежов
 
Антикризисная презентация
Антикризисная презентацияАнтикризисная презентация
Антикризисная презентацияАлександр Ежов
 
Eventmachine: структура evented-приложений
Eventmachine: структура evented-приложенийEventmachine: структура evented-приложений
Eventmachine: структура evented-приложенийАлександр Ежов
 
Обзорное сравнение серверов приложений для Rails
Обзорное сравнение серверов приложений для RailsОбзорное сравнение серверов приложений для Rails
Обзорное сравнение серверов приложений для RailsАлександр Ежов
 
Использования PgQ и Londste в rails-приложении
Использования PgQ и Londste в rails-приложенииИспользования PgQ и Londste в rails-приложении
Использования PgQ и Londste в rails-приложенииАлександр Ежов
 
Интернационализация и локализация Ruby on Rails. gem russian
Интернационализация и локализация Ruby on Rails. gem russianИнтернационализация и локализация Ruby on Rails. gem russian
Интернационализация и локализация Ruby on Rails. gem russianАлександр Ежов
 
Как сделать контрибут в Ruby on Rails
Как сделать контрибут в Ruby on RailsКак сделать контрибут в Ruby on Rails
Как сделать контрибут в Ruby on RailsАлександр Ежов
 

More from Александр Ежов (20)

Кеширование данных в БД
Кеширование данных в БДКеширование данных в БД
Кеширование данных в БД
 
Борьба с багами: RailsClub на DevConf 2015
Борьба с багами: RailsClub на DevConf 2015Борьба с багами: RailsClub на DevConf 2015
Борьба с багами: RailsClub на DevConf 2015
 
Rails 5: awesome features and breaking changes
Rails 5: awesome features and breaking changesRails 5: awesome features and breaking changes
Rails 5: awesome features and breaking changes
 
Big Data и Ruby
Big Data и RubyBig Data и Ruby
Big Data и Ruby
 
Rubt on Rails: 1000 запросов в секунду
Rubt on Rails: 1000 запросов в секундуRubt on Rails: 1000 запросов в секунду
Rubt on Rails: 1000 запросов в секунду
 
Liquor, Liquid и другие безопасные языки разметки в RoR
Liquor, Liquid и другие безопасные языки разметки в RoRLiquor, Liquid и другие безопасные языки разметки в RoR
Liquor, Liquid и другие безопасные языки разметки в RoR
 
Vim or die
Vim or dieVim or die
Vim or die
 
Capistrano Rails
Capistrano RailsCapistrano Rails
Capistrano Rails
 
Умное кэширование в Rails
Умное кэширование в RailsУмное кэширование в Rails
Умное кэширование в Rails
 
Sphinx как база данных
Sphinx как база данныхSphinx как база данных
Sphinx как база данных
 
Emacs и Rails
Emacs и RailsEmacs и Rails
Emacs и Rails
 
Антикризисная презентация
Антикризисная презентацияАнтикризисная презентация
Антикризисная презентация
 
Eventmachine: структура evented-приложений
Eventmachine: структура evented-приложенийEventmachine: структура evented-приложений
Eventmachine: структура evented-приложений
 
Дэдлоки
ДэдлокиДэдлоки
Дэдлоки
 
Обзорное сравнение серверов приложений для Rails
Обзорное сравнение серверов приложений для RailsОбзорное сравнение серверов приложений для Rails
Обзорное сравнение серверов приложений для Rails
 
Приложения в плагинах
Приложения в плагинахПриложения в плагинах
Приложения в плагинах
 
Использования PgQ и Londste в rails-приложении
Использования PgQ и Londste в rails-приложенииИспользования PgQ и Londste в rails-приложении
Использования PgQ и Londste в rails-приложении
 
Масштабирование в Rails
Масштабирование в RailsМасштабирование в Rails
Масштабирование в Rails
 
Интернационализация и локализация Ruby on Rails. gem russian
Интернационализация и локализация Ruby on Rails. gem russianИнтернационализация и локализация Ruby on Rails. gem russian
Интернационализация и локализация Ruby on Rails. gem russian
 
Как сделать контрибут в Ruby on Rails
Как сделать контрибут в Ruby on RailsКак сделать контрибут в Ruby on Rails
Как сделать контрибут в Ruby on Rails
 

Recently uploaded

Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 

Recently uploaded (20)

Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 

Abstract machines for great good

  • 1. Abstract Machines for Great Good A Gentle Introduction
  • 3.
  • 4.
  • 5.
  • 6.
  • 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
  • 15. Lambda Calculus λx.x argument body } lambda term applicationabstraction
  • 16. λx.λy.x λx.λy.y λf.λx.x λf.λx.f x λf.λx.f (f x) λm.λn.λf.λx.((m f) ((n f) x)) λp.λq.((p (λx.λy.x)) q) Basic Lambda True False Zero One Two Add Or
  • 17. ((λ (l) (((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (l) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) l)) (λ (x) (λ (x) (λ (y) x)))) ((λ (p) ((λ (s) (((λ (x) (λ (y) ((((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (x) (λ (y) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) x)) y) (((λ (p) (λ (q) (λ (h) ((h p) q)))) ((λ (p) (p (λ (x) (λ (y) x)))) x)) ((r ((λ (p) (p (λ (x) (λ (y) y)))) x)) y))))))) x) y))) (((λ (x) (λ (y) ((((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (x) (λ (y) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) x)) y) (((λ (p) (λ (q) (λ (h) ((h p) q)))) ((λ (p) (p (λ (x) (λ (y) x)))) x)) ((r ((λ (p) (p (λ (x) (λ (y) y)))) x)) y))))))) x) y))) (r (((λ (p) (λ (l) ((((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (p) (λ (l) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) l)) (λ (x) (λ (x) (λ (y) x)))) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) (p ((λ (p) (p (λ (x) (λ (y) x)))) l))) (((λ (p) (λ (q) (λ (h) ((h p) q)))) ((λ (p) (p (λ (x) (λ (y) x)))) l)) ((r p) ((λ (p) (p (λ (x) (λ (y) y)))) l)))) ((r p) ((λ (p) (p (λ (x) (λ (y) y)))) l)))))))) p) l))) (λ (x) (((λ (x) (λ (y) ((λ (n) ((n (λ (x) (λ (x) (λ (y) y)))) (λ (x) (λ (y) x)))) (((λ (m) (λ (n) ((n (λ (n) (λ (f) (λ (x) (((n (λ (g) (λ (h) (h (g f))))) (λ (u) x)) (λ (u) u)))))) m))) x) y)))) x) p))) s))) (((λ (p) (λ (q) (λ (h) ((h p) q)))) p) (λ (x) (λ (x) (λ (y) x)))))) (r (((λ (p) (λ (l) ((((λ (f) ((λ (g) (f (λ (x) ((g g) x)))) (λ (g) (f (λ (x) ((g g) x)))))) (λ (r) (λ (p) (λ (l) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) ((λ (p) (p (λ (x) (λ (y) (λ (x) (λ (y) y)))))) l)) (λ (x) (λ (x) (λ (y) x)))) ((((λ (p) (λ (x) (λ (y) ((p x) y)))) (p ((λ (p) (p (λ (x) (λ (y) x)))) l))) (((λ (p) (λ (q) (λ (h) ((h p) q)))) ((λ (p) (p (λ (x) (λ (y) x)))) l)) ((r p) ((λ (p) (p (λ (x) (λ (y) y)))) l)))) ((r p) ((λ (p) (p (λ (x) (λ (y) y)))) l)))))))) p) l))) (λ (x) (((λ (x) (λ (y) ((λ (p) ((p (λ (x) (λ (y) y))) (λ (x) (λ (y) x)))) (((λ (x) (λ (y) ((λ (n) ((n (λ (x) (λ (x) (λ (y) y)))) (λ (x) (λ (y) x)))) (((λ (m) (λ (n) ((n (λ (n) (λ (f) (λ (x) (((n (λ (g) (λ (h) (h (g f))))) (λ (u) x)) (λ (u) u)))))) m))) x) y)))) x) y)))) x) p))) s)))) ((λ (p) (p (λ (x) (λ (y) y)))) l))) ((λ (p) (p (λ (x) (λ (y) x)))) l)))))) l)) (((λ (p) (λ (q) (λ (h) ((h p) q)))) (λ (f) (λ (x) (f (f (f x)))))) (((λ (p) (λ (q) (λ (h) ((h p) q)))) (λ (f) (λ (x) (f x)))) (((λ (p) (λ (q) (λ (h) ((h p) q)))) (λ (f) (λ (x) (f (f x))))) (λ (x) (λ (x) (λ (y) x))))))) Not so Basic Lambda / Quicksort
  • 18.
  • 19.
  • 20.
  • 21.
  • 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
  • 28. Evaluation scheme • E(N) = C(N) • E(a1 + a2) = E(a1); E(a2); ADD • E(a1 - a2) = E(a1); E(a2); SUB • Example: E(3+(2-1)) = C(3); C(2); C(1); SUB; ADD
  • 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
  • 33. De Bruijn Indices λx.λy.x λx.λy.y λf.λx.x λf.λx.f x λf.λx.f (f x) True False Zero One Two λx1.λx0.x0 λx1.λx0.x1 λx1.λx0.x0 λx1.λx0.x1 x0 λx1.λx0.x1 (x1 x0)
  • 34. Evaluation scheme • E(n) = ACCESS(n) • E(λa) = CLOSURE(E(a); RETURN) • E(let a in b) = E(a); LET; E(b); ENDLET • E(a b) = E(a); E(b); APPLY
  • 36. Evaluation Example: (λx. x+1) 2 = CLOSURE(c); C(2); APPLY where c = ACCESS(1); C(1) ; ADD; RETURN
  • 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
  • 42. Is it any good?
  • 43. Yes
  • 44. Wanna know more? • ZAM-, B-, G- machines • BLC • Cata-, Hylo-, Ana- morphisms as a reduction • P-numerals vs Church version • Ultimately, Read T.S.Eliot
  • 45.