SlideShare a Scribd company logo
1 of 41
Download to read offline
Continuation calculus
Bram Geron1 Herman Geuvers1,2
1Eindhoven University of Technology
2Radboud University Nijmegen
Term Rewriting Seminar, May 2013
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 1 / 22
Outline
1 First look
2 Definition
3 Long-term goal
4 Interfaces, not pattern matching
5 The importance of head reduction
6 Relation to lambda calculus
7 Conclusion
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 2 / 22
First look Rules, names, variables, terms
CC is a constrained term rewriting system
Comp.f .g.x
def
−→ f .(g.x)
Comp.AddOne.Fact.4 → AddOne.(Fact.4)
Rules
One definition per name
(max)
No pattern matching
Only head reduction
Consequences
Deterministic
Simple operational semantics
Suitable for modeling
continuations, hence exceptions
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 3 / 22
First look Rules, names, variables, terms
CC is a constrained term rewriting system
rule
Comp
name
(constant)
.f .g.x
variables
def
−→ f .(g.x)
Comp.AddOne.Fact.4
term
→ AddOne.(Fact.4)
term
Rules
One definition per name
(max)
No pattern matching
Only head reduction
Consequences
Deterministic
Simple operational semantics
Suitable for modeling
continuations, hence exceptions
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 3 / 22
First look Rules, names, variables, terms
CC is a constrained term rewriting system
rule
Comp
name
(constant)
.f .g.x
variables
def
−→ f .(g.x)
Comp.AddOne.Fact.4
term
→ AddOne.(Fact.4)
term
Rules
One definition per name
(max)
No pattern matching
Only head reduction
Consequences
Deterministic
Simple operational semantics
Suitable for modeling
continuations, hence exceptions
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 3 / 22
First look Head reduction: continuation passing style
Functions fill in the result in their continuation parameter
Comp.f .g.x
def
−→ f .(g.x)
Comp.AddOne.Fact.4 → AddOne.(Fact).4
Realistic names:
Fact.r.x r.x!
AddOne.r.x r.(x +1)
Fact.(AddOne.r).4 AddOne.r.24
r.25
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
First look Head reduction: continuation passing style
Functions fill in the result in their continuation parameter
Comp.f .g.x
def
−→ f .(g.x)
Comp.AddOne.Fact.4 → AddOne.(Fact).4
Realistic names:
Fact.r.x r.x!
AddOne.r.x r.(x +1)
Fact.(AddOne.r).4 AddOne.r.24
r.25
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
First look Head reduction: continuation passing style
Functions fill in the result in their continuation parameter
Comp.f .g.x
def
−→ f .(g.x)
Comp.AddOne.Fact.4 → AddOne.(Fact).4
Realistic names:
Fact.r.x r.x!
AddOne.r.x r.(x +1)
Fact.(AddOne.r).4 AddOne.r.24
r.25
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
First look Head reduction: continuation passing style
Functions fill in the result in their continuation parameter
Comp.r.f .g.x
def
−→ g.(f .r).x
Comp.r.AddOne.Fact.4 → Fact.(AddOne.r).4
Realistic names:
Fact.r.x r.x!
AddOne.r.x r.(x +1)
Fact.(AddOne.r).4 AddOne.r.24
r.25
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
First look Head reduction: continuation passing style
Functions fill in the result in their continuation parameter
Comp.r.f .g.x
def
−→ g.(f .r).x
Comp.r.AddOne.Fact.4 → Fact.(AddOne.r).4
Realistic names:
Fact.r.x r.x!
AddOne.r.x r.(x +1)
Fact.(AddOne.r).4 AddOne.r.24
r.25
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
Definition
Definitions
There is an infinite set of names, indicated by a capital.
A term is either a name, or two terms combined by a dot.
We write a.b.c as shorthand for (a.b).c.
A program P consists of a set of rules, of the form
Name.variable.··· .variable
def
−→ term over those variables
That rule defines that name.
Each rule defines a different name.
If “N.x1 .··· .xk
def
−→ r” ∈ P, then we reduce N.t → r[t/x].
Term N.x1.··· .xl for l = k does not reduce at all.
There is only head reduction.
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 5 / 22
Definition
Definitions
There is an infinite set of names, indicated by a capital.
A term is either a name, or two terms combined by a dot.
We write a.b.c as shorthand for (a.b).c.
A program P consists of a set of rules, of the form
Name.variable.··· .variable
def
−→ term over those variables
That rule defines that name.
Each rule defines a different name.
If “N.x1 .··· .xk
def
−→ r” ∈ P, then we reduce N.t → r[t/x].
Term N.x1.··· .xl for l = k does not reduce at all.
There is only head reduction.
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 5 / 22
Definition
Definitions
There is an infinite set of names, indicated by a capital.
A term is either a name, or two terms combined by a dot.
We write a.b.c as shorthand for (a.b).c.
A program P consists of a set of rules, of the form
Name.variable.··· .variable
def
−→ term over those variables
That rule defines that name.
Each rule defines a different name.
If “N.x1 .··· .xk
def
−→ r” ∈ P, then we reduce N.t → r[t/x].
Term N.x1.··· .xl for l = k does not reduce at all.
There is only head reduction.
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 5 / 22
Long-term goal
Long-term goal
Formally modeling programming languages
Hopefully as a base for better languages
Operational semantics
Running time: #steps ∼ seconds CPU time
Warning: some unsubstantiated claims
Compositional
Facilitates proving properties
Deterministic by nature
Works with continuations
Explained later
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 6 / 22
Long-term goal
Long-term goal
Formally modeling programming languages
Hopefully as a base for better languages
Operational semantics
Running time: #steps ∼ seconds CPU time
Warning: some unsubstantiated claims
Compositional
Facilitates proving properties
Deterministic by nature
Works with continuations
Explained later
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 6 / 22
Interfaces, not pattern matching
Outline
1 First look
2 Definition
3 Long-term goal
4 Interfaces, not pattern matching
5 The importance of head reduction
6 Relation to lambda calculus
7 Conclusion
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 7 / 22
Interfaces, not pattern matching
Outline
1 First look
2 Definition
3 Long-term goal
4 Interfaces, not pattern matching
5 The importance of head reduction
6 Relation to lambda calculus
7 Conclusion
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 8 / 22
Interfaces, not pattern matching
Natural numbers
Slightly similar to lambda calculus
Zero.z.s
def
−→ z
S.x.z.s
def
−→ s.x
Add.r.x.y
def
−→ y.(r.x).(Add.r.(S.x))
Algorithm:
x +0 = x
x +S(y) = S(x)+y
Add.r.(S.Zero).Zero → Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero)))
→ r.(S.Zero)
Add.r.Zero.(S.Zero) → S.Zero.(r.Zero).(Add.r.(S.Zero))
→ Add.r.(S.Zero).Zero
→ Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero)))
→ r.(S.Zero)
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 9 / 22
Interfaces, not pattern matching
Natural numbers
Slightly similar to lambda calculus
Zero.z.s
def
−→ z
S.x.z.s
def
−→ s.x
Add.r.x.y
def
−→ y.(r.x).(Add.r.(S.x))
Algorithm:
x +0 = x
x +S(y) = S(x)+y
Add.r.(S.Zero).Zero → Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero)))
→ r.(S.Zero)
Add.r.Zero.(S.Zero) → S.Zero.(r.Zero).(Add.r.(S.Zero))
→ Add.r.(S.Zero).Zero
→ Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero)))
→ r.(S.Zero)
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 9 / 22
Interfaces, not pattern matching
Natural numbers
Slightly similar to lambda calculus
Zero.z.s
def
−→ z
S.x.z.s
def
−→ s.x
Add.r.x.y
def
−→ y.(r.x).(Add.r.(S.x))
Algorithm:
x +0 = x
x +S(y) = S(x)+y
What can we feed to Add?
Zero
S.(··· .(S.Zero)···)
Something else?
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 10 / 22
Interfaces, not pattern matching
Natural numbers
Slightly similar to lambda calculus
Zero.z.s
def
−→ z
S.x.z.s
def
−→ s.x
Add.r.x.y
def
−→ y.(r.x).(Add.r.(S.x))
Algorithm:
x +0 = x
x +S(y) = S(x)+y
What can we feed to Add?
Zero
S.(··· .(S.Zero)···)
Something else? Yes!
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 10 / 22
Interfaces, not pattern matching
Natural numbers
Compatible naturals
Zero.z.s
def
−→ z
S.x.z.s
def
−→ s.x
Add.r.x.y
def
−→ y.(r.x).(Add.r.(S.x))
Algorithm:
x +0 = x
x +S(y) = S(x)+y
We define when a term t represents natural number n.
1 t represents 0 if ∀z,s : t.z.s z
Informally: t “behaves the same as” Zero
2 t represents n +1 if ∀z,s : t.z.s s.q, and q represents n
Informally: t “behaves the same as” S.q
With this, we can define LazyFact such that LazyFact.x represents (x!).
(Omitted.)
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 11 / 22
Interfaces, not pattern matching
Natural numbers
Compatible naturals
Zero.z.s
def
−→ z
S.x.z.s
def
−→ s.x
Add.r.x.y
def
−→ y.(r.x).(Add.r.(S.x))
Algorithm:
x +0 = x
x +S(y) = S(x)+y
With this, we can define LazyFact such that LazyFact.x represents (x!).
(Omitted.)
Add.r.Zero.(LazyFact.(S.Zero)) → LazyFact.(S.Zero).(r.Zero).(Add.r.(S.Zero))
Add.r.(S.Zero).Zero
→ Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero)))
→ r.(S.Zero)
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 11 / 22
Interfaces, not pattern matching
Natural numbers
Compatible naturals
Zero.z.s
def
−→ z
S.x.z.s
def
−→ s.x
Add.r.x.y
def
−→ y.(r.x).(Add.r.(S.x))
Algorithm:
x +0 = x
x +S(y) = S(x)+y
With this, we can define LazyFact such that LazyFact.x represents (x!).
(Omitted.)
Add.r.Zero.(LazyFact.(S.Zero)) r.(S.Zero)
Two types of function names
Call-by-value / eager: calculate result, fill in in continuation
Call-by-name / lazy: compatible with Sn.Zero but delayed
computation
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 11 / 22
The importance of head reduction
Outline
1 First look
2 Definition
3 Long-term goal
4 Interfaces, not pattern matching
5 The importance of head reduction
6 Relation to lambda calculus
7 Conclusion
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 12 / 22
The importance of head reduction
Outline
1 First look
2 Definition
3 Long-term goal
4 Interfaces, not pattern matching
5 The importance of head reduction
6 Relation to lambda calculus
7 Conclusion
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 13 / 22
The importance of head reduction
Operational semantics
Lambda calculus (normal order)
Reduction using two instructions on the top level
M N Push N on stack, continue in M
λx.M Pop N off stack, continue in M[N/x]
as presented in [Levy(2001)]
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 14 / 22
The importance of head reduction
Back to modeling programs
Lambda calculus
λx.+ (f x) (g x)
M N Push N on stack,
continue in M
λx.M Pop N off stack,
continue in M[N/x]
Programming language
fun x → (f x) + (g x)
M N Apply function object
to argument
fun x → M Make function object
In “real languages”, functions throw exceptions and have other side effects.
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 15 / 22
The importance of head reduction
Back to modeling programs
Lambda calculus
λx.+ (f x) (g x)
M N Push N on stack,
continue in M
λx.M Pop N off stack,
continue in M[N/x]
Programming language
fun x → (f x) + (g x)
throws exception
now what?
M N Apply function object
to argument
fun x → M Make function object
In “real languages”, functions throw exceptions and have other side effects.
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 15 / 22
The importance of head reduction
Operational semantics
Computational models with control
Lambda calculus + continuations (λC)
Reduction using four instructions on the top level
M N Push N on stack, continue in M
λx.M Pop N off stack, continue in M[N/x]
A M Empty the stack, continue in M
C M Empty the stack, continue in M (λx.S x)
where function S ‘restores’ the previous stack
(details omitted)
Can model exception-like facilities
CPS transformation to transform λC terms to λ terms
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 16 / 22
The importance of head reduction
CPS transformation
λC
CPS transformation
−−−−−−−−−−−→ subset of λ, makes minimal use of stack
Two calculi in action:
λC calculus: M N, λx.M, A M, C M
Expressive
Subset of λ calculus: M N, λx.M
Simpler
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
The importance of head reduction
CPS transformation
λC
CPS transformation
−−−−−−−−−−−→ subset of λ, makes minimal use of stack
Two calculi in action:
λC calculus: M N, λx.M, A M, C M
Expressive
Subset of λ calculus: M N, λx.M
Simpler
What is this subset, really?
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
The importance of head reduction
CPS transformation
λC
CPS transformation
−−−−−−−−−−−→ subset of λ, makes minimal use of stack
Two calculi in action:
λC calculus: M N, λx.M, A M, C M
Expressive
Subset of λ calculus: M N, λx.M
Simpler
What is this subset, really?
Can we describe it?
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
The importance of head reduction
CPS transformation
λC
CPS transformation
−−−−−−−−−−−→ subset of λ, makes minimal use of stack
Two calculi in action:
λC calculus: M N, λx.M, A M, C M
Expressive
Subset of λ calculus: M N, λx.M
Simpler
What is this subset, really?
Can we describe it?
An elegant model of computation, perhaps?
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
The importance of head reduction
Lambda calculus vs. continuation calculus
λC
Four instructions on the top level
M N Push N on stack, continue in M
λx.M Pop N off stack, continue in M[N/x]
A M Empty the stack, continue in M
C M Empty the stack, continue in M (λx.S x)
where function S ‘restores’ the stack
Continuation calculus
One instruction on the top level, using program P
n.t1.··· .tk Empty the stack, continue in r[t/x]
if n.x1 .··· .xk
def
−→ r ∈ P
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 18 / 22
The importance of head reduction
Lambda calculus vs. continuation calculus
λC
Four instructions on the top level
M N Push N on stack, continue in M
λx.M Pop N off stack, continue in M[N/x]
A M Empty the stack, continue in M
C M Empty the stack, continue in M (λx.S x)
where function S ‘restores’ the stack
Continuation calculus
One instruction on the top level, using program P
n.t1.··· .tk Empty the stack, continue in r[t/x]
if n.x1 .··· .xk
def
−→ r ∈ P
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 18 / 22
The importance of head reduction
Continuation calculus
Continuation calculus
One instruction on the top level, using program P
n.t1.··· .tk Continue in r[t/x]
if n.x1 .··· .xk
def
−→ r ∈ P
No stack needed, because
n.t1.··· .tl does not reduce for l = k.
Subterms are not reduced
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 19 / 22
Relation to lambda calculus
Relation to lambda calculus
λ,λC
CPS transformation
−−−−−−−−−−−→ subset of λ
subset of λ
λx to rules∗
−−−−−−−−−−−−−−−−−−−−−−
unfold†
rules to λx
CC
∗ λx to rules: involves a supercombinator transformation
† Unfold rules to λx: first apply a fixed-point elimination to eliminate cyclic references
Catchphrase
CC is more limited than λ,
thus more suitable to model continuations
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 20 / 22
Relation to lambda calculus
Relation to lambda calculus
λ,λC
CPS transformation
−−−−−−−−−−−→ subset of λ
subset of λ
λx to rules∗
−−−−−−−−−−−−−−−−−−−−−−
unfold†
rules to λx
CC
∗ λx to rules: involves a supercombinator transformation
† Unfold rules to λx: first apply a fixed-point elimination to eliminate cyclic references
Catchphrase
CC is more limited than λ,
thus more suitable to model continuations
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 20 / 22
Conclusion
Conclusion
CC is a constrained term rewriting system
CC is deterministic
Only head reduction
As a consequence,
Suitable for control with continuations (exceptions)
CC is similar to a subset of lambda calculus
Allows both eager and lazy function terms
call-by-value vs. call-by-name
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 21 / 22
Appendix
Bibliography
P.B. Levy.
Call-by-push-value.
PhD thesis, Queen Mary, University of London, 2001.
Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 22 / 22

