Content area

Abstract

Some effects are considered to be higher level than others. High-level effects provide expressive and succinct abstraction of programming concepts, while low-level effects allow more fine-grained control over program execution and resources. Yet, often it is desirable to write programs using the convenient abstraction offered by high-level effects, and meanwhile still benefit from the optimizations enabled by low-level effects. One solution is to translate high-level effects to low-level ones.

This paper studies how algebraic effects and handlers allow us to simulate high-level effects in terms of low-level effects. In particular, we focus on the interaction between state and nondeterminism known as the local state, as provided by Prolog. We map this high-level semantics in successive steps onto a low-level composite state effect, similar to that managed by Prolog’s Warren Abstract Machine. We first give a translation from the high-level local-state semantics to the low-level global-state semantics, by explicitly restoring state updates on backtracking. Next, we eliminate nondeterminism altogether in favour of a lower-level state containing a choicepoint stack. Then we avoid copying the state by restricting ourselves to incremental, reversible state updates. We show how these updates can be stored on a trail stack with another state effect. We prove the correctness of all our steps using program calculation where the fusion laws of effect handlers play a central role.

Details

Title
From high to low: Simulating nondeterminism and state with state
Author
Tang, Wenhao 1   VIAFID ORCID Logo  ; Schrijvers, Tom 2 

 The University of Edinburgh, Edinburgh, UK (e-mail: [email protected]
 Department of Computer Science, KU Leuven, Leuven, Belgium (e-mail: [email protected]
Publication title
Volume
34
Publication year
2024
Publication date
2024
Publisher
Cambridge University Press
Place of publication
Cambridge
Country of publication
United Kingdom
ISSN
09567968
e-ISSN
14697653
Source type
Scholarly Journal
Language of publication
English
Document type
Journal Article
Publication history
 
 
Milestone dates
2023-12-01 (Received); 2024-05-23 (Revised); 2024-09-12 (Accepted)
ProQuest document ID
3151096742
Document URL
https://www.proquest.com/scholarly-journals/high-low-simulating-nondeterminism-state-with/docview/3151096742/se-2?accountid=208611
Copyright
© The Author(s), 2025. Published by Cambridge University Press. This work is licensed under the Creative Commons Attribution License This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited. (the “License”). Notwithstanding the ProQuest Terms and Conditions, you may use this content in accordance with the terms of the License.
Last updated
2025-01-07
Database
ProQuest One Academic