5,739 research outputs found
Answer Refinement Modification: Refinement Type System for Algebraic Effects and Handlers
Algebraic effects and handlers are a mechanism to structure programs with
computational effects in a modular way. They are recently gaining popularity
and being adopted in practical languages, such as OCaml. Meanwhile, there has
been substantial progress in program verification via refinement type systems.
However, thus far, there has not been a satisfactory refinement type system for
algebraic effects and handlers. In this paper, we fill the void by proposing a
novel refinement type system for algebraic effects and handlers. The
expressivity and usefulness of algebraic effects and handlers come from their
ability to manipulate delimited continuations, but delimited continuations also
complicate programs' control flow and make their verification harder. To
address the complexity, we introduce a novel concept that we call answer
refinement modification (ARM for short), which allows the refinement type
system to precisely track what effects occur and in what order when a program
is executed, and reflect the information as modifications to the refinements in
the types of delimited continuations. We formalize our type system that
supports ARM (as well as answer type modification) and prove its soundness.
Additionally, as a proof of concept, we have implemented a corresponding type
checking and inference algorithm for a subset of OCaml 5, and evaluated it on a
number of benchmark programs. The evaluation demonstrates that ARM is
conceptually simple and practically useful. Finally, a natural alternative to
directly reasoning about a program with delimited continuations is to apply a
continuation passing style (CPS) transformation that transforms the program to
a pure program. We investigate this alternative, and show that the approach is
indeed possible by proposing a novel CPS transformation for algebraic effects
and handlers that enjoys bidirectional (refinement-)type-preservation.Comment: 66 page
Combining and Relating Control Effects and their Semantics
Combining local exceptions and first class continuations leads to programs
with complex control flow, as well as the possibility of expressing powerful
constructs such as resumable exceptions. We describe and compare games models
for a programming language which includes these features, as well as
higher-order references. They are obtained by contrasting methodologies: by
annotating sequences of moves with "control pointers" indicating where
exceptions are thrown and caught, and by composing the exceptions and
continuations monads.
The former approach allows an explicit representation of control flow in
games for exceptions, and hence a straightforward proof of definability (full
abstraction) by factorization, as well as offering the possibility of a
semantic approach to control flow analysis of exception-handling. However,
establishing soundness of such a concrete and complex model is a non-trivial
problem. It may be resolved by establishing a correspondence with the monad
semantics, based on erasing explicit exception moves and replacing them with
control pointers.Comment: In Proceedings COS 2013, arXiv:1309.092
Logical relations for coherence of effect subtyping
A coercion semantics of a programming language with subtyping is typically
defined on typing derivations rather than on typing judgments. To avoid
semantic ambiguity, such a semantics is expected to be coherent, i.e.,
independent of the typing derivation for a given typing judgment. In this
article we present heterogeneous, biorthogonal, step-indexed logical relations
for establishing the coherence of coercion semantics of programming languages
with subtyping. To illustrate the effectiveness of the proof method, we develop
a proof of coherence of a type-directed, selective CPS translation from a typed
call-by-value lambda calculus with delimited continuations and control-effect
subtyping. The article is accompanied by a Coq formalization that relies on a
novel shallow embedding of a logic for reasoning about step-indexing
Lazy Evaluation and Delimited Control
The call-by-need lambda calculus provides an equational framework for
reasoning syntactically about lazy evaluation. This paper examines its
operational characteristics. By a series of reasoning steps, we systematically
unpack the standard-order reduction relation of the calculus and discover a
novel abstract machine definition which, like the calculus, goes "under
lambdas." We prove that machine evaluation is equivalent to standard-order
evaluation. Unlike traditional abstract machines, delimited control plays a
significant role in the machine's behavior. In particular, the machine replaces
the manipulation of a heap using store-based effects with disciplined
management of the evaluation stack using control-based effects. In short, state
is replaced with control. To further articulate this observation, we present a
simulation of call-by-need in a call-by-value language using delimited control
operations
- …