More Related Content

What's hot

International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI)International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI)inventionjournals
 
Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...Federico Cerutti
 
Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...Federico Cerutti
 
Conflicts between relevance-sensitive revision
Conflicts between relevance-sensitive revisionConflicts between relevance-sensitive revision
Conflicts between relevance-sensitive revisionstellaseremetaki
 
Argumentation in Artificial Intelligence
Argumentation in Artificial IntelligenceArgumentation in Artificial Intelligence
Argumentation in Artificial IntelligenceFederico Cerutti
 
Bodecoban ngobaochau
Bodecoban ngobaochauBodecoban ngobaochau
Bodecoban ngobaochauDuong Tran
 
5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)Jan Plaza
 
Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Omnia A. Abdullah
 
5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.Jan Plaza
 
Darmon Points: an overview
Darmon Points: an overviewDarmon Points: an overview
Darmon Points: an overviewmmasdeu
 
Fundamental Theorem of Calculus
Fundamental Theorem of CalculusFundamental Theorem of Calculus
Fundamental Theorem of Calculusgizemk
 
D. h. fremlin measure theory, volume 5, part 1 (2000, torres fremlin)
D. h. fremlin   measure theory, volume 5, part 1   (2000, torres fremlin)D. h. fremlin   measure theory, volume 5, part 1   (2000, torres fremlin)
D. h. fremlin measure theory, volume 5, part 1 (2000, torres fremlin)Bluewworksblue
 
