Manuscript Offprint
arXiv:2610.37244Preserving Separation Logic Specifications through Compilation
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Carmine Abate , Kleio Liotati , František Farka , and Sebastian Ertel
Barkhausen Institut, Dresden, Germany
firstname.lastname@barkhauseninstitut.org
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:
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
and whose small-footprint specification is the Hoare triple
A client, reasoning about M in separation logic, may rely on the frame rule to obtain a richer specification,
that is, no variable other than x is modified by M.
Suppose now the compiler transforms M into the low-level implementation
where is the memory cell holding . Semantic compiler correctness relates the behavior of to that of , but it gives no logical interface for . 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 , and show that the source proof—including the fact that a framed is left untouched—yields a target weakest precondition for .
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.
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 for the target program obtained by compiling the source program P.
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:
- 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.
-
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).
-
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.
-
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.
– Ret(r) terminates and returns r : R;
C. Abate et al.
– Tau(t) takes an internal, unobservable step and continues as t; and
– Vis emits an event and, after receiving an answer from the environment, continues as .
Because the datatype is coinductive, its branches may be infinite. It can therefore represent both reactive programs that produce unbounded sequences of events and programs that diverge silently through an infinite sequence of Tau steps.
Equational theories. The main equivalence notion on ITrees is weak bisimulation or equivalence up to tau, written . It relates trees that return related values and perform related visible events after ignoring finite numbers of silent steps, while still distinguishing silent divergence from termination. More generally, the relation can be parameterized by both a relation on return values and a relation on visible events, allowing ITrees with different result and event types to be compared. Other variants tailor the observable events to a particular application; for example, equivalence up to cutoff allows designated error events on one side to match any subsequent behavior on the other [44].
Algebraic structure. For every event signature E, itree E R forms a monad whose unit is Ret and whose bind bind t k replaces each return leaf Ret(r) of t with the continuation kr, while preserving silent steps and visible events. Monadic laws hold up to weak bisimulation.
Computational and logical interpretations. Events are initially uninterpreted: an event signature describes the interface between a computation and its environment, and a handler assigns meaning to it. An algebraic handler maps each event to a computation; an interpreter folds it over a tree, mapping Ret to monadic return and commuting with bind, so that interpreters preserve the monadic structure and the equational theory. A logical handler instead assigns each event a specification, the pre- and postconditions of triggering it [46]; a weakest-precondition interpretation lifts it to an entire ITree, mapping Ret to the postcondition and composing through bind, so that an ITree semantics gives rise compositionally to a program logic for the represented language. Both algebraic and logical handlers for individual effects can be combined over disjoint sums of event signatures, and both interpretations come with laws for the iteration and recursion combinators of ITrees [47,46].
Program logics from ITree semantics. Vistrup et al. [46] show how to derive program logics for languages with ITree semantics. The foundation is a general weakest-precondition calculus for ITrees,
Thus, a return establishes the postcondition, a silent step continues with the weakest precondition of its continuation, and a visible event delegates reasoning
Usually simply called handler; we say algebraic to distinguish it from the logical handler of Vistrup et al. [46].
to the logical handler. The outer update modality permits updates to Iris ghost state during each step [46].
Language-specific program logics can be obtained modularly by providing a denotation of programs into itree E R and a logical handler for each event in E. If the language is extended with a new construct whose ITree semantics introduces a new effect , its denotation ranges over itree R. The program logic can then be extended simply by providing a logical handler for ; the existing handlers and proof rules remain unchanged.
3 WP-preservation Overview
We use Example 1 to showcase the central ideas of our work. We consider a simple imperative language (IMP) with assignments, sequencing, conditionals, and loops, compiled to an assembly-like language (ASM); their syntax, semantics and the compiler are given in Section 4. Recall the increment function from Example 1 and its specification:
The precondition supplies ownership of as well as its current value. The post-condition returns that ownership with the updated value. A client can therefore reason about the command without inspecting its implementation and can retain separately owned resources, such as for , while executing it.
Establishing the specification in the source. The proof that satisfies this specification is a single application of the assignment rule. Accessing requires ownership of , so the assignment consumes , evaluates , and returns .
Fig. 1. Compiled code for M with its precondition and ownership assertions after each instruction.
Establishing the specification in the target. Figure 1 shows , the compiled code for , together with its precondition and the assertions that hold after each instruction. The precondition owns the registers and used by and the memory cell of the source variable , which contains .
After load, register also contains . The mov instruction sets the temporary register to 1. The add instruction adds the values in and and stores the result in . The final store instruction writes to the memory cell at . A direct proof at the target level thus establishes:
C. Abate et al.
This argument suggests that the source specification for survives compilation: if is incremented by 1, then is also incremented by 1. Still, the target specification also requires ownership of the registers used by .
Our goal is to obtain a target guarantee for from the source proof, without re-proving it at the target level. We achieve this by establishing a simulation relation—over the ITrees of and —that accounts for the resources accessed by both the source and compiled programs.
| Source t itree of M | Target t itree of [M] |
|---|---|
| {xmap n} | {r0map u0 * r1map u1 * axmap n} |
| vs←GetVar(x) | vt←Load(ax) |
| {xmap n} | {r0map u0 * r1map u1 * axmap n} |
| — | SetReg(r0, vt) |
| {r0map n * r1map u1 * axmap n} | |
| — | SetReg(r1, 1) |
| {r0map n * r1map 1 * axmap n} | |
| — | p←GetReg(r0) |
| {r0map n * r1map 1 * axmap n} | |
| — | q←GetReg(r1) |
| {r0map n * r1map 1 * axmap n} | |
| — | SetReg(r0, p + q) |
| {r0map n + 1 * r1map 1 * axmap n} | |
| — | w←GetReg(r0) |
| {r0map n + 1 * r1map 1 * axmap n} | |
| SetVar(x, vs + 1) | Store(ax, w) |
| {xmap n + 1} | {r0map n + 1 * r1map 1 * axmap n + 1} |
Fig. 2. Resource-aware simulation between the interaction trees of and . We display the postconditions after each stateful computation and omit silent steps, synchronized stepE, and failure branches. Initially, the source variable and the target memory cell at both contain , while the owned registers contain arbitrary values and . For the simulation to hold, GetVar() must match Load(), and SetVar() must match Store(). Each match must also provide the ownership of the resources required by the next proof obligation. The target's GetReg and SetReg events have no corresponding source events; the source stutters, as indicated by the dashes, while register ownership is preserved. The simulation owns only the cell , the source authority of , and the registers of .
Resource-aware simulation. Figure 2 shows a resource-aware simulation between t and t, the ITrees of M and , respectively. For the simulation to hold, the read GetVar(x) must match the read Load( ), and the match must relate the ownership of the source and target resources.
After the initial synchronized reads, the simulation cannot proceed in lock-step. The target writes the loaded value to , with no corresponding source event.
Further register reads and writes compute the increment and prepare the value for the final store. The simulation lets the source stutter, as indicated by the dashes, while the target performs the necessary register accesses. The simulation tracks register contents and carries ownership of resources forward to subsequent proof obligations. A GetReg preserves both the register's contents and its ownership. A SetReg updates the contents while retaining ownership.
Transporting the specification. A source assertion such as speaks about the source store, which never touches. The simulation therefore maintains a state correspondence for the variables of and the registers of : for it owns the target cell and the source authority of , a ghost resource that agrees with the client's , with the same entry in both, and it owns and . speaks about , , and only, not about the rest of the store or the memory. Our preservation theorem returns the source postcondition together with . From and the authority of in , the cell holds , so we extract . Since the target precondition owns no other cell, the frame rule of the target logic adds any other cell, such as . Combining the source proof of with our theorem, we obtain
where owns the registers of (Section 5.3).
A relation between source and target states induces a mapping from source to target properties [4]. plays this role, mapping the source postcondition to , which in turn entails the target postcondition because owns the cell and an authority that agrees with the source points-to assertion.
The simulation relation also requires ownership of and . The value eventually written to is computed through these registers. The load places in , mov places 1 in , and add computes their sum before store writes it to memory. Proving the target postcondition therefore requires permission to read and update these registers, together with assertions tracking their contents. Their initial values may be arbitrary, since both registers are overwritten before being read, but their ownership must be available from the start. The simulation carries this additional ownership through the intermediate steps and returns it together with ownership of the updated cell at .
4 IMP-to-ASM: Languages, Logic, and Compilation
We use the IMP-to-ASM compiler of Xia et al. [47] to instantiate our approach. This section presents the two languages, their ITree semantics, the source program logic, and the compilation scheme. These ingredients provide the setting for WP-preservation in Section 5.
This works for points-to assertions; an arbitrary source assertion need not have a target counterpart.
C. Abate et al.
IMP
ASM
| if b then c else c
| while b do c
Fig. 3. IMP and ASM syntax. In IMP, and are variables identifiers, is an arithmetic expressions and a Boolean expression. In ASM, registers , addresses , and labels range over a finite set . An operand is an immediate value or a register , and op ranges over addition, subtraction, multiplication, equality, order, and conjunction. A block ends in a branch.
4.1 Source Language: IMP
IMP programs are simple sequential commands (Figure 3). Its state is a finite partial map from variable identifiers to optional natural numbers, , called the store. Absent entries denote undeclared variables, and None entries denote unset variables. The denotation of a command , : itree E unit, is an ITree returning unit, with event signature , where storeE consists of the events GetVar(x), which reads the entry of the variable x, and SetVar(x, w), which writes w to it. Reading an uninitialized variable, or accessing an undeclared one, triggers an undefined behavior, ubE. Assignments evaluate their expressions and write to the store; sequencing uses bind, conditionals select a continuation, and loops use ITree iteration. stepE is an administrative event with no operational effect; it records that a computational step has occurred.
4.2 IMP Program Logic
We use events and logical handlers provided by the mechanized development accompanying Program Logics à la Carte [46] to derive a weakest precondition calculus for IMP from its ITree semantics (full details in Appendix B).
For a command c and postcondition , its semantic weakest precondition is
To ease the presentation, hereafter we suppress masks.
is the logical handler for storeE. It specifies each event by points-to assertions on the accessed variable only. We write for ownership of a fraction of , whose entry is ; we omit for full ownership, and abbreviates . Then
A read may use any fraction and returns it unchanged; a write requires full ownership. Since reading an unset variable is undefined behavior, reading a variable in a proof requires an initialized value, . The handler mentions no resource over the whole store. The points-to assertion is a fragment of a ghost authority
In Section 4.2 we use stepE to reason under the later modality.
kept for each variable separately (Appendix B), so the fragment and the authority of a variable can be held by different parties; the simulation of Section 5 relies on this. The authorities of all variables of the store appear only in the adequacy proof of the handler, which relates it to the computational semantics of the store.
The undefined-behavior handler assigns the false assertion to an ubE event, independently of its continuation, . Consequently, proving the WP of a program requires showing that undefined behavior is unreachable.
The step handler, , places a modality around the continuation, where the parameter selects either the later modality, , or no modality, . With , each stepE records one unit of logical progress and permits guarded recursive reasoning about the remainder of the computation.
The proof system provides rules for each IMP command. The rule for sequencing follows semantic bind, conditionals select the rule for the branch determined by the guard, and the loop rule unfolds the loop once with guarded recursive obligations. The rules of consequence and framing hold as WP lemmas, so a proof may retain resources untouched by a command. Appendix B gives the expression and command rules, their structural rules, and the precise command WP used in the development.
An inductive derivability judgment packages these rules; we write when the triple is derivable. It includes consequence but not framing, and its loop rule works on the once-unrolled loop instead of the guarded one (Appendix B). Its soundness theorem states that every derivable triple entails .
4.3 Target Language: ASM
ASM is a small assembly-like language organized as control-flow graphs (Figure 3). Its state consists of registers and memory, both finite partial maps to optional natural numbers, so the semantics distinguishes an absent location from a location that exists but is uninitialized.
The nodes of an ASM control-flow graph are basic blocks B. A block is a finite sequence of instructions i followed by exactly one terminator j. Instructions perform straight-line computation, moving values between registers, applying arithmetic or Boolean operations, and loading from or storing to memory. The terminator determines what happens after the instruction sequence. An unconditional jump selects one successor, a zero-test branch selects one of two successors from the value of a register, and halt stops execution. Thus instructions transform the machine state within a block, whereas the terminator controls execution between blocks.
Formally, an graph has a visible entry labels, b visible exit labels, and some finite number I of internal labels. Its code maps each element of —an internal label or a visible entry—to a block. A non-halting block transfers control to an element of : an internal label continues execution at another block, while a visible exit returns control to the surrounding graph. Here
C. Abate et al.
denotes the finite type with k elements. This distinction between visible and internal labels allows graphs to be linked and internal control-flow edges to be hidden compositionally.
The event signature for ASM is . consists of and , and of and ; each event accesses a single register or memory cell. Reads of unset locations and halt emit Exit. The denotation of a block executes its instructions in order and then follows its terminator. The semantics of a control-flow graph iterates this process across internal labels until it reaches a visible exit, giving .
4.4 Compilation
The compilation function compile : com → asm(1, 1) is the one of Xia et al. [47], used unchanged for closed programs and extended with function calls in Section 6; the ITree semantics of both languages faithfully follow Xia et al., but access the state through one event per variable, register or memory cell, and introduce stepE and ubE. The compiler follows the source syntax. Expression compilation emits instruction lists: constants become moves and variables become loads. Binary operands are computed into r and and combined into r, using higher registers as scratch space while preserving lower registers. Boolean expressions follow the same scheme. Assignment computes into register zero and stores the result at the address of the assigned variable x, with . Graph combinators implement control flow. Skip is the identity graph and assignment a single block. Sequencing links one graph's exit to the next entry; conditionals test register zero and merge branch exits; loops link the body back to the guard. Relabelling and hiding internal labels implement these connections. Their denotation laws express sequencing as bind and looping as ITree iteration, supporting compositional compiler proofs.
5 WP-Preservation
We now show that the compiler of Section 4 preserves source-level weakest preconditions, and hence source Hoare triples. The proof is organized around a generic transfer principle for weakest preconditions over interaction trees (Section 5.1). This result is independent of IMP, ASM, and the compiler, as it is parameterized by a resource-aware simulation over ITrees with arbitrary event signatures and logical handlers. We then instantiate this simulation for IMP and ASM (Section 5.2) and use its composition properties to prove WP-preservation for the IMP-to-ASM compiler (Section 5.3). The full definitions and technical statements appear in Appendix A.
5.1 Abstract Transfer Lemma
To transport a source WP to a target WP, we must relate both the computations and the resources mentioned in their specifications. We therefore use an Iris-valued simulation
indexed by a relation over returned values . The logical handlers and the simulation use the same Iris resource universe , containing both source and target resources. The assertion relates the returned values and describes the resources available when both ITrees return a value.
Hereafter we provide an intuitive description of the requirements we impose on ; their rigorous statements are in Appendix A.1.
Returns (SIMRET). must relate a source with a target ITree t that triggers visible events before returning v with , as long as the target logical handler does not change the target postcondition. For example, if the target postcondition concerns only the target memory, the simulation can relate a source return to a register event, which does not affect a predicate over the memory, followed by a target return
Tau steps (SIMTAU). A silent source step exposes no effect. The simulation must allow us to remove it and continue relating the remaining source computation to the same target computation.
Visible events (SIMVIS). A visible source event must be matched by a target event, possibly after finitely many additional target steps, such as the register write above. The simulation must justify these steps through the target logical handler.
For the matched events, an event relation identifies which source and target effects correspond. A resource-aware answer relation describes how their answers are related and which resources are available to simulate their continuations. Compatibility of the logical handlers allows the source handler's proof obligations to establish those of the target handler. Together, these conditions let us extend the source WP proof through the matched event while accounting for the target's additional computation.
These local requirements suffice to transport an entire WP.
Lemma 1 (Abstract WP transfer). Suppose satisfies SIMRET, SIMTAU, and SIMVIS from Appendix A.1. The following entailment holds:
As before, we suppress invariant masks. Source and target weakest preconditions are assertions of the same Iris logic and share one set of invariants, whose contents may refer to both source and target resources. The mechanized lemma holds for any invariant mask used by both, and more generally lets the target open more invariants than the source, with a fancy update from the source to the target mask at return (Lemma A1).
C. Abate et al.
5.2 A Resource-Aware Simulation for the ITrees of IMP and ASM
We define an instance of the simulation for the event signatures of IMP and ASM, and . The assertion relates the computations while tracking the resources needed to match their effects.
Target weakest preconditions. We give ASM no proof rules of its own, since verification is meant to happen at the source level, where stronger abstractions are available. By specifying a logical interpretation of the target events E, we obtain from the generic construction of Section 2 [46] a weakest precondition calculus for the ITrees with event signature E, and hence, indirectly, for ASM programs. Its meaning is fixed by the logical handler, and no ASM-specific proof rules are needed, since target weakest preconditions arise only as conclusions of WP-preservation.
For an ASM graph , entry label , and return postcondition , the target wpi is defined by the logical handler
The register and memory handlers, and , follow the IMP store handler (Section 4.2): they are specified by points-to assertions on the accessed location only. GetReg(r) takes for some fraction , returns and gives the assertion back, and SetReg( ) takes and gives back . Load( ) and Store( ) do the same with . The step handler, , places the same later modality as in IMP around the continuation, recording logical progress. Finally, Exit has no answer and hence no continuation, so its handler requires a chosen assertion , independently of . The postcondition applies when the graph returns through a visible exit label. As for the source WP, we suppress the invariant mask and the step modality parameter.
State correspondence. The simulation relates each source variable x to the target cell , one variable at a time. For a set of variables V it owns
where is the ghost authority of the source variable with entry . The source points-to assertions remain with the source specification. Since the authority agrees with every points-to assertion for , that is, , the simulation knows the value of while the client owns ; and since it also owns with the same entry, the source and target values agree. speaks only about the variables in and their cells, not about the rest of the store or the memory.
The simulation also owns the temporary registers used by the compiled command, . Their contents may change during evaluation, but their ownership is returned so subsequent computations can reuse them.
We write for these simulation resources.
Progress and administrative steps. The simulation must accommodate the target’s extra register operations without allowing it to perform administrative work forever. We express this distinction using a mixed fixed point:
Definition 1 (IMP–ASM simulation). For an Iris-valued return relation R,
The functor's clauses are given in Figure 4.
The greatest fixed point permits an unbounded number of matched visible events. The least fixed point bounds each intervening stretch of silent steps and target register operations. The clauses have three roles.
Matching effects. A source read GetVar(x) matches the target read Load(a_x), and a source write SetVar(x, w) matches the target write Store(a_x, w). For the matched pair, the simulation lends Cell(x). For a read, the points-to assertion that the source handler requires agrees with Auth_x, so the target cell holds the same entry and the two answers are equal. For a write, the full points-to assertion and Auth_x are updated together, and so is the target cell. Logical steps match on both sides; source undefined behavior matches target exit. The resources obtained after a matched event, here Cell(x), are passed to the continuation simulation through G.
Allowing administrative work. The target may read or write registers while the source remains unchanged. A register read requires ownership of the register and returns it; a write requires full ownership and returns the register with its new value. In both cases, the remaining computation is related through L, so register bookkeeping cannot continue indefinitely between matched events. Silent steps on either or both sides also recurse through L.
Finishing the simulation. When both computations return, their values and remaining resources must satisfy R. For the compiler proof, we take this return relation to reestablish , allowing the next command to start with the same correspondence and reuse the registers.
Lemma 2 (Transfer and algebraic properties). The relation satisfies SIMRET, SIMTAU, and SIMVIS, as in the hypotheses of Lemma 1. Moreover, it is compatible with weak bisimilarity (eutt), and is closed under bind and iteration (assuming the source loop cannot silently restart forever).
The iteration assumption permits divergent loops that keep performing visible events. It excludes infinitely many restarts with no such progress. The precise well-foundedness condition and composition lemmas appear in Appendix A.3.
5.3 WP-Preservation for IMP-to-ASM
We now use the simulation from Definition 1 to transport IMP specifications to compiled programs. The central distinction is between retaining an arbitrary source postcondition and obtaining assertions about target memory.
C. Abate et al.
(a) The simulation functor.
(b) Event relations.
| (e,f) | |||
|---|---|---|---|
| (GetVar(x),Load(α)) | Cell(x) | ||
| (SetVar(x,w),Store(α,w')) | Cell(x) | Cell(x) | |
| (Stepsrc,Steptrg) | True | True | True |
| (UB,Exit) | True | True | no answers |
| All other pairs | False | True | False |
The two Step events record source and target logical progress. The UB-Exit pair has empty answer types.
Fig. 4. The IMP-ASM simulation: (a) its single-step functor and (b) the event relations for matched events.
Notation and resource updates. In Figure 4, owns the full ghost authority of the source variable , recording the entry . It agrees with every source points-to assertion for : from we obtain . Updating the entry requires both and the full points-to assertion; the matched write updates them together with the target cell. Blue/red points-to arrows denote source/target ownership. owns a fraction of with an optional value , the fraction is omitted when full, and abbreviates ; likewise for source assertions. Target memory and register ownership are distinguished by the address or register on the left. The authorities over the whole store, memory and register file appear only in the adequacy proofs of the logical handlers, never in the simulation.
Transferring specifications. A source assertion such as talks about the source store, which the compiled program never touches; on its own, it says nothing about target memory. The preservation theorem therefore returns the source postcondition together with what is needed to read it against target memory: for each variable of the command, its source authority and its target cell, with the same entry. From the target's point of view the authorities are ghost, since no target instruction reads or writes them. For a command , let be its variables and the registers used by compile(c). We write
for the state correspondence of . It owns only the cells of the variables of and the registers of its compiled code; no resource in it ranges over the whole store or the whole memory.
Theorem 1 (Closed-program WP preservation). For every IMP command c and source postcondition ,
where . Source and target use the same invariant mask and step modality, and the target exit postcondition is arbitrary.
The state correspondence is thus returned, with the final entries of the variables of , together with the source postcondition. Since the precondition owns nothing outside the cells of and the registers , the frame rule of the target logic applies to compiled code: any target assertion owned separately, such as for a variable that does not use, is preserved by compile().
Proof (sketch). The main step is the compiler simulation. Take . We establish
(Compiler simulation)
The proof proceeds by induction on , using Lemma 2, for the more general correspondence with and , so that a subcommand runs with the correspondence of the enclosing command. Skip restores the input resources directly. For assignment, expression simulation accounts for temporary register use, and the matched write updates the source authority and the target cell of the assigned variable together. For a conditional, expression simulation relates the source guard to the target branch test, after which we use the selected branch's induction hypothesis. Sequencing uses closure under bind to pass resources between commands. The while case uses closure under iteration, relating source loop states to target control-flow labels. The logical step following guard evaluation rules out an infinite chain of silent restarts.
Applying Lemma 1 to this simulation and the source WP yields a target WP that returns the source postcondition together with , that is, . Soundness of the source proof system supplies the source WP premise for derivable Hoare triples.
Obtaining target points-to assertions. In practice, a client of the compiled program wants target assertions rather than a source postcondition read through the state correspondence. An arbitrary Iris assertion need not admit such a translation, which is why Theorem 1 retains together with the state correspondence. Points-to assertions, however, do. If the source postcondition owns a variable x of c containing v, the authority of x in agrees with it, so the cell owned by holds . For example, lets us extract , where and are the memory addresses of x and y; the cells of the other variables of c are returned in . This extraction uses the supplied target ownership; the source assertion alone does not create
C. Abate et al.
target resources. Lemma A3 states it precisely, and Theorem A2 combines it with Theorem 1. Variables that c does not use need no such detour: their target cells are framed in the target logic, as above.
For a closed program, the target facts obtained this way, points-to assertions about the final memory, could also be derived from the adequacy of the source logic and a behavioral correctness theorem for the compiler. What Theorem 1 adds is the form of its conclusion, a weakest precondition of the target logic, which composes with target-level reasoning. In Section 6, it is what lets a compiled function satisfy a target contract that other compiled modules rely on (Theorem 2).
Example 2 (Fibonacci). Consider the following implementation of Fibonacci
FIB(n):
while do (temp := y; ; ; );
fib := x
and, writing Fib(k) for the k-th Fibonacci number, its specification
We proved , where owns , , , and with arbitrary, possibly uninitialized, values. Instantiating Theorem 1 with and extracting the points-to assertions of (Theorem A2) gives the target specification
where
The precondition owns only the cells of the five variables of and the registers of its compiled code. The postcondition consists of target points-to assertions, the registers, and the correspondence cell of temp, whose final value does not describe.
Since the precondition owns no other memory cell, the frame rule of the target logic applies. For a variable that does not use, whose target cell holds 42, .
6 Separate Compilation
We extend IMP, ASM and the compiler with modules and function calls, and show that WP-preservation survives separate compilation and linking. Each compiled function is related to its source by an open simulation, which yields the preservation of function and module contracts and, once the modules are linked, of the WP of the whole program (Section 6.3). The transfer lemma of Section 5.1 is reused unchanged. We illustrate the results with two modules whose mutually recursive functions pass ownership of a shared counter (Section 6.4). Appendix C in the appendix gives the full details.
6.1 Modules, Calls, and Linking
Fig. 5. Modules and calls, simplified (full definitions in Appendix C). A module N declares globals g, functions F, and exported (exp) and imported (imp) signatures f/n (name and arity). An IMP function f has formal parameters p, locals l, a body c and a result expression a, evaluated after the body; ASM functions have an arity n, locals l, the registers regs they use, and a body B : asm(1,1). Variables are local, y, or global, N.y; we omit the module qualification of called functions. A function table T, produced by linking modules M, maps the qualified name N.f of each function to its definition; a program is an entry command run with a table.
Modules. IMP and ASM programs are organized in modules of the same shape, parametric in the kind of function they contain (Figure 5). A module has a name, a list of global variables, a list of named functions, and the signatures (name and arity) of the functions it exports and imports. Variables are either local, x, or global, M.x, where M is the module that declares x; memory addresses follow the same scheme, and the address of a variable x is the address of the same kind and name.
Functions and calls. An IMP function has a list of parameters, a list of local variables, a body command, and a result expression evaluated after the body; there is no return command. We extend IMP with the command , which first evaluates the arguments, calls the function , and assigns its result to . An ASM function has an arity, a list of local variables, the set of registers it uses, and a body, an graph whose single exit returns to the caller, with the result in register . ASM gains a call instruction , which passes the operands to and writes the result to .
Function call events and linking. In both languages a call triggers the event FnCall(f, v), which carries the callee and the argument values and returns the result. For IMP, the call command then writes the result to x; for ASM, the call instruction writes it to r. Calls are thus visible events of the ITree of a function body, later interpreted by linking.
Linking a list of modules produces a function table, a finite map from qualified names N.f, for each function f of a module N, to function definitions. We write T for the table of the source modules and T for the table of their compilation. A resolver then interprets the FnCall events of a program recursively (using interp_mrec from the ITree library). Each call performs a step, looks up the callee in the table, checks the number of arguments, runs the body of the callee, and returns its result. A call whose callee is missing, or has the wrong arity, results in an undefined behavior in IMP and Exit in ASM. A program is thus an entry command c run with a function table T, that is, the resolver of T runs c and resolves each call by running the body that T assigns to the callee. The program
C. Abate et al.
is closed when every function called by c, or by a function of T, is defined in T. The closed programs of Section 5 are the special case of a command without calls and an empty table.
Calling convention. The caller is compiled to code that evaluates each argument into register , followed by
which calls , receives the result in , and stores it at the address of . The compiled callee starts with a prologue that stores its parameters from to their local addresses, and ends by computing its result expression into . The remaining parts of the convention are carried out by the target resolver, which saves the values of the callee's local addresses, resets them, writes the argument values to , runs the body, restores the saved values, and reads the result from . ASM has no activation records. A local address is a single memory cell, shared by all functions that use the name , and the resolver saves and restores these cells so that nested calls do not overwrite the locals of their callers. The source resolver performs the same steps on the store, event for event, so that the two resolvers can be related step by step.
Separate compilation. A module is compiled function by function. Hence T can be obtained either by linking the compiled modules or by compiling each function of T, and both yield the same table.
6.2 Contracts
A contract specifies a single function by a precondition over its argument values and a postcondition over its result. Both mention a logical witness , chosen by the caller, which lets the postcondition refer to what the caller handed over, e.g. to return a resource with the value it had. A contract context is a partial map from function names to contracts, and is the contract for , which callers rely on and which must be proved to satisfy.
Contexts give call events their logical meaning. For any FnCall(f, v), the call handler looks up , gives away for some witness , and receives for the result ; only calls to functions with a contract can be verified (Appendix C.2).
Contracts for separately compiled modules. For a list of linked modules, we distinguish between calls to functions defined by one of them (internal calls) and calls to functions defined elsewhere (external calls). Contracts for internal calls are collected in , contracts for external calls in . In the source, internal calls also lend the caller's local variables: the ownership LocalsAt(W) of the locals X of the link at values W known to the caller, which the callee returns with the same values. Locals are shared cells that a callee may overwrite, and the resolver saves and restores them around each call, so a caller keeps the values of its locals across calls; we call such contracts scoped. External contracts are the same in source and target, while the target contracts of internal calls additionally carry the state correspondence Corr from caller to callee and back, similar in spirit to Theorem 1 (see Appendix C.3 for more detail).
Well-formed modules. A module is well formed if each function with a contract in has a source body whose compilation is exactly its entry in T, and that body is proved against its contract in the source logic, with scoped contracts for internal calls; the remaining conditions concern arities and variable names (Appendix C.6).
6.3 WP-Preservation under Separate Compilation
We write for one call of by the resolver of a table , which saves and resets the locals of , passes , runs the body of , restores the locals, and returns the result, and for the ITree whose calls to functions of are resolved recursively by .
We write for the ITree obtained from by resolving its calls to functions of recursively, and leaving every other call as an external FnCall event (partial resolution).
We write for the ASM logical handler whose calls are answered by . We extend the notation of Section 4 in two ways. For an open program, whose calls are answered by the contracts of a source context ,
and for the program c run with the source table T,
For a command without calls, both coincide with .
We organize the results below as Compositional CompCert [41] organizes its correctness proof, with a simulation for each compiled function, from which the per-module results and a linking theorem follow. Unlike there, the results transport weakest preconditions and contracts rather than behaviors.
Functions.
Lemma 3 (Open simulation and resolution)
-
Per function. Each source function, run by the resolver of T, is related to its compiled function, run by the resolver of T: from Corr, the two runs return equal results together with Corr, and the calls they make remain related events.
-
Under resolution. If the source and target resolvers are related at every call, resolving the calls of two related ITrees recursively yields related ITrees.
Throughout this section Corr is (Section 5.2), which generalizes of Section 5: it owns a pool Pool of registers shared by all linked functions instead of the registers of a single command, and the cells of a set V of visible variables, fixed for the link, instead of the variables of a single command.
C. Abate et al.
The precise statements, with their side conditions on registers and variables, are Lemmas C4 and C5 in Appendix C.
For a source contract , the target contract adds the scoped resources and the state correspondence (Section 6.2). Its witness is a pair of the caller's locals and the witness of , and
with LocalsAt(W) := * w, and answers internal calls to f by the scoped contract of and external calls by , while answers them by and .
Theorem 2 (Function contract preservation). Let have body in and the compiled body compile() in , with registers in Pool and visible variables, and with contract , and let its body be proved against this contract in the source logic, with scoped contracts for internal calls. For all argument values of the right length and all witnesses ,
In words, the compiled code of satisfies its target contract, assuming that all the functions it calls satisfy their own target contracts. The proof applies Lemma 1, unchanged, to the simulation of Lemma 3 and to the source WP of obtained from the contract proof of the body (Appendix C.7).
Modules. Applying Theorem 2 to every function of a module gives the result at the granularity of modules.
Corollary 1 (Per-module contract preservation). Let M be a well-formed module. Then Theorem 2 holds for every function f of M with a contract in .
The corollary concerns M alone, since each call of M to a function of another module is answered by the contract of that function, from if the module is linked with M and from otherwise.
Linked programs. Finally, we state the result for linked modules. Let be the source modules, linked into T and compiled into T, and let c be an entry command such that c and every function of T have their registers in Pool and their variables visible. A source postcondition for c can be established against the table T or against the contracts :
Theorem 3 (Separate Compilation WP-preservation). Let be well formed. For every source , and for :
- Separate compilation preserves the weakest preconditions of the source program closed by linking,
- Separate compilation preserves the weakest preconditions proved against the contracts in ,
In both items the modules are compiled separately. In item 1 the source proof concerns the linked, closed program; item 2 makes verification separate as well. Each module is verified once against the contracts (Corollary 1) and the entry command against the same contracts, so no proof looks at the linked source program. Item 1 follows from Lemma 3. By its first part the resolvers are related at every call, so by its second part the two linked programs are related, and Lemma 1 applies once. Item 2 follows from Corollary 1 and Löb induction over the steps performed by the resolver at each call. Both proofs are in Appendix C.8.
Remark 1. As in Section 5, in both items the points-to assertions of on visible variables can be extracted to target points-to assertions. The shared counter of Section 6.4 shows this, as its final target postcondition contains . Moreover, an adequacy corollary discharges the source and target logical handlers against the computational interpretation of their events, for the compiled linked program run from initial states related by Corr (Corollary C1).
6.4 Case Study: a Shared Counter
We link three modules: G declares a global counter c, and and define functions f and g that call each other until c reaches zero,
module G {c; ; exp ; imp }
module ; ;
module ; ;
where is the empty list and
and is the same with . as callee. Here decrements by counting up to in a loop, and the result of each call is assigned to the unused local . The entry command is .
Both functions have the same contract, which passes ownership of the counter to the callee and returns it set to zero:
and is empty, since main run with the table of the three modules is a closed program. Each body is proved against this contract in the source logic, assuming the contract of the other function for the call it makes (CALL-SCOPED in Appendix C.2). The proofs of f and g are independent, and the two modules are well formed. By Corollary 1, the compiled code of each of them satisfies its target contract.
By item 2 of Theorem 3, once the three compiled modules are linked, the compiled entry command ends with the counter set to zero in target memory:
C. Abate et al.
where collects the registers of Pool, the correspondence cells of and , and the source pool LocalPool( ) of main, whose locals are owned with arbitrary values. The precondition owns only the cells of , and , not the rest of target memory. Both functions use the locals and , so their calls overwrite the same memory cells and ; the save and restore performed by the resolver keep each activation's values separate.
7 Related Work
Specification-preserving compilation. Schäfer et al. [37] define the semantics of a guarded-command and a goto language by total-correctness judgments and prove in Rocq that their compiler preserves these judgments; quantified over all Q, preservation coincides with contextual approximation. Omnisemantics [14] generalize this judgment to the omni-big-step judgment and state correctness as implies ; quantified over all Q, this is termination-preserving behavioral refinement, as the authors prove by instantiating Q with the strongest postcondition. Across languages Q is lifted through a state relation to , the shape of our ; the Bedrock2 compiler is verified this way [17]. In both lines Q is a pure predicate over concrete states, R relates whole source and target states, and the results hold for terminating programs only. Our Corr and are Iris assertions over different states and logical handlers. owns only the cells of the variables of c and the registers of its compiled code, so the transported specification keeps a small footprint and the target frame rule applies (Example 2); it carries ownership and ghost state, accounts for registers that have no source counterpart, composes with other target-level Iris proofs, covers divergence, and extends to contracts under separate compilation.
Proof-transforming compilation and certificate translation take source derivations as input and transport the proof of one specification. Barthe et al. show that a non-optimizing compiler preserves generated proof obligations exactly [12], and transport certificates through an imperative-to-RTL compiler with optimizations by strengthening annotations with certified analysis results [10]; Barthe and Kunz [11] generalize the approach to an abstract notion of certificate translation. Saabas and Uustalu [35] compile Hoare proofs of While programs, together with the programs, into proofs for a low-level language with jumps. Nordio et al. compile Eiffel contracts and Hoare-style proofs to .NET CIL [27] and translate separation-logic derivations for object-oriented programs into bytecode proofs [26]. Seo et al. [38] compile programs, specifications and Hoare proofs together, with a Rocq proof that the proof compiler is sound whenever the compiler satisfies a few equational conditions, even if it is incorrect elsewhere. All of these translate syntactic objects, proofs or verification conditions, into a target logic designed to mirror the source one; only Seo et al. report a mechanization. Our compiler operates on programs alone and preserves every semantic WP, however established; the transfer relates different event signatures and logical handlers, accounts for ownership, and extends to separate compilation. Like the compiler of [12], ours does not optimize, but we require a simulation rather than identical proof obligations.
Behavioral preservation and separate compilation. Semantics preservation is the criterion of CompCert [22] and CakeML [42]: every behavior of the compiled program is a behavior of the source. Compositional CompCert [41] extends it to separately compiled modules through structured simulations with module-local invariants, and CompCertO [21] through simulation conventions that relate source and target interfaces, calling conventions included. Song et al. [40] verify ITree modules against abstract ones under separation-logic conditions on the modules they call, and reach assembly through CompCert; Zhang et al. [48] organize such results in a refinement algebra along modules, abstraction levels and state components. In all of these, what is preserved is behavioral refinement, and conditions, where present, live at the source, so the compiled code receives no contract, whereas Theorem 2 derives one for each compiled function from its source contract.
End-to-end verification. The Verified Software Toolchain connects Verifiable C, a separation logic for CompCert's Clight, to CompCert through adequacy, as logical proofs imply properties of the source semantics and CompCert's correctness theorem transfers those behavioral guarantees to assembly [8]. Mansky and Du rebuild Verifiable C on Iris [24], and Archmage follows the same architecture for programs that cast between integers and pointers, with a memory model shared by the logic and the CompCertCast compiler [20]. In all three, the guarantee at the assembly level is behavioral, and there is no specification in a logic of the target that a target-level proof, or another compiled module, could use. WP-preservation yields such a specification, and in Section 6 a target contract for each compiled function.
Interaction trees and compiler verification. Xia et al. [47] prove their IMP-to-ASM compiler correct as weak bisimilarity between source and target ITree denotations interpreted into a common state monad; Silver et al. [39] extend the result to noninterference with an event-sensitive bisimulation. Vellvm scales the approach to a substantial subset of LLVM IR [13], and Torrini and Grégoire [44] to more than twenty passes of the Jasmin front end, with relational Hoare-logic proofs of equivalence up to cutoff, which relates source undefined behavior with arbitrary target behavior; probabilistic ITree semantics later extend this to the whole Jasmin compiler and to preservation of KEM-IND-CCA security [9]. DimSum [36] specifies each language independently and relates them through protocols, with a separation logic for modular refinement proofs. All these results are bisimulations or refinements of behaviors; none transports a WP to the target logic.
Proof techniques similar to ours. Simuliris [18] internalizes a simulation over small-step semantics in a non-step-indexed Iris logic, with ownership reasoning for fair termination-preserving contextual refinement of concurrent optimizations within one language. Its simulation nests a least fixed point for stuttering inside a greatest fixed point, as our . does for administrative target steps;
C. Abate et al.
FreeSim [15] generalizes such stuttering to progress recorded on each side independently. The Tail Modulo Cons proof [6] builds on Simuliris to verify a compiler pass for all inputs. It relates calls of source and target through protocols, as our call row does, and hands ownership of an uninitialized destination field to the target callee, recovering it filled with a value related to the source result; we do the same with Corr across matched events and calls, against logical handlers rather than an operational state interpretation. These works establish behavioral refinement; our simulation is defined over ITrees, at the semantic level of the WP calculus, so that each step is tied to the logical specification of an event, and it establishes WP-preservation across a lowering.
Secure compilation. Van Strydonck et al. [45] compile separation-logic-verified code using linear capabilities and boundary checks, and prove their compiler fully abstract [1,33]. A compiler is fully abstract when it preserves and reflects contextual equivalence. Full abstraction, however, is known not to guarantee that a property of an individual source program, and hence a specification, holds after compilation [5,31,23]. Robust compilation [5,4,2] instead preserves properties of traces against adversarial contexts. The framework of Abate et al. [4] in principle allows traces to carry information about resource ownership, but robust compilation has so far been achieved for traces of I/O events [3,43,7]. Mück et al. [25] use DimSum to verify a hardening compiler to a capability machine, proving that Reckon specifications are robustly safe after compilation. We do not consider adversarial contexts, but preserve separation-logic specifications, including ownership, as weakest preconditions of the compiled code.
8 Conclusions and Future Work
We investigated WP-preserving compilation as a way of transporting source-level logical interfaces to compiled code. Unlike trace-based semantics preservation [22], WP-preservation does not relate the observable behaviors of source and target programs, and unlike compilers that preserve predicates over whole final states [37,14], it transports judgments of a program logic, with ownership and a footprint limited to what the compiled code uses. It relates specifications provable in a separation logic for the source program, including ownership of resources, to specifications that hold for the compiled target program. Our main proof technique is a resource-aware simulation over interaction trees (Section 5). The generic WP-transfer lemma isolates the properties that a simulation must satisfy to transport weakest preconditions between ITrees with potentially different event signatures, return types, and logical handlers. We instantiated this simulation for the IMP and ASM languages and proved that the denotations of every IMP program and its compiled ASM program are related. This case study demonstrates that logical specifications can survive compilation from a structured source language to a control-flow-graph language, even when the two semantics expose different effects and the target performs additional administrative operations. The target precondition owns only the memory cells of the variables of the compiled command and the registers of its code, so target-level clients can frame the rest of target memory. Finally, we extended WP-preservation from closed programs to separately compiled modules (Section 6): each module is verified in the source logic against the contracts of its imports and compiled separately, and its specifications carry over to the compiled module and are preserved when compiled modules are linked, and callers keep the values of their locals across calls.
Limitations. For separate compilation, Theorem 3 covers closed programs whose target modules are all produced by our compiler, while open modules are covered only through contracts (Corollary 1), relative to a register pool, local pool and set of visible variables fixed for the whole link. In particular, the target contract of a call says that the callee may overwrite every register of the pool, so target-level clients cannot keep values in registers across calls. ASM has no activation records: the resolver saves and restores the locals of a callee, and this saving is not proved correct with respect to a stack-allocated semantics.
Future work. A first, mild generalization concerns the state correspondence, which relates each source variable to one target cell holding the same value. A value relation and a location map would do, with : the target postcondition is then the image of along the induced relation between stores and memories, in the sense of trace-relating compilation [4], and a source yields in the target. The transfer lemma is unaffected; the event relations of the simulation and the points-to extraction would change, and a location map that depends on the program point would be needed for register allocation. Similarly, points-to assertions are extracted to the target only at full ownership; extracting a fraction as would let hand out shares of its target cell, a change confined to the extraction lemmas.
More ambitious future work concerns the generic transfer lemma, whose conditions we satisfy with a simulation specific to the events of IMP and ASM. A parameterized resource-aware ITree relation, in the style of eutt, rutt [47] or xrutt [44], would provide the transfer, bind and iteration principles once, and let the results for individual passes compose into an end-to-end theorem.
WP-preservation for separate compilation currently links compiled modules only. Extending it to arbitrary, possibly adversarial target contexts, i.e. to the robust preservation of safety specifications [5], requires restricting what target modules may do, for instance by a static check at link time or by a capability mechanism in ASM [25].
Acknowledgments This work has been supported by funding from the Agentur für Innovation in der Cybersicherheit GmbH (Cyberagentur).
C. Abate et al.
References
-
Abadi, M.: Protection in programming-language translations. In: International Colloquium on Automata, Languages, and Programming. pp. 868–883. Springer (1998)
-
Abate, C.: A formal framework for correct and secure compilation. PhD thesis, Ruhr-Universität Bochum, Universitätsbibliothek (2023). https://doi.org/10.13154/294-9870
-
Abate, C., Azevedo de Amorim, A., Blanco, R., Evans, A.N., Fachini, G., Hritcu, C., Laurent, T., Pierce, B.C., Stronati, M., Tolmach, A.: When good components go bad: Formally secure compilation despite dynamic compromise. In: Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security. pp. 1351–1368 (2018)
-
Abate, C., Blanco, R., Ciobăcă, Ş., Durier, A., Garg, D., Hritcu, C., Patrignani, M., Tanter, É., Thibault, J.: An extended account of trace-relating compiler correctness and secure compilation. ACM Transactions on Programming Languages and Systems (TOPLAS) 43(4), 1–48 (2021)
-
Abate, C., Blanco, R., Garg, D., Hritcu, C., Patrignani, M., Thibault, J.: Journey beyond full abstraction: Exploring robust property preservation for secure compilation. In: 2019 IEEE 32nd Computer Security Foundations Symposium (CSF). pp. 256–271. IEEE (2019)
-
Allain, C., Bour, F., Clément, B., Pottier, F., Scherer, G.: Tail modulo cons, OCaml, and relational separation logic. Proc. ACM Program. Lang. 9(POPL) (Jan 2025). https://doi.org/10.1145/3704915
-
Andrici, C.C., Pribisova, A., Ahman, D., Hritcu, C., Rivas, E., Winterhalter, T.: Misquoted no more: Securely extracting F* programs with IO. Proceedings of the ACM on Programming Languages 10(ICFP), 494–523 (2026)
-
Appel, A.W.: Program Logics for Certified Compilers. Cambridge University Press (2014)
-
Arranz-Olmos, S., Barthe, G., Blatter, L., Grégoire, B., Laporte, V., Torrini, P.: KEM-IND-CCA-preserving compilation of Jasmin's ML-KEM (2026), https://arxiv.org/abs/2511.11292
-
Barthe, G., Grégoire, B., Kunz, C., Rezk, T.: Certificate translation for optimizing compilers. In: Yi, K. (ed.) Static Analysis. pp. 301–317. Springer Berlin Heidelberg, Berlin, Heidelberg (2006)
-
Barthe, G., Kunz, C.: An abstract model of certificate translation. ACM Trans. Program. Lang. Syst. 33(4) (Jul 2011). https://doi.org/10.1145/1985342.1985344
-
Barthe, G., Rezk, T., Saabas, A.: Proof obligations preserving compilation. In: International Workshop on Formal Aspects in Security and Trust. pp. 112–126. Springer (2005)
-
Beck, C., Chen, H., Zdancewic, S.: Vellvm: Formalizing the informal LLVM (experience report). In: NASA Formal Methods (NFM 2025). Lecture Notes in Computer Science, vol. 15682, pp. 91–99. Springer (2025). https://doi.org/10.1007/978-3-031-93706-4_6
-
Charguéraud, A., Chlipala, A., Erbsen, A., Gruetter, S.: Omnisemantics: Smooth handling of nondeterminism. ACM Transactions on Programming Languages and Systems 45(1), 5:1–5:43 (2023). https://doi.org/10.1145/3579834
-
Cho, M., Song, Y., Lee, D., Gäher, L., Dreyer, D.: Stuttering for free. Proc. ACM Program. Lang. 7(OOPSLA2) (Oct 2023). https://doi.org/10.1145/3622857
-
Dijkstra, E.W.: Guarded commands, nondeterminacy and formal derivation of programs. Communications of the ACM 18(8), 453–457 (1975)
-
Erbsen, A., Gruetter, S., Choi, J., Wood, C., Chlipala, A.: Integration verification across software and hardware for a simple embedded system. In: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation (PLDI 2021). pp. 604–619. ACM (2021). https://doi.org/10.1145/3453483.3454065
-
Gäher, L., Sammler, M., Spies, S., Jung, R., Dang, H.H., Krebbers, R., Kang, J., Dreyer, D.: Simuliris: a separation logic framework for verifying concurrent program optimizations. Proc. ACM Program. Lang. 6(POPL) (Jan 2022). https://doi.org/10.1145/3498689
-
Jung, R., Krebbers, R., Jourdan, J., Bizjak, A., Birkedal, L., Dreyer, D.: Iris from the ground up: A modular foundation for higher-order concurrent separation logic. J. Funct. Program. 28, e20 (2018). https://doi.org/10.1017/S0956796818000151
-
Kim, Y., Cho, M., Lee, J., Kim, J., Yoon, T., Song, Y., Hur, C.K.: Archmage and CompCertCast: End-to-end verification supporting integer-pointer casting. Proc. ACM Program. Lang. 9(POPL) (Jan 2025). https://doi.org/10.1145/3704881
-
Koenig, J., Shao, Z.: CompCertO: compiling certified open C components. In: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation. pp. 1095–1109. PLDI 2021, Association for Computing Machinery, New York, NY, USA (2021). https://doi.org/10.1145/3453483.3454097
-
Leroy, X.: Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In: Morrisett, J.G., Jones, S.L.P. (eds.) Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2006, Charleston, South Carolina, USA, January 11-13, 2006. pp. 42–54. ACM (2006). https://doi.org/10.1145/1111037.1111042
-
Longley, J.R., Plotkin, G.: Logical full abstraction and PCF. In: Proof, Language, and Interaction: Essays in Honour of Robin Milner. MIT Press (2000)
-
Mansky, W., Du, K.: An Iris instance for verifying CompCert C programs. Proc. ACM Program. Lang. 8(POPL), 148–174 (2024). https://doi.org/10.1145/3632848
-
Mück, N., Georges, A.L., Dreyer, D., Garg, D., Sammler, M.: Endangered by the language but saved by the compiler: Robust safety via semantic back-translation. Proc. ACM Program. Lang. 10(POPL) (Jan 2026). https://doi.org/10.1145/3776682
-
Nordio, M., Calcagno, C., Meyer, B.: Certificates and separation logic. In: International Symposium on Trustworthy Global Computing. pp. 273–293. Springer (2013)
-
Nordio, M., Müller, P., Meyer, B.: Proof-transforming compilation of Eiffel programs. In: International Conference on Objects, Components, Models and Patterns. pp. 316–335. Springer (2008)
-
O'Hearn, P.: Separation logic. Commun. ACM 62(2), 86–95 (Jan 2019). https://doi.org/10.1145/3211968
-
O'Hearn, P.W.: Resources, concurrency, and local reasoning. Theoretical Computer Science 375(1), 271–307 (2007). https://doi.org/10.1016/j.tcs.2006.12.035, festschrift for John C. Reynolds's 70th birthday
-
Parkinson, M., Bierman, G.: Separation logic and abstraction. In: Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages. pp. 247–258 (2005)
-
Parrow, J.: General conditions for full abstraction. Mathematical Structures in Computer Science 26(4), 655–657 (2016)
C. Abate et al.
-
Patrignani, M.: Why should anyone use colours? or, syntax highlighting beyond code snippets (2022), https://squera.github.io/misc/colours-1.pdf, accessed: 2026-09-01
-
Patrignani, M., Ahmed, A., Clarke, D.: Formal approaches to secure compilation: A survey of fully abstract compilation and related work. ACM Computing Surveys (CSUR) 51(6), 1–36 (2019)
-
Reynolds, J.: Separation logic: a logic for shared mutable data structures. In: Proceedings 17th Annual IEEE Symposium on Logic in Computer Science. pp. 55–74 (2002). https://doi.org/10.1109/LICS.2002.1029817
-
Saabas, A., Uustalu, T.: A compositional natural semantics and Hoare logic for low-level languages. Theoretical Computer Science 373(3), 273–302 (2007). https://doi.org/10.1016/j.tcs.2006.12.020
-
Sammler, M., Spies, S., Song, Y., D'Osualdo, E., Krebbers, R., Garg, D., Dreyer, D.: DimSum: A decentralized approach to multi-language semantics and verification. Proc. ACM Program. Lang. 7(POPL), 775–805 (2023). https://doi.org/10.1145/3571220
-
Schäfer, S., Schneider, S., Smolka, G.: Axiomatic semantics for compiler verification. In: Proceedings of the 5th ACM SIGPLAN Conference on Certified Programs and Proofs (CPP 2016). pp. 188–196. ACM (2016). https://doi.org/10.1145/2854065.2854083
-
Seo, A., Lam, C., Grossman, D., Ringer, T.: Correctly compiling proofs about programs without proving compilers correct. In: 15th International Conference on Interactive Theorem Proving (ITP 2024). LIPIcs, vol. 309, pp. 33:1–33:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024). https://doi.org/10.4230/LIPIcs.ITP.2024.33
-
Silver, L., He, P., Cecchetti, E., Hirsch, A.K., Zdancewic, S.: Semantics for noninterference with interaction trees. In: 37th European Conference on Object-Oriented Programming (ECOOP 2023). Leibniz International Proceedings in Informatics (LIPIcs), vol. 263, pp. 29:1–29:29. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik (2023). https://doi.org/10.4230/LIPIcs.ECOOP.2023.29
-
Song, Y., Cho, M., Lee, D., Hur, C., Sammler, M., Dreyer, D.: Conditional contextual refinement. Proceedings of the ACM on Programming Languages 7(POPL), 1121–1151 (2023). https://doi.org/10.1145/3571232
-
Stewart, G., Beringer, L., Cuellar, S., Appel, A.W.: Compositional CompCert. In: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. pp. 275–287 (2015)
-
Tan, Y.K., Myreen, M.O., Kumar, R., Fox, A.C.J., Owens, S., Norrish, M.: The verified CakeML compiler backend. J. Funct. Program. 29, e2 (2019). https://doi.org/10.1017/S0956796818000229
-
Thibault, J., Blanco, R., Lee, D., Argo, S., Azevedo de Amorim, A., Georges, A.L., Hritcu, C., Tolmach, A.: SECOMP: Formally secure compilation of compartmentalized C programs. In: Proceedings of the 2024 on ACM SIGSAC Conference on Computer and Communications Security. pp. 1061–1075. CCS '24, Association for Computing Machinery, New York, NY, USA (2024). https://doi.org/10.1145/3658644.3670288
-
Torrini, P., Grégoire, B.: Interaction trees and verified compilation. In: The Rocq Workshop (2025), https://coq-workshop.gitlab.io/2025/files/EA5.pdf
-
Van Strydonck, T., Piessens, F., Devriese, D.: Linear capabilities for fully abstract compilation of separation-logic-verified code. Journal of Functional Programming 31, e6 (2021). https://doi.org/10.1017/S0956796821000022
-
Vistrup, M., Sammler, M., Jung, R.: Program logics à la carte. Proceedings of the ACM on Programming Languages 9(POPL), 300–331 (2025)
-
Xia, L.y., Zakowski, Y., He, P., Hur, C.K., Malecha, G., Pierce, B.C., Zdancewic, S.: Interaction trees: representing recursive and impure programs in Coq. Proceedings of the ACM on Programming Languages 4(POPL), 1–32 (2020)
-
Zhang, Y., Koenig, J., Shao, Z., Wang, Y.: Unifying compositional verification and certified compilation with a three-dimensional refinement algebra. Proceedings of the ACM on Programming Languages 9(POPL), 1903–1933 (2025). https://doi.org/10.1145/3704900
C. Abate et al.
A Details of WP-Preservation
This appendix gives the transfer interface, simulation definition, and resource assertions used in Section 5.
A.1 The abstract transfer interface
Let relate return values, and let and be Iris-valued relations on events and their answers. All assertions use the same Iris resource universe. Write for the itree WP with handler and invariant mask ; abbreviates . For the visible-event case, fix a source answer type , an event , and a continuation . We write for the logical handler applied to the event, its continuation assertion , and its auxiliary thread-spawning continuation assertion . The latter is part of the library's general handler interface; the IMP and ASM handlers ignore it. For every target postcondition , the abstract simulation must satisfy:
(SIMRET)
(SIMTAU)
(SIMVIS)
Here is the target event's answer type, , and . The assertions and range over continuation assertions; and are event answers, and is the Iris fancy update at the empty mask. It lets the transport perform ghost updates: with handlers specified by points-to assertions only, no handler clause offers an update modality, and the matched write of IMP and ASM updates the source authority of the written variable (Section 5.2). The requirement is weaker than one without the update, so the lemma is stronger.
The premise quantified over asks the caller to prove the WP of the matched target event, given three resources: the event relation, the continuation simulation, and the displayed handler-transport wand. When establishing SIMVIS for IMP and ASM, the simulation proof constructs this wand from the resources of the matched-event clause (in particular, in Figure 4). It also accounts for the target administrative steps preceding the match.
In the abstract transfer proof, the wand is received as Htransport. Applying the target visible-event WP rule reduces the goal to a target handler assertion. The proof then applies Htransport: handler monotonicity, the source WP induction hypothesis, and the continuation simulation establish its source-handler premise, yielding the required target-handler assertion. Thus the transport wand connects the two handlers at the matched event, as described in Section 5.1.
Lemma A1 (Abstract transfer with masks). Suppose the simulation satisfies the three requirements above. For invariant masks ,
Here denotes an Iris fancy update from mask to . Taking equal masks and using update introduction gives Lemma 1.
A.2 The IMP-ASM simulation
For , the simulation is
with the functor and auxiliary assertions in Figure 4. The simulation resources are (Section 5.2). For a command , let be the compiler's structural register footprint and the variables of , write , and take . The compiler simulation of Section 5.3 is proved for with any and .
A.3 Composition and iteration
Lemma A2 (Composition properties). The IMP-ASM simulation satisfies the abstract transfer interface in Appendix A.1. It also has the following properties.
-
If and , then .
-
For an intermediate return relation Q,
- Let I relate loop states, and define
If the relation
C. Abate et al.
is well founded, then
Here inl restarts the loop and inr returns; makes the body premise reusable. The well-foundedness condition is on source restarts without a visible event.
A.4 Specification transfer and target points-to
Table 1 summarizes who holds each resource.
| resource | source WP simulation target WP | ||
|---|---|---|---|
| client | — | extracted as | |
| — | |||
| — | |||
| — | |||
| other target cells — | — | client (target frame) | |
Table 1. Who holds each resource in the source WP, in the state correspondence of the simulation, and in the target WP; a dash means the resource does not occur. The authorities over the whole store, memory and register file occur only in the adequacy proofs of the handlers.
Theorem A1 (WP preservation: full statement). For every command , source postcondition , invariant mask , and the same step modality on both sides,
for every target exit postcondition.
For a finite map of initialized variables, abbreviate
Lemma A3 (Extracting target points-to assertions).
Proof. The authority of in agrees with , so the entry shared with the target cell is . The second entailment is the first, cell by cell.
Theorem A2 (WP preservation with target points-to). For every command , initialized map with , and assertion ,
Source and target use the same invariant mask and step modality, and the target exit postcondition is arbitrary.
Proof (Proof sketch). Theorem 1 returns with . Split into and apply Lemma A3. For derivable source Hoare triples, source soundness supplies the source WP premise.
A target assertion about a cell outside is preserved by the frame rule of the target logic, since the precondition does not own that cell.
B The IMP Program Logic
This appendix presents the WP rules for IMP in detail. The rules are collected in Figure 6. We fix an invariant mask M and a step modality m, and use the following abbreviations to keep the figure compact:
All three itree WPs use mask and . Arithmetic and Boolean expressions return natural numbers and Booleans, respectively; commands return tt.
We write for the modality selected by and . The assertion , where , permits an uninitialized value; abbreviates the case . Both denote full ownership; the variable rule also holds for a fraction, , which the figure omits. All ownership arrows in the figure refer to source resources. The rules are Iris entailments. A rule with premises and conclusion stands for : its premises are resources supplied together, not separate proof obligations. A wand in a premise describes how to use resources returned by a subproof.
Reading the rules. Expression evaluation proceeds from left to right. In particular, AND evaluates both operands. The variable rule preserves ownership of the variable being read. The assignment rule lets the right-hand side use the assigned variable's ownership, provided that ownership is returned with its old value before the write. The auxiliary assertion carries the other resources produced by expression evaluation into the postcondition proof. This supports assignments such as . The sequencing rule passes the first command's resources directly to the second command. The while rule exposes one guard evaluation and retains the step modality around the chosen continuation. With , this permits guarded recursive reasoning.
Ghost state of stores, registers and memory. The store, the register file and the memory are finite maps from keys K (variables, registers, addresses) to optional values, accessed one key at a time. They share one ghost state, defined once for a key type K and a value type V and built only from Iris library components: a resource in the camera gmap(K, auth(option(dfrac_agree(option(V))))), with one authority per key and fractions on the fragments, and a ghost map of
C. Abate et al.
Arithmetic and Boolean expressions.
Here , is Boolean-valued, and .
Commands.
Structural and modality rules.
Here ranges over , , with the appropriate expression or command type. Superscripts make the normally implicit modality and mask explicit; is the Iris fancy update between those masks.
Fig. 6. Weakest precondition calculus for IMP.
the keys present:
Instantiated at variables, these are the source assertions and ; at registers and addresses, the target assertions. We prove that implies for every fraction , that fragments split and agree as usual, and that can be updated to . Because the authority is kept per key, the authorities of distinct keys compose; this is what lets of Section 5.2 own the authorities of the variables in and nothing else, whereas a single authority, as in a standard ghost map, would make range over every variable.
The handlers, the program logics and the adequacy proofs see this ghost state only through points-to assertions and the interpretation
where DomAuth is the authority of ; the simulation also uses the per-key authorities, with agreement and joint update; the camera itself appears only at allocation, which yields and a full points-to assertion for every key of . One adequacy proof serves the three handlers: the per-key events are implemented by events that read and write the whole map, and a WP over the former yields a WP over the latter, with split in two halves between the state interpretation and the proof. An absent key is a parameter of the implementation: undefined behavior for the store, which the domain witness of an owned variable rules out, and a read of None and an insertion on write for registers and memory. The target uses the per-key authorities too, although our simulation needs only target points-to, so that a later pass with ASM as its source can relate registers and memory cells as Cell relates variables.
C. Abate et al.
C Details of Separate WP-Preservation
This appendix gives the technical details of Section 6.
C.1 Modules, Linking, and Compilation
The following definitions, from the Rocq development, give the full syntax of modules and functions summarized in Figure 5. A module is parametric in the type F of its functions: F is function for IMP and asm_function for compiled ASM.
Variant var := VLocal (x : string) | VGlobal (mn : module_name) (x : string). Variant addr := Local (x : string) | Global (mn : module_name) (x : string). Record qualname := { qual_mod : ident; qual_fun : ident }. Record signature := { sig_name : qualname; sig_arity : nat }. Record function := { fun_params : list ident; fun Locals : list ident; fun_body : com; fun_result : aexp }. Record asm_function := { af_arity : nat; af Locals : list string; af_regs : gset reg; af_body : asm 1 1 }. Record module (F : Type) := { mod_name : ident; mod_globals : list ident; (* names only *) mod_functions : list (ident * F); modExports : list signature; mod_imports : list signature }.
Linking a list of modules qualifies each function name f of a module N as N.f and takes the union of the resulting function tables. Compiling a module maps the compiler over its functions: an IMP function is compiled to the ASM function whose arity is the number of parameters, whose locals are the parameters followed by the locals, whose registers are those used by the compiled code, and whose body is the compiled body.
Resolvers. A table T is resolved by a recursive interpretation of call events. One call FnCall(f, v) performs a step and looks up f in T. If f is missing, or its arity differs from the length of v, the call is undefined behavior in IMP and Exit in ASM. Otherwise the resolver runs run_T(f, v), which
-
saves the current values of the parameters and locals of f,
-
resets them to unset values,
-
passes the arguments, in IMP by assigning them to the parameters and in ASM by writing them to registers ,
-
runs the body of f, which may perform further calls,
-
computes the result, in IMP by evaluating the result expression and in ASM by the compiled body, which leaves it in ,
-
restores the saved values, and returns the result, in ASM read from .
In ASM, the saved values are kept in the ITree, not in memory, so the local cells of f are free during the call. The source resolver performs the same steps on the store, in the same order, so that the two resolvers emit corresponding events. The partial resolver of a target table T handles calls to functions of T as above, and re-emits every other call unchanged, as an external event answered by the environment.
Compiled functions. The body of a compiled function is
for parameters , body and result expression , where evaluates into . A call command is compiled to the evaluation of each into , followed by ; .
Lemma C1 (Linking commutes with compilation). For every list of IMP modules, linking their compilations yields the table obtained by compiling each function of the linked source table.
C.2 Rules for Function Calls
A contract consists of a precondition over the argument values and a postcondition over the result, both indexed by a witness of a type that depends on . Contracts that need no witness use the unit type. Calls are answered by a contract context , a partial map from function names to contracts, through the call handler , which is part of the logical handler of both IMP and ASM. We write for the WP of the left-to-right evaluation of the arguments , and reuse the notation of Appendix B otherwise.
CALL
CALL-EVENT holds for every handler H that contains , in particular for the IMP and ASM handlers: a call event gives away the callee's precondition and receives its postcondition for the result. CALL lifts it to the IMP call command: it evaluates the arguments, establishes the precondition, and assigns the result to x, which must be owned. In Rocq the postcondition is weakened through an intermediate predicate; the rule above is the instance where that predicate is post.
For internal calls between linked modules, the source logic uses scoped contracts (Section 6.2 and Appendix C.3): the scoped version of also lends the local pool at values known to the caller, LocalsAt(W) with dom , i.e. ownership of
C. Abate et al.
every local name in X with its entry in W, and returns it unchanged. Calls to scoped contracts use the following rule, for a local result variable :
CALL-SCOPED
After the call, the caller gets its locals back with the values they had before the call, except for x, which holds the result. ASM has no rule for the call instruction beyond CALL-EVENT: target WPs are obtained by WP-preservation, not proved directly.
C.3 Contracts and Call Contexts
A call to is internal if belongs to the target table and external otherwise. For contexts and , the contexts used by the source and the target logic are
where, for ,
LocalsAt(W) := * w,
LocalPool(X) := ∃W. ∇dom W = X ∇ * LocalsAt(W),
with , and is defined in Appendix C.4. The witness of and of is the pair of the caller's locals and the witness of . The pool must contain the parameters and locals of every linked function.
Internal calls lend the whole pool because the resolver writes the locals of the callee when it saves, resets and restores them, and because locals are shared cells: a callee may overwrite any local of its caller. The pool comes back with the same values because the resolver restores the callee's locals to their saved values and the rest of the pool is returned unchanged by the callee's body, by induction over nested calls. They carry Corr in the target because the compiled callee needs the correspondence to replay the simulation for its body. External calls use on both sides, and the caller keeps Corr across them.
C.4 Resources and State Correspondence
Variables are mapped to addresses by . Let Pool be the union of the registers used by the linked functions, and V a list of visible variables. With and of Figure 4,
Compared with of Section 5.3, owns the link-wide register pool instead of the registers of one command, and the cells of the visible variables instead of those of one command. Like , it owns no resource over the whole store or memory.
Lemma C2 (Allocation). Let be a register file whose domain includes Pool, a store whose domain includes V, and a memory with for every . Fresh ghost state yields the state interpretations of and , the correspondence , the ownership of the registers of outside Pool, a source points-to assertion for every variable of , and target points-to assertions for every cell of that is not the address of a visible variable.
Hence the premises of the theorems below can always be established.
C.5 The Simulation with Calls
The event relations of Appendix A.2 gain a row for calls. Two call events and are related when and ; at the call, the simulation hands to the callee, and the answers are related when they are equal and is returned. The rows for store and memory events are those of Figure 4, for the visible variables, with the register pool in place of the registers of a single command. With these relations, the three conditions of Lemma 1 hold as in Section 5, provided that the source and target call handlers answer related calls compatibly: whenever the target context answers a call with handed over and back, the source context answers it with the same contract without . The contexts and of Appendix C.3 satisfy this condition.
Lemma C3 (Commands with calls). Let c be a command whose registers are in Pool and whose variables are in V, and let the source and target call contexts and answer calls compatibly. For every precondition P and source postcondition , if
then
for every step modality and mask.
The proof is that of Theorem A1, by induction on c, with one more case for the call command: its arguments are evaluated as expressions, and the call events of source and target are related by the call row.
C.6 Well-Formedness of Modules
A source function with parameters , locals , body and result expression is proved against if, for all witnesses and argument values of
C. Abate et al.
length , there are and with , for all , and, for every whose domain is without and ,
where the WPs use the context , the step modality Later and the empty mask. The body thus gets the rest of the pool at known values and must return it unchanged, so it can call functions with other local names. One obligation covers the body and the result expression, which may read the callee's locals at the values the body left. A module is well formed if every function of with a contract satisfies:
-
its parameters and locals are distinct and belong to X, and its variables belong to V;
-
implies that has the arity of ;
-
it is proved against .
For linked modules we also require that the source and target tables contain the functions of M and compile(M), with distinct names. The third condition is the only proof obligation; it mentions the other modules only through their contracts.
C.7 Proofs of the Main Results
Lemma C4 (Per-function open simulation). Let have body in the source table and its compiled body compile() in , with registers in Pool and visible variables. For all argument values of the right length,
The simulation is open: calls made by remain events, related when they have the same callee and arguments. Lemma C4 relates and step by step. Saving, resetting and restoring the locals are related store and memory events on the cells of the locals of , which are visible, so owns them. Passing the arguments is related to the prologue of the compiled function, which stores the argument registers at the parameter addresses. The body is related by Lemma C3, and the result expression as in the assignment case of Theorem A1. The pieces are composed with the bind rule of Appendix A.3. For Theorem 2, the contract proof of yields a source WP of under , from to : the pool supplies the cells that the resolver saves and resets, the rest of the pool is passed to the body, and the restore returns the callee's locals with their saved values. Lemma 1, applied to this WP and the simulation of Lemma C4 with the empty mask on both sides, gives the target WP under . Corollary 1 applies this to every function of ; for the partial resolver, the internal calls of are re-tagged as internal events, which does not change their WP.
C.8 Linked Programs and Adequacy
Item 1 of Theorem 3 assumes that T contains exactly the compilation of each function of T, that the variables of every function of T are visible, and that the registers of c are in Pool. It holds for every step modality, with the empty mask. Its proof relies on a linking law for the simulation.
Lemma C5 (Linking law). If the source and target ITrees and are related by an open simulation, in which calls remain events, and the source and target resolvers are related pointwise, i.e. for every call they perform related computations guarded by a step, then the ITrees obtained by resolving the calls of and recursively are related by the closed simulation.
Lemma C4 provides the pointwise relation of the resolvers, the step performed by each resolver at each call provides the guard, and the open simulation of the entry command is that of Lemma C3. The linking law relates the two linked programs, and Lemma 1, applied once to the closed simulation, yields item 1 of Theorem 3. As in Lemma A3, points-to assertions of on visible variables can then be extracted to target points-to assertions.
Corollary C1 (Adequacy). Under the hypotheses of item 1 of Theorem 3, let the linked source program satisfy from , and let and be an initial register file and memory such that can be allocated for them (Lemma C2). Then, for every fuel , running the compiled linked program for steps from and under the handler that answers no event satisfies, as an Iris weakest precondition, the postcondition that holds when the fuel is exhausted, when the program exits with , or when it terminates in a state in which holds. The source and target logical handlers are thus discharged against the computational interpretation of their events; a pure statement about final states would further require the adequacy theorem of Iris, which we have not mechanized. Since every target exit corresponds to a source undefined behavior, which the source WP excludes, the corollary also holds with : the compiled linked program never exits.
Linking with contracts. Item 2 of Theorem 3 starts from a source proof of the entry command c in which calls are answered by , rather than from a WP of the linked source program. Its proof applies Corollary 1 to every module. The resulting target contracts assume the contracts of internal calls; Löb induction discharges this assumption for all linked functions at once, the step performed by the resolver at each call supplying the later. This is why item 2 fixes the step modality to Later. Lemma C3 gives the WP of the compiled entry command under , and resolving its calls by T preserves it.
C.9 The Shared Counter in Full
The decrement is
C. Abate et al.
which satisfies, for ,
With and , the body of is proved against its contract as follows: if holds 0, the postcondition holds immediately; otherwise PRED decrements the counter, and CALL-SCOPED hands to and receives . The proof for is symmetric, and the entry command main is proved in the same way, with a frame . Linking with contracts then yields, for every ,
where holds the correspondence cells of and . The precondition owns no target cell other than those of , and .