Continuation calculus (CC) is an alternative to lambda calculus, where the order of evaluation is determined by programs themselves. Owing to its simplicity, continuations are no unusual terms. This makes it natural to model programs with nonlocal control flow, as with exceptions and call-by-name functions.
This presentation includes the list multiplication example.
Understanding Dynamic Programming through Bellman OperatorsAshwin Rao
Policy Iteration and Value Iteration algorithms are best understood by viewing them from the lens of Bellman Policy Operator and Bellman Optimality Operator
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...Quantopian
We will present the most general model of the type considered by Black and Litterman (1991) after fully clarifying the duality between Black–Litterman optimization and Bayesian regression.
Our generalization is itself a special case of a Bayesian network or graphical model. As an example, we will work out in full detail the treatment of views on factor risk premia in the context of APT.
We will also consider a more speculative example in which the portfolio manager specifies a view on realized volatility by trading a variance swap.
Understanding Dynamic Programming through Bellman OperatorsAshwin Rao
Policy Iteration and Value Iteration algorithms are best understood by viewing them from the lens of Bellman Policy Operator and Bellman Optimality Operator
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...Quantopian
We will present the most general model of the type considered by Black and Litterman (1991) after fully clarifying the duality between Black–Litterman optimization and Bayesian regression.
Our generalization is itself a special case of a Bayesian network or graphical model. As an example, we will work out in full detail the treatment of views on factor risk premia in the context of APT.
We will also consider a more speculative example in which the portfolio manager specifies a view on realized volatility by trading a variance swap.
RuleML 2015 Constraint Handling Rules - What Else?RuleML
Constraint Handling Rules (CHR) is both a versatile theoretical formalism based on logic and an efficient practical high-level programming language based on rules and constraints.
Procedural knowledge is often expressed by if-then rules, events and actions are related by reaction rules, change is expressed by update rules. Algorithms are often specified using inference rules, rewrite rules, transition rules, sequents, proof rules, or logical axioms. All these kinds of rules can be directly written in CHR. The clean logical semantics of CHR facilitates non-trivial program analysis and transformation. About a dozen implementations of CHR exist in Prolog, Haskell, Java, Javascript and C. Some of them allow to apply millions of rules per second. CHR is also available as WebCHR for online experimentation with more than 40 example programs. More than 200 academic and industrial projects worldwide use CHR, and about 2000 research papers reference it.
Characterizing the Distortion of Some Simple Euclidean EmbeddingsDon Sheehy
This talk addresses some upper and lower bounds techniques for bounding the distortion between mappings between Euclidean metric spaces including circles, spheres, pairs of lines, triples of planes, and the union of a hyperplane and a point.
Program Derivation of Operations in Finite Fields of Prime OrderCharles Southerland
The higher-quality version of my undergraduate research presentation (still some typos and missing formulas, but better explanations, more pleasing layout, more coherent analysis, etc.). Presented at Oklahoma Computing Consortium 2011.
Continuation calculus at Term Rewriting Seminarbgeron
Continuation calculus (CC) is an alternative to lambda calculus, where the order of evaluation is determined by programs themselves. Owing to its simplicity, continuations are no unusual terms. This makes it natural to model programs with nonlocal control flow, as with exceptions and call-by-name functions.
RuleML 2015 Constraint Handling Rules - What Else?RuleML
Constraint Handling Rules (CHR) is both a versatile theoretical formalism based on logic and an efficient practical high-level programming language based on rules and constraints.
Procedural knowledge is often expressed by if-then rules, events and actions are related by reaction rules, change is expressed by update rules. Algorithms are often specified using inference rules, rewrite rules, transition rules, sequents, proof rules, or logical axioms. All these kinds of rules can be directly written in CHR. The clean logical semantics of CHR facilitates non-trivial program analysis and transformation. About a dozen implementations of CHR exist in Prolog, Haskell, Java, Javascript and C. Some of them allow to apply millions of rules per second. CHR is also available as WebCHR for online experimentation with more than 40 example programs. More than 200 academic and industrial projects worldwide use CHR, and about 2000 research papers reference it.
Characterizing the Distortion of Some Simple Euclidean EmbeddingsDon Sheehy
This talk addresses some upper and lower bounds techniques for bounding the distortion between mappings between Euclidean metric spaces including circles, spheres, pairs of lines, triples of planes, and the union of a hyperplane and a point.
Program Derivation of Operations in Finite Fields of Prime OrderCharles Southerland
The higher-quality version of my undergraduate research presentation (still some typos and missing formulas, but better explanations, more pleasing layout, more coherent analysis, etc.). Presented at Oklahoma Computing Consortium 2011.
Continuation calculus at Term Rewriting Seminarbgeron
Continuation calculus (CC) is an alternative to lambda calculus, where the order of evaluation is determined by programs themselves. Owing to its simplicity, continuations are no unusual terms. This makes it natural to model programs with nonlocal control flow, as with exceptions and call-by-name functions.
In mathematics, a partial derivative of a function of several variables is its derivative with respect to one of those variables, with the others held constant (as opposed to the total derivative, in which all variables are allowed to vary). Partial derivatives are used in vector calculus and differential geometry.
TreeNet is Salford's most flexible and powerful data mining tool, capable of consistently generating extremely accurate models. TreeNet has been responsible for the majority of Salford’s modeling competition awards. TreeNet demonstrates remarkable performance for both regression and classification. The algorithm typically generates thousands of small decision trees built in a sequential error–correcting process to converge to an accurate model.
AIOU Code 803 Mathematics for Economists Semester Spring 2022 Assignment 2.pptxZawarali786
Skilling Foundation
Download Free
Past Papers
Guess Papers
Solved Assignments
Solved Thesis
Solved Lesson Plans
PDF Books
Skilling.pk
Other Websites
Diya.pk
Stamflay.com
Please Subscribe Our YouTube Channel
Skilling Foundation:https://bit.ly/3kEJI0q
WordPress Tutorials:https://bit.ly/3rqcgfE
Stamflay:https://bit.ly/2AoClW8
Please Contact at:
0314-4646739
0332-4646739
0336-4646739
اگر آپ تعلیمی نیوز، رجسٹریشن، داخلہ، ڈیٹ شیٹ، رزلٹ، اسائنمنٹ،جابز اور باقی تمام اپ ڈیٹس اپنے موبائل پر فری حاصل کرنا چاہتے ہیں ۔تو نیچے دیے گئے واٹس ایپ نمبرکو اپنے موبائل میں سیو کرکے اپنا نام لکھ کر واٹس ایپ کر دیں۔ سٹیٹس روزانہ لازمی چیک کریں۔
نوٹ : اس کے علاوہ تمام یونیورسٹیز کے آن لائن داخلے بھجوانے اور جابز کے لیے آن لائن اپلائی کروانے کے لیے رابطہ کریں۔
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Accelerate your Kubernetes clusters with Varnish Caching
Colloquium presentation
1. Continuation calculus
An alternative to lambda calculus
Midterm presentation
Bram Geron
(supervised by Herman Geuvers)
Eindhoven University of Technology
FSA colloquium, June 2013
Bram Geron (TU/e) Continuation calculus FSA colloquium 1 / 31
2. Modeling programming languages
Goals:
Assign exact meaning to programs
Assign exact meaning to functions
Reason on functions
Approaches:
Big-step semantics
Small-step semantics
Reduction to simpler calculus
Bram Geron (TU/e) Continuation calculus FSA colloquium 2 / 31
3. Modeling programming languages
Goals:
Assign exact meaning to programs
Assign exact meaning to functions
Reason on functions
Approaches:
Big-step semantics: lambda calculus
Small-step semantics: lambda calculus, continuation calculus
Reduction to simpler calculus: programming languages to λ or CC
Bram Geron (TU/e) Continuation calculus FSA colloquium 2 / 31
4. Modeling programming languages
Simple calculi
Lambda calculus
Tree of expressions
(fact 4)+1
β 25
Continuation calculus
Tree of “continuation terms”
Fact.(AddOne.Return).4
Return.25
Bram Geron (TU/e) Continuation calculus FSA colloquium 3 / 31
5. First look
Outline
1 First look
2 Definition
3 Long-term goal
4 The importance of head reduction
5 Case study: list multiplication
6 Conclusion
Bram Geron (TU/e) Continuation calculus FSA colloquium 4 / 31
6. First look Rules, names, variables, terms
CC is a term rewriting system in a constrained shape
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
Bram Geron (TU/e) Continuation calculus FSA colloquium 5 / 31
7. First look Rules, names, variables, terms
CC is a term rewriting system in a constrained shape
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
Bram Geron (TU/e) Continuation calculus FSA colloquium 5 / 31
8. First look Rules, names, variables, terms
CC is a term rewriting system in a constrained shape
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
Bram Geron (TU/e) Continuation calculus FSA colloquium 5 / 31
9. 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
−→ CPS transformation
Bram Geron (TU/e) Continuation calculus FSA colloquium 6 / 31
10. 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
−→ CPS transformation
Bram Geron (TU/e) Continuation calculus FSA colloquium 6 / 31
11. 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
−→ CPS transformation
Bram Geron (TU/e) Continuation calculus FSA colloquium 6 / 31
12. 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
−→ CPS transformation
Bram Geron (TU/e) Continuation calculus FSA colloquium 6 / 31
13. 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
−→ CPS transformation
Bram Geron (TU/e) Continuation calculus FSA colloquium 6 / 31
14. 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
−→ CPS transformation
Bram Geron (TU/e) Continuation calculus FSA colloquium 6 / 31
15. First look Another example
Natural numbers
Representation and AddOne
We represent 0 by Zero, 3 by S.(S.(S.Zero)), and n by
S.(··· .(S.Zero)···). These terms are denoted n .
We implement the function AddOne, such that AddOne.r. n r. n +1 .
AddOne.r.m
def
−→ r.(S.m)
Bram Geron (TU/e) Continuation calculus FSA colloquium 7 / 31
16. First look Another example
Natural numbers
Behavior and Double
We represent 0 by Zero, 3 by S.(S.(S.Zero)), and n by
S.(··· .(S.Zero)···). These terms are denoted n .
There are rules for Zero and S:
Zero.z.s
def
−→ z s.t. 0 .z.s z
S.m.z.s
def
−→ s.m s.t. m +1 .z.s s. m
We can now make a function Double such that Double.r. n r. 2n .
Double.r.m
def
−→ m.(r.Zero).(Double.(AddOne.(AddOne.r)))
Bram Geron (TU/e) Continuation calculus FSA colloquium 8 / 31
17. First look Another example
Natural numbers
Behavior and Double
We represent 0 by Zero, 3 by S.(S.(S.Zero)), and n by
S.(··· .(S.Zero)···). These terms are denoted n .
We can now make a function Double such that Double.r. n r. 2n .
Double.r.m
def
−→ m.(r.Zero).(Double.(AddOne.(AddOne.r)))
Bram Geron (TU/e) Continuation calculus FSA colloquium 8 / 31
18. First look Another example
Natural numbers
Behavior and Double
We represent 0 by Zero, 3 by S.(S.(S.Zero)), and n by
S.(··· .(S.Zero)···). These terms are denoted n .
We can now make a function Double such that Double.r. n r. 2n .
Double.r.m
def
−→ m.(r.Zero).(Double.(AddOne.(AddOne.r)))
Double.r. 0 → Zero.(r. 0 ).(Double.(AddOne.(AddOne.r)))
→ r. 0
Bram Geron (TU/e) Continuation calculus FSA colloquium 8 / 31
19. First look Another example
Natural numbers
Behavior and Double
We represent 0 by Zero, 3 by S.(S.(S.Zero)), and n by
S.(··· .(S.Zero)···). These terms are denoted n .
We can now make a function Double such that Double.r. n r. 2n .
Double.r.m
def
−→ m.(r.Zero).(Double.(AddOne.(AddOne.r)))
Double.r. 2 → S. 1 .(r. 0 ).(Double.(AddOne.(AddOne.r)))
→ Double.(AddOne.(AddOne.r)). 1
→ S. 0 .(AddOne.(AddOne.r). 0 ).(Double.(AddOne.(AddOne.(AddOne.(Add
→ Double.(AddOne.(AddOne.(AddOne.(AddOne.r)))). 0
→ Zero.(AddOne.(AddOne.(AddOne.(AddOne.r))). 0 ).(Double.(AddOne.(Ad
→ AddOne.(AddOne.(AddOne.(AddOne.r))). 0
r. 4 in 4 steps
Bram Geron (TU/e) Continuation calculus FSA colloquium 8 / 31
20. 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.
Bram Geron (TU/e) Continuation calculus FSA colloquium 9 / 31
21. 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.
Bram Geron (TU/e) Continuation calculus FSA colloquium 9 / 31
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.
Bram Geron (TU/e) Continuation calculus FSA colloquium 9 / 31
23. 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 10 / 31
24. 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 10 / 31
25. The importance of head reduction
Outline
1 First look
2 Definition
3 Long-term goal
4 The importance of head reduction
5 Case study: list multiplication
6 Conclusion
Bram Geron (TU/e) Continuation calculus FSA colloquium 11 / 31
26. The importance of head reduction
Outline
1 First look
2 Definition
3 Long-term goal
4 The importance of head reduction
5 Case study: list multiplication
6 Conclusion
Bram Geron (TU/e) Continuation calculus FSA colloquium 12 / 31
27. 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.
Bram Geron (TU/e) Continuation calculus FSA colloquium 13 / 31
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)
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.
Bram Geron (TU/e) Continuation calculus FSA colloquium 13 / 31
29. 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 14 / 31
30. 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 15 / 31
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
What is this subset, really?
Bram Geron (TU/e) Continuation calculus FSA colloquium 15 / 31
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?
Can we describe it?
Bram Geron (TU/e) Continuation calculus FSA colloquium 15 / 31
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?
An elegant model of computation, perhaps?
Bram Geron (TU/e) Continuation calculus FSA colloquium 15 / 31
34. 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 16 / 31
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
Bram Geron (TU/e) Continuation calculus FSA colloquium 16 / 31
36. 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 17 / 31
37. Case study: list multiplication
Outline
1 First look
2 Definition
3 Long-term goal
4 The importance of head reduction
5 Case study: list multiplication
6 Conclusion
Bram Geron (TU/e) Continuation calculus FSA colloquium 18 / 31
38. Case study: list multiplication
List multiplication
An algorithm
product [4,2,6] = 4∗2∗6 = 48
product l = case l of
| [] → 1
| [x]++xs → x ∗product xs
product [4,2,6] = 4∗(2∗(6∗1)) = 48
Bram Geron (TU/e) Continuation calculus FSA colloquium 19 / 31
39. Case study: list multiplication
List multiplication
An algorithm
product [4,2,6] = 4∗2∗6 = 48
product l = case l of
| [] → 1
| [x]++xs → x ∗product xs
product [4,2,6] = 4∗(2∗(6∗1)) = 48
Bram Geron (TU/e) Continuation calculus FSA colloquium 19 / 31
40. Case study: list multiplication
List multiplication
A better algorithm
product [4,0,6] = 4∗0∗6 = 0
product l = case l of
| [] → 1
| [x]++xs → x ∗product xs
product [4,0,6] = 4∗(0∗(6∗1)) = 0
Bram Geron (TU/e) Continuation calculus FSA colloquium 20 / 31
41. Case study: list multiplication
List multiplication
A better algorithm
product [4,0,6] = 4∗0∗6 = 0
product l =
try:
let subproduct l = case l of
| [] → 1
| [0]++xs → abort
| [x]++xs → x ∗subproduct xs
in subproduct l
catch abort :
0
Bram Geron (TU/e) Continuation calculus FSA colloquium 20 / 31
42. Case study: list multiplication
List multiplication
A better algorithm
product l =
try:
let subproduct l = case l of
| [] → 1
| [0]++xs → abort
| [x]++xs → x ∗subproduct xs
in subproduct l
catch abort :
0
product [4,0,6] = try: {4∗abort} catch abort : 0
= 0
Bram Geron (TU/e) Continuation calculus FSA colloquium 20 / 31
43. Case study: list multiplication
List multiplication
Implementation
Implemented ListMult with this behavior in continuation calculus
includes modeling of naturals and lists with CC rules
Proved correct
ListMult. l .r r. product l for all l ∈ ListN
Empirical evidence of efficiency
ListMult. [4,0,6] .r r. 0 in 10 steps
ListMult. [4,2,6] .r r. 48 in 339 steps
Bram Geron (TU/e) Continuation calculus FSA colloquium 21 / 31
44. Conclusion
Conclusion
CC is a term rewriting system in a constrained shape
CC is deterministic
Only head reduction
As a consequence,
Suitable for control with continuations (exceptions)
CC is similar to a subset of lambda calculus
Mimics running times of real programs to some degree
Bram Geron (TU/e) Continuation calculus FSA colloquium 22 / 31
45. Conclusion
Current state and future work
Joint paper with Herman Geuvers
Accepted in proceedings of COS 2013, 24–25 June
Future work:
Systematic translation of functional programming language to CC
Prove that this translation preserves semantics
Type system
Model hierarchical side-effects using an extension
Bram Geron (TU/e) Continuation calculus FSA colloquium 23 / 31
49. Extra slides 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 27 / 31
50. Extra slides 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 27 / 31
51. Extra slides 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)
Bram Geron (TU/e) Continuation calculus FSA colloquium 28 / 31
52. Extra slides 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)
Bram Geron (TU/e) Continuation calculus FSA colloquium 28 / 31
53. Extra slides 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?
Bram Geron (TU/e) Continuation calculus FSA colloquium 29 / 31
54. Extra slides 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!
Bram Geron (TU/e) Continuation calculus FSA colloquium 29 / 31
55. Extra slides 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.)
Bram Geron (TU/e) Continuation calculus FSA colloquium 30 / 31
56. Extra slides 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)
Bram Geron (TU/e) Continuation calculus FSA colloquium 30 / 31
57. Extra slides 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
Bram Geron (TU/e) Continuation calculus FSA colloquium 30 / 31