Truth as a logical connective
Truth as a logical connectiveTruth as a logical connective
Truth as a logical connectiveShunsuke Yatabe
 
Geometry Section 4-3
Geometry Section 4-3Geometry Section 4-3
Geometry Section 4-3Jimbo Lamb
 
Quantum optical models in noncommutative spaces
Quantum optical models in noncommutative spacesQuantum optical models in noncommutative spaces
Quantum optical models in noncommutative spacesSanjib Dey
 

What's hot (19)

10.1.1.226.4381
10.1.1.226.438110.1.1.226.4381
10.1.1.226.4381
 
International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI)International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI)
 
Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Right m...
 
Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...
Argumentation in Artificial Intelligence: 20 years after Dung's work. Left ma...
 
Conflicts between relevance-sensitive revision
Conflicts between relevance-sensitive revisionConflicts between relevance-sensitive revision
Conflicts between relevance-sensitive revision
 
Argumentation in Artificial Intelligence
Argumentation in Artificial IntelligenceArgumentation in Artificial Intelligence
Argumentation in Artificial Intelligence
 
Bodecoban ngobaochau
Bodecoban ngobaochauBodecoban ngobaochau
Bodecoban ngobaochau
 
5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)5.8 Permutations (dynamic slides)
5.8 Permutations (dynamic slides)
 
