Paulo Emílio de Vilhena

Profile Picture

About me

Hi, welcome to my page! I'm a postdoctoral researcher at Imperial College London, working as a member of Azalea Raad's research group, Veritas.

I did my PhD at Inria Paris, in the Cambium research team, under the supervision of François Pottier. The main contribution of my thesis is the extension of Separation Logic with support for effect handlers, an advanced control-flow mechanism that was recently added to OCaml (coincidentally, in the same day as my thesis defense!).

Publications

A Relational Separation Logic for Effect Handlers
(Conditionally accepted) Principles of Programming Languages (POPL), January 2026
Paulo Emílio de Vilhena, Simcha Van Collem, Ines Wright, and Robbert Krebbers
[ draft ] [ abstract ]
Effect handlers offer a powerful and relatively simple mechanism for controlling a program's flow of execution. Since their introduction, an impressive array of verification tools for effect handlers has been developed. However, to this day, no framework can express and prove relational properties about programs that use effect handlers in languages such as OCaml and Links, where programming features like mutable state and concurrency are readily available. To this end, we introduce blaze, the first relational separation logic for effect handlers. We build blaze on top of the Rocq implementation of the Iris separation logic, thereby enjoying the rigour of a mechanised theory and all the reasoning properties of a modern fully-fledged concurrent separation logic, such as modular reasoning about stateful concurrent programs and the ability to introduce user-defined ghost state. In addition to familiar reasoning rules, such as the bind rule and the frame rule, blaze offers rules to reason modularly about programs that perform and handle effects. Significantly, when verifying that two programs are related, blaze does not require that effects and handlers from one program be in correspondence with effects and handlers from the other. To assess this flexibility, we conduct a number of case studies: most noticeably, we show how different implementations of an asynchronous-programming library using effects are related to truly concurrent implementations. As side contributions, we introduce two new, simple, and general reasoning rules for concurrent relational separation logic that are independent of effects: a logical-fork rule that allows one to reason about an arbitrary program phrase as if it had been spawned as a thread and a thread-swap rule that allows one to reason about how threads are scheduled.
Extending the C/C++ Memory Model with Inline Assembly
Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), October 2024
Paulo Emílio de Vilhena, Ori Lahav, Viktor Vafeiadis, and Azalea Raad
[ pdf | doi | slides ] [ abstract ]
Programs written in C/C++ often include inline assembly: a snippet of architecture-specific assembly code used to access low-level functionalities that are impossible or expensive to simulate in the source language. Although inline assembly is widely used, its semantics has not yet been formally studied.
In this paper, we overcome this deficiency by investigating the effect of inline assembly on the consistency semantics of C/C++ programs. We propose the first memory model of the C++ Programming Language with support for inline assembly for Intel's x86 including non-temporal stores and store fences. We argue that previous provably correct compiler optimizations and correct compiler mappings should remain correct under such an extended model and we prove that this requirement is met by our proposed model.
Verifying an Effect-Handler-Based Define-By-Run Reverse-Mode AD Library
Logical Methods in Computer Science (LMCS), October 2023
Paulo Emílio de Vilhena and François Pottier
[ pdf | doi | arxiv ] [ abstract ]
We apply program verification technology to the problem of specifying and verifying automatic differentiation (AD) algorithms. We focus on define-by-run, a style of AD where the program that must be differentiated is executed and monitored by the automatic differentiation algorithm. We begin by asking, "what is an implementation of AD?" and "what does it mean for an implementation of AD to be correct?" We answer these questions both at an informal level, in precise English prose, and at a formal level, using types and logical assertions. After answering these broad questions, we focus on a specific implementation of AD, which involves a number of subtle programming-language features, including dynamically allocated mutable state, first-class functions, and effect handlers. We present a machine-checked proof, expressed in a modern variant of Separation Logic, of its correctness. We view this result as an advanced exercise in program verification, with potential future applications to the verification of more realistic automatic differentiation systems and of other software components that exploit delimited-control effects.
A Type System for Effect Handlers and Dynamic Labels
European Symposium on Programming (ESOP), April 2023
Paulo Emílio de Vilhena and François Pottier
Nominated for one of the best-paper awards
[ pdf | doi | slides ] [ abstract ]
We consider a simple yet expressive λ-calculus equipped with references, effect handlers, and dynamic allocation of effect labels, and whose operational semantics does not involve coercions or rely on type information. We equip this language with a type system that supports type and effect polymorphism, allows reordering row entries and extending a row with new entries, and supports (but is not restricted to) lexically scoped handlers. This requires addressing the issue of potential aliasing between effect names. Our original solution is to interpret a row not only as a permission to perform certain effects but also as a disjointness requirement bearing on effect names. The type system guarantees strong type soundness: a well-typed program cannot crash or perform an unhandled effect. We prove this fact by encoding the type system into a novel Separation Logic for effect handlers, which we build on top of Iris. Our results are formalized in Coq.
Proof of Programs with Effect Handlers
PhD Thesis, Université Paris Cité, December 2022
Paulo Emílio de Vilhena
Recipient of the thesis award from the GDR GPL
[ pdf | slides ] [ short abstract ]
This thesis addresses the problem of reasoning about programs that modify the heap and alter the control flow through effect handlers, a novel programming construct that provides a relatively simple interface to delimited control. This ability to manipulate the control flow is extremely powerful: many programming features — such as asynchronous programming and coroutines — that come as built-in packages of traditional programming languages can be expressed in terms of effect handlers.
The status of effect handlers as a modular and expressive programming construct is attested by the development of the OCaml programming language, which will have support for handlers in its next major release.
This event makes the problem of unveiling the logical principles that govern effect handlers even more pressing. In particular, how to reason abstractly about a continuation, rather than thinking concretely as a fragment of the stack? Moreover, can we reason separately about a program that performs effects and a program that handles these effects? This thesis answers these questions by introducing Hazel, a separation logic for effect handlers, built as an extension of Iris. Hazel introduces a novel specification language by means of which one can describe the behavior of programs, including continuations. The logic allows one to compose specifications in a modular fashion through familiar reasoning rules, such as the bind rule and the frame rule, and novel ones, such as the reasoning rules for handling and performing effects.
A Separation Logic for Effect Handlers
Principles of Programming Languages (POPL), January 2021
Paulo Emílio de Vilhena and François Pottier
[ pdf | doi | talk | slides ] [ abstract ]
User-defined effects and effect handlers are advertised and advocated as a relatively easy-to-understand and modular approach to delimited control. They offer the ability of suspending and resuming a computation and allow information to be transmitted both ways between the computation, which requests a certain service, and the handler, which provides this service. Yet, a key question remains, to this day, largely unanswered: how does one modularly specify and verify programs in the presence of both user-defined effect handlers and primitive effects, such as heap-allocated mutable state? We answer this question by presenting a Separation Logic with built-in support for effect handlers, both shallow and deep. The specification of a program fragment includes a protocol that describes the effects that the program may perform as well as the replies that it can expect to receive. The logic allows local reasoning via a frame rule and a bind rule. It is based on Iris and inherits all of its advanced features, including support for higher-order functions, user-defined ghost state, and invariants. We illustrate its power via several case studies, including (1) a generic formulation of control inversion, which turns a producer that "pushes" elements towards a consumer into a producer from which one can "pull" elements on demand, and (2) a simple system for cooperative concurrency, where several threads execute concurrently, can spawn new threads, and communicate via promises.
Algebraically Closed Fields in Isabelle/HOL
International Joint Conference on Automated Reasoning (IJCAR), June 2020
Paulo Emílio de Vilhena and Lawrence C. Paulson
[ pdf | doi | talk | slides ] [ abstract ]
That any field admits an algebraically closed extension is a fundamental theorem in modern mathematics. Despite its central importance, we believe that the result has never been formalised in a proof assistant. Here, we fill this gap by documenting the accomplishment of its formalisation in Isabelle/HOL. As auxiliary contributions, we elaborate on the difficulties that impeded this development and the solutions that we found.
Spy Game: Verifying a Local Generic Solver in Iris
Principles of Programming Languages (POPL), January 2020
Paulo Emílio de Vilhena, François Pottier, and Jacques-Henri Jourdan
[ pdf | doi | talk | slides ] [ abstract ]
We verify the partial correctness of a local generic solver, that is, an on-demand, incremental, memoizing least fixed point computation algorithm. The verification is carried out in Iris, a modern breed of concurrent separation logic. The specification is simple: the solver computes the optimal least fixed point of a system of monotone equations. Although the solver relies on mutable internal state for memoization and for spying, a form of dynamic dependency discovery, it is apparently pure: no side effects are mentioned in its specification. As auxiliary contributions, we provide several illustrations of the use of prophecy variables, a novel feature of Iris; we establish a restricted form of the infinitary conjunction rule; and we provide a specification and proof of Longley's modulus function, an archetypical example of spying.