arXiv:2610.37244cs.PLOct 2026

Manuscript Offprint

arXiv:2610.37244

Preserving Separation Logic Specifications through Compilation

Carmine Abate, Kleio Liotati, František Farka, Sebastian Ertel

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Carmine Abate 1^{1}, Kleio Liotati 1,2^{1,2}, František Farka 1^{1}, and Sebastian Ertel 1^{1}

1^{1} Barkhausen Institut, Dresden, Germany

firstname.lastname@barkhauseninstitut.org

2^{2} TU Dresden, Germany

Abstract. Program specifications in separation logic describe ownership of resources and serve as logical interfaces for local reasoning. Compiler correctness, expressed as semantics preservation, does not by itself supply such an interface for compiled code, because it does not explicitly relate source and target resources and assertions.

We investigate WP-preserving compilation: when a compiler translates a source program, the weakest preconditions that the program satisfies in a separation logic carry over to the compiled program. Our proof technique consists of a resource-aware simulation over interaction trees: it relates the resources required by corresponding source and target events, and tracks ownership through target operations, such as register accesses, that have no source counterpart. We apply the approach to a compiler from a structured imperative language to an assembly-like language, first for closed programs and then extended with modules and function calls. In the extended setting, each module can be verified in the source logic and compiled separately; its specifications carry over to the compiled module and are preserved when compiled modules are linked. All results are mechanized in Rocq.

Keywords: WP-preservation · Compiler verification · Separation logic · Interaction trees

1 Introduction

Program logics establish specifications through which clients reason about programs and components [8]. In a separation logic, specifications describe the pre- and postconditions of a program in terms of resources, e.g. what part of the memory is accessible to or owned by the program and what resource is returned after execution [34,28]. Such specifications serve as logical interfaces: clients can use them to reason about a component without inspecting its implementation and retain ownership of separately held resources [29,30].

Semantics preservation alone does not supply a corresponding logical interface for compiled code. Correctness theorems such as those of CompCert [22] and CakeML [42] relate source and target behaviors, guaranteeing that every behav-

C. Abate et al.

ior of the compiled program is a possible behavior of the source program: 3^{3}

BehT([[P]])⊆BehS(P).\mathbf{B e h}_{\mathbf{T}}(\left[\left[P\right]\right])\subseteq\mathbf{B e h}_{\mathsf{S}}(P).

Compositional correctness and contextual refinement extend behavioral guarantees to components interacting with compatible contexts [41,21], while secure compilation considers arbitrary target contexts [33,1,5].

These guarantees constrain the behaviors of compiled programs, but do not by themselves specify how source assertions and ownership requirements are represented in the target. A source variable may be represented by a target memory cell, while compiled code may additionally require registers to compute intermediate results. Deriving a corresponding target specification requires relating resources and their ownership, and establishing that the resulting logical interface supports reasoning about the compiled component. The following example illustrates this gap.

Example 1. Consider a library component whose source-level implementation is

M:x:=x+1M:\quad x:=x+1

and whose small-footprint specification is the Hoare triple

{x↦n}M{x↦n+1}.\{x\mapsto n\}M\{x\mapsto n+1\}.

A client, reasoning about M in separation logic, may rely on the frame rule to obtain a richer specification,

{x↦n}M{x↦n+1}{x↦n∗y↦0}M{x↦n+1∗y↦0}\frac{\left\{x\mapsto n\right\}M\left\{x\mapsto n+1\right\}}{\left\{x\mapsto n*y\mapsto0\right\}M\left\{x\mapsto n+1*y\mapsto0\right\}}

that is, no variable other than x is modified by M.

Suppose now the compiler transforms M into the low-level implementation

[M]:loadr0,ax;movr1,1;addr0,r0,r1;storeax,r0,\left[M\right]:\quad load r_{0},a_{x};\quad mov r_{1},1;\quad add r_{0},r_{0},r_{1};\quad store a_{x},r_{0},

where axa_x is the memory cell holding xx. Semantic compiler correctness relates the behavior of [M][M] to that of MM, but it gives no logical interface for [M][M]. To obtain one without verifying the compiled code from scratch, we must relate source locations and their ownership to target memory, account for the registers used by [M][M], and show that the source proof—including the fact that a framed yy is left untouched—yields a target weakest precondition for [M][M].

This paper investigates WP-preserving compilation (or simply WP-preservation) in a semantic, separation-logic setting: when a compiler translates a source program, the weakest preconditions that the program satisfies carry over to the compiled program. 4^{4}

3^{3} Throughout the paper, we use blue sans-serif text, optionally with a subscript S, for source-language entities, and red bold text, optionally with a subscript T, for target-language entities; see [32] for a discussion of this convention. We write [P][P] for the target program obtained by compiling the source program P.

4^{4} Hoare triples are defined from weakest preconditions [19] (cf. Dijkstra [16]), so preserving weakest preconditions means preserving Hoare triples.

Contributions. More precisely, this paper makes the following contributions:

  1. We develop a proof technique for establishing WP-preservation based on a resource-aware simulation over interaction trees (ITrees).

(a) We identify an interface of three conditions under which a simulation transports weakest preconditions from source to target (the WP-transfer lemma, Section 5.1), independently of the event signatures, return types, and logical handlers of the source and target ITree semantics.

(b) We build such a simulation between IMP, a structured imperative language, and ASM, an assembly-like language with registers and memory (Section 5.2). The simulation is defined over the events of the two languages rather than over a particular compiler, and it is closed under bind and iteration. It relates the resources required by corresponding events, carries their ownership forward to subsequent simulation steps, and accounts for target operations, such as register accesses, that have no corresponding source event.

  1. We demonstrate our approach on the IMP-to-ASM compiler of Xia et al. [47]. We instantiate the Program Logics à la Carte framework [46] to obtain an Iris instance for IMP, and prove a WP-preservation theorem for closed programs (Section 5.3).

  2. We extend the languages and the compiler with modules and function calls, and establish WP-preservation under separate compilation (Section 6): each module can be verified in the source logic and compiled separately; its specifications carry over to the compiled module and are preserved when compiled modules are linked. We illustrate this with two modules whose mutually recursive functions decrement a shared counter, passing ownership of the counter across module boundaries.

  3. All results are formalized in Rocq, using the Iris framework [19].

Structure of the paper. Section 2 reviews interaction trees and their use in deriving program logics. Readers familiar with this background may proceed directly to Section 3, which illustrates WP-preservation and our simulation technique through the running example. Section 4 presents the IMP and ASM languages and the compiler. Section 5 presents both layers of our proof technique, the WP-transfer lemma and the resource-aware simulation, and the proof of WP-preservation for the IMP-to-ASM compiler. Section 6 extends languages and compiler with modules and function calls and establishes WP-preservation under separate compilation. Section 7 discusses related work, and Section 8 concludes with current limitations and directions for future work.

References (47)