AI Lesson 14
AI Lesson 14AI Lesson 14
AI Lesson 14
 
Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Discrete Mathematics - All chapters
Discrete Mathematics - All chapters
 
5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.
 
Darmon Points: an overview
Darmon Points: an overviewDarmon Points: an overview
Darmon Points: an overview
 
Chap05
Chap05Chap05
Chap05
 
Fundamental Theorem of Calculus
Fundamental Theorem of CalculusFundamental Theorem of Calculus
Fundamental Theorem of Calculus
 
AI Lesson 15
AI Lesson 15AI Lesson 15
AI Lesson 15
 
D. h. fremlin measure theory, volume 5, part 1 (2000, torres fremlin)
D. h. fremlin   measure theory, volume 5, part 1   (2000, torres fremlin)D. h. fremlin   measure theory, volume 5, part 1   (2000, torres fremlin)
D. h. fremlin measure theory, volume 5, part 1 (2000, torres fremlin)
 
Truth as a logical connective
Truth as a logical connectiveTruth as a logical connective
Truth as a logical connective
 
Geometry Section 4-3
Geometry Section 4-3Geometry Section 4-3
Geometry Section 4-3
 
Quantum optical models in noncommutative spaces
Quantum optical models in noncommutative spacesQuantum optical models in noncommutative spaces
Quantum optical models in noncommutative spaces
 

Similar to Continuation calculus at Term Rewriting Seminar

2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting PosterChelsea Battell
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionEelco Visser
 
Applications of partial differentiation
Applications of partial differentiationApplications of partial differentiation
Applications of partial differentiationVaibhav Tandel
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus AhsanIrshad8
 
Testing Forest-Isomorphism in the Adjacency List Model
Testing Forest-Isomorphismin the Adjacency List ModelTesting Forest-Isomorphismin the Adjacency List Model
Testing Forest-Isomorphism in the Adjacency List Modelirrrrr
 
Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...
Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...
Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...Kenshi Abe
 
Data Science Meetup: DGLARS and Homotopy LASSO for Regression Models
Data Science Meetup: DGLARS and Homotopy LASSO for Regression ModelsData Science Meetup: DGLARS and Homotopy LASSO for Regression Models
Data Science Meetup: DGLARS and Homotopy LASSO for Regression ModelsColleen Farrelly
 
Optimization of probabilistic argumentation with Markov processes
Optimization of probabilistic argumentation with Markov processesOptimization of probabilistic argumentation with Markov processes
Optimization of probabilistic argumentation with Markov processesEmmanuel Hadoux
 
Reciprocity Law For Flat Conformal Metrics With Conical Singularities
Reciprocity Law For Flat Conformal Metrics With Conical SingularitiesReciprocity Law For Flat Conformal Metrics With Conical Singularities
Reciprocity Law For Flat Conformal Metrics With Conical SingularitiesLukasz Obara
 
Fixed point result in menger space with ea property
Fixed point result in menger space with ea propertyFixed point result in menger space with ea property
Fixed point result in menger space with ea propertyAlexander Decker
 
Prime numbers boundary
Prime numbers boundary Prime numbers boundary
Prime numbers boundary Camilo Ulloa
 
The Chase in Database Theory
The Chase in Database TheoryThe Chase in Database Theory
The Chase in Database TheoryJan Hidders
 
Darmon Points for fields of mixed signature
Darmon Points for fields of mixed signatureDarmon Points for fields of mixed signature
Darmon Points for fields of mixed signaturemmasdeu
 
A Theory of the Learnable; PAC Learning
A Theory of the Learnable; PAC LearningA Theory of the Learnable; PAC Learning
A Theory of the Learnable; PAC Learningdhruvgairola
 

Similar to Continuation calculus at Term Rewriting Seminar (20)

Pl vol1
Pl vol1Pl vol1
Pl vol1
 
2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster
 
Unit05 dbms
Unit05 dbmsUnit05 dbms
Unit05 dbms
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Applications of partial differentiation
Applications of partial differentiationApplications of partial differentiation
Applications of partial differentiation
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus
 
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
 
Testing Forest-Isomorphism in the Adjacency List Model
Testing Forest-Isomorphismin the Adjacency List ModelTesting Forest-Isomorphismin the Adjacency List Model
Testing Forest-Isomorphism in the Adjacency List Model
 
Big o
Big oBig o
Big o
 
Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...
Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...
Competitive Multi-agent Inverse Reinforcement Learning with Sub-optimal Demon...
 
Data Science Meetup: DGLARS and Homotopy LASSO for Regression Models
Data Science Meetup: DGLARS and Homotopy LASSO for Regression ModelsData Science Meetup: DGLARS and Homotopy LASSO for Regression Models
Data Science Meetup: DGLARS and Homotopy LASSO for Regression Models
 
Optimization of probabilistic argumentation with Markov processes
Optimization of probabilistic argumentation with Markov processesOptimization of probabilistic argumentation with Markov processes
Optimization of probabilistic argumentation with Markov processes
 
Reciprocity Law For Flat Conformal Metrics With Conical Singularities
Reciprocity Law For Flat Conformal Metrics With Conical SingularitiesReciprocity Law For Flat Conformal Metrics With Conical Singularities
Reciprocity Law For Flat Conformal Metrics With Conical Singularities
 
H-MLQ
H-MLQH-MLQ
H-MLQ
 
Fixed point result in menger space with ea property
Fixed point result in menger space with ea propertyFixed point result in menger space with ea property
Fixed point result in menger space with ea property
 
Prime numbers boundary
Prime numbers boundary Prime numbers boundary
Prime numbers boundary
 
The Chase in Database Theory
The Chase in Database TheoryThe Chase in Database Theory
The Chase in Database Theory
 
04_AJMS_254_19.pdf
04_AJMS_254_19.pdf04_AJMS_254_19.pdf
04_AJMS_254_19.pdf
 
Darmon Points for fields of mixed signature
Darmon Points for fields of mixed signatureDarmon Points for fields of mixed signature
Darmon Points for fields of mixed signature
 
A Theory of the Learnable; PAC Learning
A Theory of the Learnable; PAC LearningA Theory of the Learnable; PAC Learning
A Theory of the Learnable; PAC Learning
 

Recently uploaded

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Recently uploaded (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Continuation calculus at Term Rewriting Seminar

  • 1. Continuation calculus Bram Geron1 Herman Geuvers1,2 1Eindhoven University of Technology 2Radboud University Nijmegen Term Rewriting Seminar, May 2013 Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 1 / 22
  • 2. Outline 1 First look 2 Definition 3 Long-term goal 4 Interfaces, not pattern matching 5 The importance of head reduction 6 Relation to lambda calculus 7 Conclusion Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 2 / 22
  • 3. First look Rules, names, variables, terms CC is a constrained term rewriting system Comp.f .g.x def −→ f .(g.x) Comp.AddOne.Fact.4 → AddOne.(Fact.4) Rules One definition per name (max) No pattern matching Only head reduction Consequences Deterministic Simple operational semantics Suitable for modeling continuations, hence exceptions Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 3 / 22
  • 4. First look Rules, names, variables, terms CC is a constrained term rewriting system rule Comp name (constant) .f .g.x variables def −→ f .(g.x) Comp.AddOne.Fact.4 term → AddOne.(Fact.4) term Rules One definition per name (max) No pattern matching Only head reduction Consequences Deterministic Simple operational semantics Suitable for modeling continuations, hence exceptions Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 3 / 22
  • 5. First look Rules, names, variables, terms CC is a constrained term rewriting system rule Comp name (constant) .f .g.x variables def −→ f .(g.x) Comp.AddOne.Fact.4 term → AddOne.(Fact.4) term Rules One definition per name (max) No pattern matching Only head reduction Consequences Deterministic Simple operational semantics Suitable for modeling continuations, hence exceptions Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 3 / 22
  • 6. First look Head reduction: continuation passing style Functions fill in the result in their continuation parameter Comp.f .g.x def −→ f .(g.x) Comp.AddOne.Fact.4 → AddOne.(Fact).4 Realistic names: Fact.r.x r.x! AddOne.r.x r.(x +1) Fact.(AddOne.r).4 AddOne.r.24 r.25 Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
  • 7. First look Head reduction: continuation passing style Functions fill in the result in their continuation parameter Comp.f .g.x def −→ f .(g.x) Comp.AddOne.Fact.4 → AddOne.(Fact).4 Realistic names: Fact.r.x r.x! AddOne.r.x r.(x +1) Fact.(AddOne.r).4 AddOne.r.24 r.25 Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
  • 8. First look Head reduction: continuation passing style Functions fill in the result in their continuation parameter Comp.f .g.x def −→ f .(g.x) Comp.AddOne.Fact.4 → AddOne.(Fact).4 Realistic names: Fact.r.x r.x! AddOne.r.x r.(x +1) Fact.(AddOne.r).4 AddOne.r.24 r.25 Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
  • 9. First look Head reduction: continuation passing style Functions fill in the result in their continuation parameter Comp.r.f .g.x def −→ g.(f .r).x Comp.r.AddOne.Fact.4 → Fact.(AddOne.r).4 Realistic names: Fact.r.x r.x! AddOne.r.x r.(x +1) Fact.(AddOne.r).4 AddOne.r.24 r.25 Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
  • 10. First look Head reduction: continuation passing style Functions fill in the result in their continuation parameter Comp.r.f .g.x def −→ g.(f .r).x Comp.r.AddOne.Fact.4 → Fact.(AddOne.r).4 Realistic names: Fact.r.x r.x! AddOne.r.x r.(x +1) Fact.(AddOne.r).4 AddOne.r.24 r.25 Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 4 / 22
  • 11. Definition Definitions There is an infinite set of names, indicated by a capital. A term is either a name, or two terms combined by a dot. We write a.b.c as shorthand for (a.b).c. A program P consists of a set of rules, of the form Name.variable.··· .variable def −→ term over those variables That rule defines that name. Each rule defines a different name. If “N.x1 .··· .xk def −→ r” ∈ P, then we reduce N.t → r[t/x]. Term N.x1.··· .xl for l = k does not reduce at all. There is only head reduction. Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 5 / 22
  • 12. Definition Definitions There is an infinite set of names, indicated by a capital. A term is either a name, or two terms combined by a dot. We write a.b.c as shorthand for (a.b).c. A program P consists of a set of rules, of the form Name.variable.··· .variable def −→ term over those variables That rule defines that name. Each rule defines a different name. If “N.x1 .··· .xk def −→ r” ∈ P, then we reduce N.t → r[t/x]. Term N.x1.··· .xl for l = k does not reduce at all. There is only head reduction. Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 5 / 22
  • 13. Definition Definitions There is an infinite set of names, indicated by a capital. A term is either a name, or two terms combined by a dot. We write a.b.c as shorthand for (a.b).c. A program P consists of a set of rules, of the form Name.variable.··· .variable def −→ term over those variables That rule defines that name. Each rule defines a different name. If “N.x1 .··· .xk def −→ r” ∈ P, then we reduce N.t → r[t/x]. Term N.x1.··· .xl for l = k does not reduce at all. There is only head reduction. Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 5 / 22
  • 14. Long-term goal Long-term goal Formally modeling programming languages Hopefully as a base for better languages Operational semantics Running time: #steps ∼ seconds CPU time Warning: some unsubstantiated claims Compositional Facilitates proving properties Deterministic by nature Works with continuations Explained later Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 6 / 22
  • 15. Long-term goal Long-term goal Formally modeling programming languages Hopefully as a base for better languages Operational semantics Running time: #steps ∼ seconds CPU time Warning: some unsubstantiated claims Compositional Facilitates proving properties Deterministic by nature Works with continuations Explained later Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 6 / 22
  • 16. Interfaces, not pattern matching Outline 1 First look 2 Definition 3 Long-term goal 4 Interfaces, not pattern matching 5 The importance of head reduction 6 Relation to lambda calculus 7 Conclusion Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 7 / 22
  • 17. Interfaces, not pattern matching Outline 1 First look 2 Definition 3 Long-term goal 4 Interfaces, not pattern matching 5 The importance of head reduction 6 Relation to lambda calculus 7 Conclusion Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 8 / 22
  • 18. Interfaces, not pattern matching Natural numbers Slightly similar to lambda calculus Zero.z.s def −→ z S.x.z.s def −→ s.x Add.r.x.y def −→ y.(r.x).(Add.r.(S.x)) Algorithm: x +0 = x x +S(y) = S(x)+y Add.r.(S.Zero).Zero → Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero))) → r.(S.Zero) Add.r.Zero.(S.Zero) → S.Zero.(r.Zero).(Add.r.(S.Zero)) → Add.r.(S.Zero).Zero → Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero))) → r.(S.Zero) Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 9 / 22
  • 19. Interfaces, not pattern matching Natural numbers Slightly similar to lambda calculus Zero.z.s def −→ z S.x.z.s def −→ s.x Add.r.x.y def −→ y.(r.x).(Add.r.(S.x)) Algorithm: x +0 = x x +S(y) = S(x)+y Add.r.(S.Zero).Zero → Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero))) → r.(S.Zero) Add.r.Zero.(S.Zero) → S.Zero.(r.Zero).(Add.r.(S.Zero)) → Add.r.(S.Zero).Zero → Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero))) → r.(S.Zero) Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 9 / 22
  • 20. Interfaces, not pattern matching Natural numbers Slightly similar to lambda calculus Zero.z.s def −→ z S.x.z.s def −→ s.x Add.r.x.y def −→ y.(r.x).(Add.r.(S.x)) Algorithm: x +0 = x x +S(y) = S(x)+y What can we feed to Add? Zero S.(··· .(S.Zero)···) Something else? Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 10 / 22
  • 21. Interfaces, not pattern matching Natural numbers Slightly similar to lambda calculus Zero.z.s def −→ z S.x.z.s def −→ s.x Add.r.x.y def −→ y.(r.x).(Add.r.(S.x)) Algorithm: x +0 = x x +S(y) = S(x)+y What can we feed to Add? Zero S.(··· .(S.Zero)···) Something else? Yes! Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 10 / 22
  • 22. Interfaces, not pattern matching Natural numbers Compatible naturals Zero.z.s def −→ z S.x.z.s def −→ s.x Add.r.x.y def −→ y.(r.x).(Add.r.(S.x)) Algorithm: x +0 = x x +S(y) = S(x)+y We define when a term t represents natural number n. 1 t represents 0 if ∀z,s : t.z.s z Informally: t “behaves the same as” Zero 2 t represents n +1 if ∀z,s : t.z.s s.q, and q represents n Informally: t “behaves the same as” S.q With this, we can define LazyFact such that LazyFact.x represents (x!). (Omitted.) Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 11 / 22
  • 23. Interfaces, not pattern matching Natural numbers Compatible naturals Zero.z.s def −→ z S.x.z.s def −→ s.x Add.r.x.y def −→ y.(r.x).(Add.r.(S.x)) Algorithm: x +0 = x x +S(y) = S(x)+y With this, we can define LazyFact such that LazyFact.x represents (x!). (Omitted.) Add.r.Zero.(LazyFact.(S.Zero)) → LazyFact.(S.Zero).(r.Zero).(Add.r.(S.Zero)) Add.r.(S.Zero).Zero → Zero.(r.(S.Zero)).(Add.r.(S.(S.Zero))) → r.(S.Zero) Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 11 / 22
  • 24. Interfaces, not pattern matching Natural numbers Compatible naturals Zero.z.s def −→ z S.x.z.s def −→ s.x Add.r.x.y def −→ y.(r.x).(Add.r.(S.x)) Algorithm: x +0 = x x +S(y) = S(x)+y With this, we can define LazyFact such that LazyFact.x represents (x!). (Omitted.) Add.r.Zero.(LazyFact.(S.Zero)) r.(S.Zero) Two types of function names Call-by-value / eager: calculate result, fill in in continuation Call-by-name / lazy: compatible with Sn.Zero but delayed computation Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 11 / 22
  • 25. The importance of head reduction Outline 1 First look 2 Definition 3 Long-term goal 4 Interfaces, not pattern matching 5 The importance of head reduction 6 Relation to lambda calculus 7 Conclusion Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 12 / 22
  • 26. The importance of head reduction Outline 1 First look 2 Definition 3 Long-term goal 4 Interfaces, not pattern matching 5 The importance of head reduction 6 Relation to lambda calculus 7 Conclusion Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 13 / 22
  • 27. The importance of head reduction Operational semantics Lambda calculus (normal order) Reduction using two instructions on the top level M N Push N on stack, continue in M λx.M Pop N off stack, continue in M[N/x] as presented in [Levy(2001)] Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 14 / 22
  • 28. The importance of head reduction Back to modeling programs Lambda calculus λx.+ (f x) (g x) M N Push N on stack, continue in M λx.M Pop N off stack, continue in M[N/x] Programming language fun x → (f x) + (g x) M N Apply function object to argument fun x → M Make function object In “real languages”, functions throw exceptions and have other side effects. Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 15 / 22
  • 29. The importance of head reduction Back to modeling programs Lambda calculus λx.+ (f x) (g x) M N Push N on stack, continue in M λx.M Pop N off stack, continue in M[N/x] Programming language fun x → (f x) + (g x) throws exception now what? M N Apply function object to argument fun x → M Make function object In “real languages”, functions throw exceptions and have other side effects. Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 15 / 22
  • 30. The importance of head reduction Operational semantics Computational models with control Lambda calculus + continuations (λC) Reduction using four instructions on the top level M N Push N on stack, continue in M λx.M Pop N off stack, continue in M[N/x] A M Empty the stack, continue in M C M Empty the stack, continue in M (λx.S x) where function S ‘restores’ the previous stack (details omitted) Can model exception-like facilities CPS transformation to transform λC terms to λ terms Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 16 / 22
  • 31. The importance of head reduction CPS transformation λC CPS transformation −−−−−−−−−−−→ subset of λ, makes minimal use of stack Two calculi in action: λC calculus: M N, λx.M, A M, C M Expressive Subset of λ calculus: M N, λx.M Simpler Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
  • 32. The importance of head reduction CPS transformation λC CPS transformation −−−−−−−−−−−→ subset of λ, makes minimal use of stack Two calculi in action: λC calculus: M N, λx.M, A M, C M Expressive Subset of λ calculus: M N, λx.M Simpler What is this subset, really? Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
  • 33. The importance of head reduction CPS transformation λC CPS transformation −−−−−−−−−−−→ subset of λ, makes minimal use of stack Two calculi in action: λC calculus: M N, λx.M, A M, C M Expressive Subset of λ calculus: M N, λx.M Simpler What is this subset, really? Can we describe it? Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
  • 34. The importance of head reduction CPS transformation λC CPS transformation −−−−−−−−−−−→ subset of λ, makes minimal use of stack Two calculi in action: λC calculus: M N, λx.M, A M, C M Expressive Subset of λ calculus: M N, λx.M Simpler What is this subset, really? Can we describe it? An elegant model of computation, perhaps? Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 17 / 22
  • 35. The importance of head reduction Lambda calculus vs. continuation calculus λC Four instructions on the top level M N Push N on stack, continue in M λx.M Pop N off stack, continue in M[N/x] A M Empty the stack, continue in M C M Empty the stack, continue in M (λx.S x) where function S ‘restores’ the stack Continuation calculus One instruction on the top level, using program P n.t1.··· .tk Empty the stack, continue in r[t/x] if n.x1 .··· .xk def −→ r ∈ P Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 18 / 22
  • 36. The importance of head reduction Lambda calculus vs. continuation calculus λC Four instructions on the top level M N Push N on stack, continue in M λx.M Pop N off stack, continue in M[N/x] A M Empty the stack, continue in M C M Empty the stack, continue in M (λx.S x) where function S ‘restores’ the stack Continuation calculus One instruction on the top level, using program P n.t1.··· .tk Empty the stack, continue in r[t/x] if n.x1 .··· .xk def −→ r ∈ P Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 18 / 22
  • 37. The importance of head reduction Continuation calculus Continuation calculus One instruction on the top level, using program P n.t1.··· .tk Continue in r[t/x] if n.x1 .··· .xk def −→ r ∈ P No stack needed, because n.t1.··· .tl does not reduce for l = k. Subterms are not reduced Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 19 / 22
  • 38. Relation to lambda calculus Relation to lambda calculus λ,λC CPS transformation −−−−−−−−−−−→ subset of λ subset of λ λx to rules∗ −−−−−−−−−−−−−−−−−−−−−− unfold† rules to λx CC ∗ λx to rules: involves a supercombinator transformation † Unfold rules to λx: first apply a fixed-point elimination to eliminate cyclic references Catchphrase CC is more limited than λ, thus more suitable to model continuations Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 20 / 22
  • 39. Relation to lambda calculus Relation to lambda calculus λ,λC CPS transformation −−−−−−−−−−−→ subset of λ subset of λ λx to rules∗ −−−−−−−−−−−−−−−−−−−−−− unfold† rules to λx CC ∗ λx to rules: involves a supercombinator transformation † Unfold rules to λx: first apply a fixed-point elimination to eliminate cyclic references Catchphrase CC is more limited than λ, thus more suitable to model continuations Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 20 / 22
  • 40. Conclusion Conclusion CC is a constrained term rewriting system CC is deterministic Only head reduction As a consequence, Suitable for control with continuations (exceptions) CC is similar to a subset of lambda calculus Allows both eager and lazy function terms call-by-value vs. call-by-name Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 21 / 22
  • 41. Appendix Bibliography P.B. Levy. Call-by-push-value. PhD thesis, Queen Mary, University of London, 2001. Geron, Geuvers (TU/e, RU) Continuation calculus TERESE May 2013 22 / 22