Manuscript Offprint
arXiv:2609.04372Corten - Foundational Verification of Rust Programs
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
FRANTIŠEK FARKA, Barkhausen Institute, Germany
CARMINE ABATE, Barkhausen Institute, Germany
SVEN LINKER, Kernkonzept GmbH, Germany
SEBASTIAN ERTEL, Barkhausen Institute, Germany
We present Corten, a foundational verification framework for Rust programs in the Rocq theorem prover, built on the Iris separation logic framework. Corten provides the first semantics of surface-level Rust mechanized in a proof assistant with an attached program logic, directly grounded in the Rust Reference: it deeply embeds the Typed High-level Intermediate Representation (THIR) into Rocq and formalises Rust's dynamic semantics as a weakest-precondition predicate transformer calculus. By operating at THIR rather than on internal compiler representations, Corten proof goals display the THIR AST, which pretty-prints to surface Rust, keeping verification close to the source code and facilitating maintainability as code evolves. Atop this semantics, Corten develops a program logic and a syntax-directed proof automation layer; the program logic includes defunctionalized continuation stacks that keep proof goals first-order and compact. Soundness is established incrementally, construct by construct, against an interaction-trees denotation. A synthetic test suite demonstrates a two-to-four times reduction in proof size compared to raw semantic proofs. We further showcase Corten on a buddy allocator case study, verifying memory safety of the allocation and deallocation functions, laying the groundwork for end-to-end verification in a shared Rocq semantic foundation spanning hardware-software boundaries.
CCS Concepts: • Theory of computation → Operational semantics; Separation logic; Program verification; • Software and its engineering → Formal software verification.
Additional Key Words and Phrases: Rust, Semantics, Formal Verification
ACM Reference Format:
František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel. 2026. Corten - Foundational Verification of Rust Programs. 1, 1 (September 2026), 41 pages. https://doi.org/10.1145/nnnnnnn.nnnnnnn
Acknowledgments
This work has been supported by funding from the Agentur für Innovation in der Cy-bersicherheit GmbH (Cyberagentur).
Authors' Contact Information: František Farka, frantisek.farka@barkhauseninstitut.org, Barkhausen Institute, Germany; Carmine Abate, carmine.abate@barkhauseninstitut.org, Barkhausen Institute, Germany; Sven Linker, sven.linker@kernkonzept.com, Kernkonzept GmbH, Germany; Sebastian Ertel, carmine.abate@barkhauseninstitut.org, Barkhausen Institute, Germany, sebastian.ertel@barkhauseninstitut.org.
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.
© 2026 Copyright held by the owner/author(s). Publication rights licensed to ACM.
ACM XXXX-XXXX/2026/9-ART
https://doi.org/10.1145/nnnnnnn.nnnnnnn
František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel
However, memory safety alone is not sufficient for critical systems: ensuring correct functional behavior, compliance with specifications, and correctness of interactions between components requires formal verification that accounts for both the behavior of individual components and their interactions across system boundaries. A framework that focuses in particular on end-to-end verification of such critical systems is still missing.
The design space of existing Rust verification. Throughout the last decade, various verification frameworks for Rust programs were proposed; each focusing on a different aspect in the design space. Dynamic and bounded tools such as Miri [20] and Kani [52] focus on detecting bugs, via concrete execution and bounded model checking respectively. SMT-based verifiers such as Verus [29], Prusti [5], and Creusot [11] focus on proof automation via external solvers. Foundational approaches provide machine-checked soundness proofs based on formal operational semantics, supporting higher-order reasoning. Aeneas [16] shows that for a restricted fragment of the Rust language, verification can be reduced to reasoning about a pure functional translation. RefinedRust [14] combines a foundational Iris-based approach in Rocq with a high degree of proof automation. Most of these approaches build on MIR, the mid-level intermediate representation, which exposes borrowing information but discards source-program structure, breaking the correspondence between proofs and code.
End-to-end verification for Rust-based systems. In a realistic systems stack a verified Rust component interacts with other components—software modules, operating system services for example for networked I/O, or hardware mechanisms such as CHERI capabilities [57, 59]. For verification to scale, proofs about software components need to stay close to the source code, keeping verification maintainable as the code evolves [35], and reasoning needs to be modular [9, 15, 25]: the correctness of a caller must follow from the specifications of its callees, without re-examining their implementations. However, modular reasoning among Rust components alone does not extend across system boundaries such as hardware. Composing proofs across such boundaries requires a shared semantic foundation in which the semantics of each layer can be related.
We present Corten, a foundational verification framework for Rust programs in the Rocq theorem prover [12] that addresses this gap. Corten targets THIR, the Typed High-Level Intermediate Representation, the first typed IR in the Rust compiler, which closely follows the Rust language reference [1]. Corten is built on Iris [21], a higher-order separation logic framework, and deeply embeds Rust into Rocq via Hax [6]. This provides foundational guarantees, modular reasoning and a semantic foundation for composition with other Rocq-verified components. Unlike toy calculi, which typically omit control flow altogether, Corten's semantics accounts for Rust's expression-oriented control flow at the scale of a full systems language. By grounding the formal semantics in the Rust language reference, we take a step toward opening the definition of Rust's semantics to the broader programming language research community.
Contributions. The key contributions of our work are in both design and implementation of Corten. In this work we:
- provide an extensible architecture for foundational Rust verification: a layered design in which axiomatic semantics, program logic, and proof automation are cleanly separated, language coverage can be grown incrementally, and soundness can be established gradually as the framework matures (see Fig. 1).
This architecture is designed with industrial-scale verification as a goal, and we demonstrate it on a realistic case study as a first step toward it. As concrete technical contributions, we:

Fig. 1. A Rust crate is embedded via hax and hax2rocq as THIR in Rocq, on which the user writes a specification and proof, guided by the Corten framework's automation, program logic, and axiomatic semantics, whose soundness is established via ITrees.
- propose an axiomatic weakest-precondition semantics for THIR, closely following the Rust Reference¹ and validate it against the intended semantics via a synthetic test suite;
- demonstrate that existing techniques [54] provide an incremental approach for instantiating the axiomatic semantics, and show how operational semantics and soundness proofs can be grown compositionally as language coverage expands;
- implement a program logic layer exemplified by definition sealing, evaluation reordering, join-point reasoning, and defunctionalized continuation stacks;
- build a syntax-directed proof automation layer atop the program logic and evaluate it on a synthetic test suite covering the language constructs supported by Corten;
- verify a buddy memory allocator [26] comprising approximately 300 lines of Rust as a realistic case study.
The accompanying Rocq development supports a wider range of language features than those presented in the paper, including trait method calls with static dispatch and simple generics, further demonstrating the extensibility of the architecture (remaining trait limitations are discussed in §9). The full drop-scope calculus is out of scope for the main text and is given in Appendix D, which also discusses verification of destructors for types with non-trivial Drop implementations as future work.
Structure of the paper. In Sec. 2, we showcase Corten on a simple example that illustrates both the expressiveness of Rust and the layers of Corten's framework; the example guides the reader through the technical development and forward-references the formal definitions introduced in later sections. Sec. 3 describes our memory model and the interface used to capture value ownership. In Sec. 4, we present the axiomatic weakest-precondition semantics and Sec. 5 describes our approach to proving their soundness with respect to an ITrees denotation in Sec. 5. Sections 6 and 7 present the program logic layer and the proof automation respectively. In Sec. 8, we report on the buddy allocator case study, discuss related work in Sec. 9 and conclude in Sec. 10.
2 Corten by Example
What distinguishes Rust from other systems programming languages is that Rust is primarily an expression language, thus providing programmers with a considerable degree of expressiveness. Constructs such as control-flow expressions appearing as function call arguments are idiomatic in Rust—for instance, an early return nested within the desugaring of a conditional expression. To illustrate, consider a simple, control-flow sensitive function example (Fig. 2a), annotated with its functional specification. The function takes a boolean argument and either produces the value 1 –
¹Definitions marked with ® are linked to the Rust Reference in the electronic version of the paper.
František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel
1 #[with(b)]
2 #[arg(bool b)]
3 #[post( v | if b then v = 1u8
else v = 0u8 )]
5 pub fn example (b : bool) -> u8 {
6 return (identity (
if b { 1 }
else { return 0; }) )
8
(a) Rust program with specification annotations
Lemma example_{ok} : identity_{spec} ← example_{spec}.
Proof with wp_engage.
wp_fn...
wp_call... (* call to identity *)
wp_if b...
Qed.
(b) Automated Rocq proof (verbatim)
Fig. 2. Control-flow sensitive Rust function and its Corten proof
passing it through a call to identity – or early returns 0, with the branching expressed directly as a control-flow expression in the argument position.
Corten’s automation yields a concise proof of the specification, the example_{ok} lemma (Fig. 2b). The statement of the lemma reflects Corten’s modular approach to verification: identity_{spec} the specification of the callee identity, entails the specification of the caller, example_{spec} consisting of lines 1–4 of Fig. 2a, where the entailment (⊣) is that of Iris separation logic². The tactics-based proof script mirrors the structure of the function itself (cf. Sec. 7): to start the verification of the function, the tactic wp_fn handles the function prologue, wp_call reasons about the call to identity, and wp_if b reasons about the conditional expression branching on b. This syntactic correspondence between code and proof script is not a limitation of the framework but a conscious design choice that eases readability and maintainability of proofs. In what follows, we discuss each proof step in detail, exposing the underlying Rust semantics and the layers of Corten’s framework that together enable this level of automation. This necessarily forward-references formal definitions from later sections.³
Before starting the proof, hax2rocq, our extension to HAX [6], transpiles the Rust crate into a THIR AST in Rocq (Fig. 1); all subsequent reasoning operates on this AST. Corten’s notion of function specification correctness (Def. 4.11) relates the specification to the weakest precondition (WP) of the function definition (wp_fn, Def. 4.10), located in the crate AST. The first proof step, tactic wp_fn, performs the necessary lookups in the AST and reduces the wp_fn goal to a WP of the function body. Interactively inspecting the proof state at this point, rather than relying on automation, reveals the following goal:
The goal is an Iris entailment. The antecedent, the separation logic (spatial) assumptions, comprise correctness of the specification of the callee, identity_{spec} and the postcondition of the caller, abbreviated with —which is exactly the post annotation on line 3 of Fig. 2a:
²In the actual development, we state specifications separately from the code, though we use Rocq notations to achieve the presentation shown above.
³In a modern PDF viewer, hovering over a cross-reference previews the referenced definition.
The conclusion of the Iris entailment is a sequence of three weakest preconditions, separated by the monadic bind (), in our control-flow-sensitive specification monad (Sec. 4.1). In particular, the goal is accumulated from the WP of the identifier pattern in the function argument (, Fig. 6) that introduces a new binding of local variable into the function frame, the WP of the function body, and the final guard asserting that function evaluation results in a return. We highlight the Rust AST for readability— is a Rust variable and bool encodes a boolean value in our semantics, parameterized over the Rocq variable .
Applying an inference rule of the predicate transformer calculus (Sec. 4) to the conclusion of the entailment accumulates new proof obligations atop an implicit postcondition, effectively reducing the goal step by step. The inference rules are an underapproximation of the reference semantics, ensuring that discharging all accumulated obligations is sufficient to establish the original specification.
The semantics materialises local variable bindings in memory: results in the frame bound to , denoting that the local variable is materialised at location , and the corresponding points-to fact is accumulated as an assumption, denoting that the location of stores its value bound to in the ambient metalogic of Rocq. The WPs of the return expression and the function call are then accumulated in turn. The return expression (WP-VEXPR-RETURN, Fig. 10) first accumulates the WP of its operand and then performs the monadic return operation (Sec. 4.1). The call to identity (WP-VEXPR-CALL-GLOBNAME, Fig. 10) decomposes the WP into the WP of the argument and the of the function bound to the symbolic value produced by the argument:
The of identity can be accumulated out of order; the specification (cf. Def. 4.11) reduces to and can be canceled out using the equational theory of the underlying monad. Although the specification is persistent, we drop it from the context as it is no longer needed. The proof proceeds by case analysis on the value of , yielding two subgoals. The WP of each subgoal is accumulated according to the semantics of if expressions (WP-VEXPR-IF), simplifying each to the of the corresponding branch:
The left subgoal follows from the semantics of blocks (, Def. 4.8) and integer literals (), producing a symbolic value that is then bound in the return operation. The other subgoal is more interesting: the WP of the block is accumulated, followed by the WP of the expression statement (WP-STMT-EXPR), arriving at the return expression. As described before, the WP of the operand—the literal 0 in this case—is first accumulated, and then the return operation
František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel
is sequenced. After simplification, we arrive at the following two goals:
The guard in the left subgoal simply traps the return and reverts control flow into normal state while binding its result to the operand of return , and is closed by the assumption . The right subgoal contains two return operations: the return expression is itself an expression, technically yielding a value of type never (!). However, the monadic bind skips over the remainder of the sequence after the first return , and the guard receives the value 0 of the first return. The goal is then closed using , concluding the proof.
The running example demonstrates several points. The semantics of Sec. 4 is given directly, staying close to the Rust Reference, but is not always the most convenient basis for reasoning. Large goals reduce theorem prover performance and lead to long Qed times. The block definition simplifies to the constituent statement WPs, accumulated one closure per bind step by the combinator; for longer blocks this remains manageable, as the closures stay sequential. The real source of blowup is nested control flow: the case analysis on b above duplicates the continuation and the proof of the remainder of the function across both branches, compounding with nesting depth and pushing Qed times to minutes. The out-of-order proof of for identity also requires extra steps. To address these concerns, we build a layer of program logic atop the base semantics; in Sec. 6, we concretely showcase definition sealing, evaluation reordering, join-point reasoning, and defunctionalized continuation stacks (Sec. 6), each addressing one of the issues raised above, in order.
This pattern of control flow nested in argument position, exercised by our running example, arises naturally in real-world Rust. Chaining method calls with the question-mark operator is a compelling instance: the following line from our buddy- allocator case study manipulates block indices using checked arithmetic:
1 blocks.checked_add(offset)?.checked_shl(block_order)
Though concise and verifiable by Corten, this idiomatic code is surprisingly complex upon desugaring, nesting checked_add in the argument of checked_shl and involving several definitions from core::ops.
These syntax-directed proof steps admit simple yet powerful automation, which the program logic layer preserves and we build upon (Sec. 7).
3 Memory Model
To reason formally about Rust programs, we need a memory model that captures how values are manipulated in the Rust Abstract Machine, the idealized model underlying Rust's semantics; our work is inspired by MiniRust [17]. For the vast majority of Rust programs—even systems code—functional correctness depends on which values are stored and who owns them, not on their byte-level representation. Verifying that a buddy allocator tracks free blocks, for example, requires ownership of those blocks but not their byte encoding. By contrast, unsafe code that peeks through value representations—via transmute, lock-free atomics, or memory-mapped I/O registers—does depend on the concrete representation, but forms a small, well-identified subset. We exploit this by modelling memory as an abstract interface that captures ownership using fractional permissions
Fig. 3. Values, runtime types, and locations of Rust Abstract Machine
Fig. 4. points-to relation for basic types
and organises it as a forest over basic values: structured-type values are represented as trees, with elements and fields accessible via index and field offsets and their layout kept abstract.⁴
3.1 Values and Locations
Values are either of basic types—integers, booleans, pointers, and references—or structured types—tuples, structs, and enumerations—as captured by the runtime type (Fig. 3). We represent Rust fixed-size arrays as homogeneous tuples. We write for a sequence of elements of —a notation we use for sequences throughout the paper—so is a tuple type with field types drawn from . Definition identifiers range over fully qualified names of source Rust elements; in and , identifies the type in a source crate. We further use local identifiers for names of local variables.
Variables and intermediate results of evaluation may be dereferenced through their locations to access their values, or the elements of tuples and fields of structured values. Locations are either roots base -base allocations on the stack, heap, or global objects—or reachable from a root via index () or field () offsets; they are thus paths through the memory forest.
Integer values int are indexed with signedness and bit width , with drawn from the ambient logic. Booleans bool are likewise modeled by ambient-logic booleans, and pointers ptr by a location. Tuples tuple carry a finite map from indices to values, encoded as a sequence of pairs; uniqueness of indices is validated during parsing and maintained by the dynamic semantics of Sec. 4. Similarly, struct and enum carry finite maps from fields to values, indexed additionally by type-definition and constructor name. There is an obvious forgetful mapping [[-$$]_{Type_{\mathbb{R}}}: \mathcal{V} \to Type_{\mathbb{R}} from values to runtime types.
3.2 Fractional Abstract Memory Model
Fractional permissions [7, 8] are a standard separation-logic tool; we use fractional points-to assertions to reason precisely about shared and mutable accesses to values in memory. The interface () is shown in Fig. 4. The relation captures core data types, i.e. integers (), booleans (), and pointers () as well as the memory layout of structures and enumerations; tuples need none, being laid out sequentially in memory. We also represent uninitialized values (), indexed by their runtime type. Fractions are drawn from
⁴We have proven this forest-of-values interface atop an abstract byte-level memory model (single-threaded); its description is out of scope for this paper.
, Vol. 1, No. 1, Article. Publication date: September 2026.
František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel $q \leq 1\}$, dropping $q$ when it equals 1. Importantly, this interface abstracts over the concrete memory representations, the layout abstracts the ownership of any padding bytes. Using this interface, we define a points-to relation for values: Definition 3.1 (Points-to relation, $\mapsto_{\mathbf{q}}$).\begin{aligned}\ell\mapsto_{\mathbf{q}}int s w z&\triangleq\ell\mapsto_{int s w}z&\ell\mapsto_{\mathbf{q}}struct d f s&\triangleq layout_{\mathbf{q}}[![struct d f s]!]{Type{\mathbf{R}}}\\ell\mapsto_{\mathbf{q}}bool b&\triangleq\ell\mapsto_{bool}b&\underset{(f,v)\in fs}{\star}(\ell.f\mapsto_{\mathbf{q}}v)\\ell\mapsto_{\mathbf{q}}ptr\ell^{\prime}&\triangleq\ell\mapsto_{ptr}\ell^{\prime}&\ell\mapsto_{\mathbf{q}}enum d d^{\prime}fs&\triangleq layout_{\mathbf{q}}[![enum d d^{\prime}fs]!]{Type{\mathbf{R}}}\\ell\mapsto_{\mathbf{q}}tuple vs&\triangleq\underset{(i,v)\in vs}{\star}(\ell.i\mapsto_{\mathbf{q}}v)&\underset{(f,v)\in fs}{\star}(\ell.f\mapsto_{\mathbf{q}}v)\end{aligned}
### 3.3 Borrowing and Unsafe Rust In Rust, borrows are the compiler's primary mechanism for enforcing the linear type system [55] and safe memory access. From a verification perspective, they are a sound but incomplete approximation of ownership-safe memory manipulations: they guarantee that all compiler-checked code respects the memory model, but not every valid manipulation a programmer might perform—so unsafe blocks allow operations outside the borrow checker's decidable fragment. Our memory model handles both uniformly: safe code is code whose ownership discipline the compiler discharges statically, whereas unsafe code discharges it manually. Within safe Rust, borrow-checked code can often be verified automatically, reflecting the linear type discipline. For unsafe code instead, the verification engineer interacts with the theorem prover to manually split ownership as needed by complex memory access patterns while maintaining soundness with respect to the underlying memory model (see Sec. 6 for the program logic layer that supports this). A borrow’s end is not modeled as a separate temporal event but falls out of the spatial resource discipline: because the encoding logic is affine, a WP rule that consumes an ownership fact via the separating conjunction and only returns a (possibly different) fact via the magic wand encodes a temporal transition as a spatial exchange—$w_{\text{move}}$ (Sec. 4.4) is the paradigmatic instance, exchanging $\ell \mapsto v$ for $\ell \mapsto \text{uninit} \left\lfloor \left\lfloor \text{Type}_{\mathbf{R}} \right\rfloor \right\rfloor$. This coincides with the discipline Tree Borrows [53] articulates operationally: a borrow’s lifetime ends at the next conflicting access.$^5$ The axioms under-approximate the Reference semantics: programs violating the ownership discipline yield unprovable goals, e.g. $w_{\text{move}}$ demands $\ell \mapsto v$. For the adequacy-covered fragment (Sec. 5) this is a semantic guarantee; beyond it, it is enforced proof-theoretically. The borrow checker is outside the TCB: the dynamic semantics consumes no borrow-checker facts, so no proof's soundness depends on its correctness—it is an untrusted oracle whose acceptance merely predicts that the fractional obligations of safe code are dischargeable, as in practice they often are. rustc's parsing, name resolution, and type checking remain in the TCB. This contrasts with solver-based tools (Verus, Prusti, Creusot) that assume well-borrowed input; foundational MIR-level tools such as RefinedRust [14] likewise do not trust the borrow checker, but encode the discipline explicitly in a lifetime logic. Our design instead leaves it implicit: on borrow-checked code, the checker's untrusted acceptance is precisely what makes our automation's fractional obligations dischargeable without any lifetime reasoning of our own. ## 4 Axiomatic Semantics Corten leverages the frontend of the Hax tool, which interfaces directly with rustc via a compiler driver, to obtain an AST representation of the program syntax in Rocq. By relying on the compiler $^{5}$Appendix H exposes a mutable-reborrow example through the pattern rules.\begin{aligned}Type \ni ty::=bool\mid char\mid num sgn w\mid&8m ty\mid!\ (\overline{iy})\mid fn(\overline{iy})&\to ty\mid[ty;ce]\mid[ty]\mid adv d\ Pat \ni pat::=_{-}\mid ref^{2}mut^{2}v\mid ce\mid&&mut^{2}pat\mid!|\ (\overline{iy})\mid[\overline{iy}]| adv d\ \overline{pat}\ Stmt \ni stmt::=e\mid let pat (=e)^{?}\ Expr \ni e::=lit\mid v\mid gn\mid&&mut^{2}e\mid*e\mid-e\mid!e\mid e\odot e\mid e as ty\mid e=e\mid\ [\overline{e},]&\mid[e;ce]\mid(\overline{e},)\mid e.n\mid gn\ (\overline{gn}(:e)^{?})\mid e.gn\mid\ {&stmt;\ e^{?}}&\mid loop e\mid break\mid continue\mid\ if e(e else e)^{?}&\mid match e\ (\overline{pat}=>e,\ )\mid\ gn(\overline{e},)&\mid return e^{?}\end{aligned}
Fig. 5. Syntax of Rust: Types, patterns, statements, and expressions for, e.g., parsing, name resolution, and type checking, we delegate the static semantics to the compiler; these components are part of the trusted computing base (TCB), while all dynamic semantics reasoning and proofs of correctness are carried out within our verified framework and are thus outside the TCB. The syntax (Fig. 5) in this paper is displayed in a style that resembles surface level Rust; we give a full account in Appendix A. We formalize dynamic semantics of Rust in the form of inference rules of a weakest-precondition predicate transformer calculus. The calculus is structured in two layers: a set of core transformers for value expressions (wp_vexpr), place expressions (wp_pexpr), statements (wpStmt), and constant expressions (wp_cexpr) that are parameters of a Rocq module type and instantiated on top of an ITrees model for soundness (Sec. 5), and a set of derived predicates, such as those for functions (wp_fn), patterns (wp_pat), and blocks (wp_block), expressed in terms of the core ones. The axioms of the module type, covering both core and defined predicates, closely follow the Rust Reference, give the predicate transformations, and act as a proof interface rather than an executable model; we validate them against the intended semantics via a synthetic test suite (cf. Sec. 7), checking that each supported construct behaves as expected. ### 4.1 Control Flow and Specification Monad Evaluation of an expression can have six possible outcomes: a value is produced and evaluation continues sequentially; a return expression terminates the current function frame passing its operands value; a break expression terminates the corresponding loop body; a continue expression resumes evaluation at the beginning of the loop body; a pattern match fails; and a completed match expression passes control to the remainder of the program. These outcomes are uniformly described by the following type: Definition 4.1 (Control flow, CF·).CF A:=seq_{CF}(a:A)\mid return_{CF}v\mid break_{CF}\mid continue_{CF}\mid nomatch_{CF}\mid match_{CF}
break$_{CF}$ targets the innermost enclosing loop and continue$_{CF}$ resumes its current iteration; Corten does not yet support labeled break/continue (Sec. 4.4), which would require extending these constructors with a depth or label index. Accumulating weakest precondition as shown in Sec 2 gives rise to a continuation monad $Cont_R(A) \triangleq (A \to R) \to R$. The type CF $\cdot$ : Type $\to$ Type classifies the state of the computation—seq$_{CF}$ A as non-exceptional computations, and the other constructors as the exceptional computation $E$ corresponding to the evaluation of control-flow František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel\mathsf{w p}{\mathrm{p a t}}:\mathsf{P a t}\to\mathcal{V}\to\Xi\to\mathsf{w p}{\mathrm{C F}}\Xi
\begin{aligned}\mathsf{w p}{\mathrm{p a t}}-\nu\xi&\triangleq\mathsf{r e t}{\mathsf{w p}{\mathrm{C F}}}\xi\\mathsf{w p}{\mathrm{p a t}}\left(\mathsf{m u t}i\right)\nu\xi&\triangleq\forall\ell_{\mathrm{t m p}},\ell_{\mathrm{t m p}}\mapsto\nu--\mathsf{r e t}{\mathsf{w p}{\mathrm{C F}}}\left(\xi\cup i@{\ell}{\mathrm{t m p}}\right)\\mathsf{w p}{\mathrm{p a t}}i\nu\xi&\triangleq\forall\ell_{\mathrm{t m p}}q,\ell_{\mathrm{t m p}}\mapsto_{q}\nu--\mathsf{r e t}{\mathsf{w p}{\mathrm{C F}}}\left(\xi\cup i@{\ell}{\mathrm{t m p}}\right)\\mathsf{w p}{\mathrm{p a t}}\left(\mathsf{r e f}\mathsf{m u t}i\right)\nu\xi&\triangleq\exists\ell,\ell\mapsto\nu*(\ell\mapsto\nu--\&\quad\forall\ell_{\mathrm{t m p}},\ell_{\mathrm{t m p}}\mapsto\mathsf{p t r}\ell--\mathsf{r e t}{\mathsf{w p}{\mathrm{C F}}}\left(\xi\cup i@{\ell}{\mathrm{t m p}}\right)\\mathsf{w p}{\mathrm{p a t}}\left(\mathsf{r e f}i\right)\nu\xi&\triangleq\exists\ell q,\ell\mapsto_{q}\nu*(\ell\mapsto_{q}\nu--\&\quad\forall\ell_{\mathrm{t m p}}q,\ell_{\mathrm{t m p}}\mapsto\mathsf{p t r}\ell--\mathsf{r e t}{\mathsf{w p}{\mathrm{C F}}}\left(\xi\cup i@{\ell}{\mathrm{t m p}}\right)\\mathsf{w p}{\mathrm{p a t}}\left(\mathsf{a d t}d p a t s\right)\nu\xi&\triangleq\mathrm{i f}\nu=\mathsf{a d t}d p a t s\mathrm{t h e n}\mathsf{w p}{\mathrm{p a t s}}p a t s\xi\&\quad\mathrm{e l s e}\mathrm{t h o w n o m a t c h}{\mathrm{C F}}\end{aligned}
\begin{aligned}\mathsf{w p}{\mathrm{p a t s}}\left(\mathsf{a d t}d p a t::p a t s\right)\nu::v s\xi&\triangleq\xi^{\prime}\leftarrow\mathsf{w p}{\mathrm{p a t}}p a t\nu\xi;\mathsf{w p}{\mathrm{p a t s}}p a t s v s\xi^{\prime}\\mathsf{w p}{\mathrm{p a t s}}\left(\mathsf{a d t}d\left[\right]\right)\left[\right]\xi&\triangleq\mathsf{r e t}{\mathsf{w p}{\mathrm{C F}}}\xi\end{aligned}
Fig. 6. Weakest precondition predicate for patterns, $wp_{pat}$ transferring expressions. This classification gives rise to an exception monad CF $A \cong A + E$ and the respective transformer. The bind and return of CF · are those of the exception monad, i.e. the bind concatenates sequential executions while propagating exceptions, while the other constructors trigger an exception. Applying the exception monad transformer to the continuation monad over Iris's iProp yields the control-flow sensitive specification monad $wp_{CF}$; Definition 4.2 (Control-flow sensitive specification monad, core transformers and guard).\mathsf{w p}_{\mathrm{C F}}A\triangleq(\mathrm{C F}A->i P r o p)->i P r o p
\mathrm{guard}:\forall A\left(c:\mathrm{CF}A\right).\mathrm{w p}{\mathrm{CF}}A\rightarrow(\mathrm{CF}A->\mathrm{w p}{\mathrm{CF}}A)->\mathrm{w p}_{\mathrm{CF}}A
throw:\forall A\left(c:CF A\right).wp_{CF}A
\begin{array}{r l r l r}{\mathsf{w p}{\mathrm{v e x p r}}:}&{E x p r\to\Xi\to\mathsf{w p}{\mathrm{C F}}\mathcal{V}}&&{}&&{\mathsf{w p}{\mathrm{c e x p r}}:}&{E x p r\to\mathsf{w p}{\mathrm{C F}}\mathcal{V}}\ {\mathsf{w p}{\mathrm{p e x p r}}:}&{E x p r\to\Xi\to\mathsf{w p}{\mathrm{C F}}\mathcal{L}}&&{}&&{\mathsf{w p}{\mathrm{s t m t}}:}&{S t m t\to\mathsf{w p}{\mathrm{C F}}\Xi}\end{array}
The monad $\mathrm{wp}_{\mathrm{CF}}(\cdot)$ enjoys the desirable properties of a specification monad [33, 34]. After partial application, e.g. $\mathrm{wp}_{\mathrm{stmt}}(s : \mathrm{Stmt})$, the core weakest-precondition transformers in the definition above satisfy the equational theory of the $\mathrm{wp}_{\mathrm{CF}}(\cdot)$ monad. As a consequence, all the derived weakest-precondition transformers discussed in this paper satisfy the equational theory of specification monads. Finally, throw $A \subset Q = Q(\text{inr } c)$ forces the evaluation of a $Q : \mathrm{CF} A \to i \mathrm{Prop}$ in the exceptional context $c$, and guard provides a handler to resume sequential evaluation $^6$.\begin{array}{c}\mathrm{wp}{\mathrm{stmt}}:\mathrm{Stmt}\rightarrow\Xi\rightarrow\mathrm{wp}{\mathrm{CF}}\Xi\\end{array}
\begin{array}{r l}&{\mathrm{W P-S T M T-L E T}\textcircled{6}}\ &{\quad\nu\leftarrow\mathrm{w p}{\mathrm{v e x p r}}e\xi;}\ &{\quad\mathrm{w p}{\mathrm{p a t}}p a t\nu\xi}\ &{\frac{\mathrm{w p}{\mathrm{s t m t}}\left(\mathrm{l e t p a t=e}\right)\xi}{}}\end{array}\quad\begin{array}{r l}&{\mathrm{W P-S T M T-E X P R}\textcircled{8}}\ &{\frac{\mathrm{w p}{\mathrm{v e x p r}}e\xi\quad e\in E x p r}{\mathrm{w p}_{\mathrm{s t m t}}e\xi}}\end{array}
Fig. 7. Weakest precondition predicate for statements, $wp_{stmt}$ ### 4.2 Patterns The weakest precondition semantics of patterns, $wp_{pat}$ is given in Fig. 6; we discuss destructuring patterns and identifier patterns in particular. Destructuring patterns and refutability. Patterns can be used to destructure values of struct, enum, and tuple type into their components. Semantically, this amounts to checking that the type of the value corresponds to the type of the pattern and delegating component values to sub-patterns, as shown for the adt d pats case in Fig. 6. Note that, when the pattern does not match, the control flow transitions to nomatch $_{CF}$. That makes the pattern refutable, and refuting the pattern transitions the control flow. This works also under a chain of sub-patterns as these are sequentialised after each other. Identifier patterns. bind a value to a variable. By default, identifier patterns copy or move the value (cf. Sec. 4.4), but bind by reference or mutable reference if annotated accordingly. Our semantics distinguishes the individual cases, requires that the sufficient ownership of points-to facts is available, and introduces the new points-to fact for the bound variable. ### 4.3 Statements Statements in Rust serve primarily to sequentialize expression evaluation. Let statement. Given a pattern, a let declaration introduces a set of variables. The variables are initialized based on an optional initializer expression, or uninitialized otherwise. For the sake of simplicity, we support only let statements with initializer expression. The corresponding axiom is WP-STMT-LET in Figure 7. The statements asserts that with function frame $\xi$, the weakest precondition of a let statement with pattern pat and initializer expression e is entailed by sequentially obtaining the weakest precondition of expression e, yielding a value $\nu$, and then obtaining the weakest precondition of matching the pattern pat to the yielded value. Note that $wp_{pat}$ pat $\nu$ is a weakest precondition over function frames $wp_{CF} \Xi$. That indeed captures the intuition, the let statement enriches function frames with bindings captured by the pattern. Expression statement. Expression statement evaluates an expression and drops the result. Thus, the weakest precondition of an expression statement WP-STMT-EXPR (Fig. 7) is the weakest precondition of the expression in the current frame, $wp_{vexpr} e \xi$ followed by simple return of the unchanged function frame, $ret_{wp_{CF}} \xi$. ### 4.4 Expressions The syntactic category Expr of expressions represents the core of the Rust language. An expression always evaluates to a value, and it may have side effects. Expressions are nested within each other, $^{6}$we omit A in the rest of the paper and just write throw c, guard c. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel\begin{aligned}&\mathrm{wp}{\mathrm{vexpr}}:\mathrm{Expr}\rightarrow\Xi\rightarrow\mathrm{wp}{\mathrm{CF}}\mathcal{V}\ &\ &\frac{\mathrm{WP-VEXPR-LITERAL-BOOL}\textcircled{5}}{\mathrm{ret}{\mathrm{w}{\mathrm{CF}}}(\mathrm{bool}\mathrm{lit})\quad\mathrm{lit}\in{\mathrm{!True!},\mathrm{!False!}}}\ &\quad\mathrm{wp}{\mathrm{vexpr}}\mathrm{lit}\xi\ &\ &\frac{\mathrm{WP-VEXPR-LITERAL-INT}\textcircled{5}}{\mathrm{ret}{\mathrm{w}{\mathrm{CF}}}(\mathrm{int}\mathrm{sng}\mathrm{w}\mathrm{lit})\quad\mathrm{lit}:\mathrm{!num!}\mathrm{sgn}\mathrm{w}}\ &\quad\mathrm{wp}{\mathrm{vexpr}}\mathrm{lit}\xi\ &\ &\frac{\mathrm{WP-VEXPR-VAR}\textcircled{5}}{\ell\leftarrow\mathrm{wp}{\mathrm{pexpr}}\mathrm{id}\xi;\quad\mathrm{WP-VEXPR-BORROW-PLACE}\textcircled{5}}\ &\quad\frac{\mathrm{wp}{\mathrm{move}}\ell}{\mathrm{ret}{\mathrm{w}{\mathrm{CF}}}(\mathrm{ptr}\ell)\quad e\text{is pexpr}}\ &\quad\mathrm{wp}{\mathrm{vexpr}}\mathrm{id}\xi\ &\ &\frac{\mathrm{WP-VEXPR-BORROW-VALUE}\textcircled{5}}{\nu\leftarrow\mathrm{wp}{\mathrm{vexpr}}e\xi;\quad\ell\leftarrow\mathrm{wp}{\mathrm{imp}}\nu}\ &\quad\frac{\mathrm{ret}{\mathrm{w}{\mathrm{CF}}}\mathrm{ptr}\ell\quad e\text{is vexpr}}{\mathrm{wp}{\mathrm{vexpr}}&e\xi}\ &\ &\frac{\mathrm{WP-VEXPR-UNOP-NEG}\textcircled{5}}{\nu\leftarrow\mathrm{wp}{\mathrm{vexpr}}e\xi;\quad\mathrm{wp}{\mathrm{uneg}}\neg\nu}\ &\quad\frac{\mathrm{wp}{\mathrm{vexpr}}\neg e\xi}{\mathrm{WP-VEXPR-BINOP}\textcircled{5}}\ &\quad\frac{\nu\leftarrow\mathrm{wp}{\mathrm{vexpr}}e_{1}\xi;\quad\nu\leftarrow\mathrm{wp}{\mathrm{vexpr}}e{r}\xi;\quad\mathrm{wp}{\mathrm{binop}}\odot\nu\nu{r}}{\mathrm{wp}{\mathrm{vexpr}}e{1}\odot e_{r}\xi}\ \end{aligned}
Fig. 8. Weakest precondition predicate for value expressions, $wp_{vexpr}$\begin{array}{r l}&{\mathrm{w p}{\mathrm{p e x p r}}:\mathrm{E x p r}\to\Xi\to\mathrm{w p}{\mathrm{C F}}\mathcal{L}}\ &\ &\frac{\mathrm{W P-P E X P R-V A R}\textcircled{5}}{\mathrm{r e t}{\mathrm{w}{\mathrm{C F}}}\ell\quad\xi[\mathrm{i d}]=\ell}\ &{\quad\mathrm{w p}_{\mathrm{p e x p r}}\mathrm{i d}\xi}\end{array}
\begin{array}{r l}&{\mathrm{W P-V E X P R-B O R R O W-P L A C E}\textcircled{5}}\ &{\quad\nu\leftarrow\mathrm{w p}{\mathrm{v e x p r}}&\mathrm{m}\mathrm{e}\xi;}\ &{\quad\mathrm{w p}{\mathrm{t u m p}}\nu}\ &{\quad\mathrm{w p}_{\mathrm{p e x p r}}&\mathrm{m}\mathrm{e}\xi}\end{array}
Fig. 9. Weakest precondition predicate for place expressions, $wp_{pexpr}$ built up from sub-expressions, called operands, and their structure determines the control flow (cf. Sec. 2). Place and value expressions. Expressions fall into two categories: place expressions (pexpr)—paths referring to variables, dereferences, indexing, and field expressions, and denoting a memory location—and value expressions (vexpr), the rest, denoting actual values of the Rust Abstract Machine (Section 3). Within each expression, sub-expressions may occur in place or value expression context. For example, the operand of a field expression occurs in place expression context. Our semantics captures the distinction between place and value expression context using two weakest-precondition predicates, $wp_{pexpr}$ (Fig. 9) for place expressions, and $wp_{vexpr}$ (Fig. 8) for value expressions. The predicate $wp_{pexpr} e \xi \{ \ell.Q \}$ is the weakest precondition of an expression $e$ in function frame $\xi$, for a control-flow sensitive postcondition $\{\ell.Q\}$ that depends on location $\ell : \mathcal{L}$, the result of evaluating $e$. Similarly, $wp_{vexpr} e \xi \{ v.Q \}$ is the weakest precondition of an expression $e$ in value expression context for a postcondition that depends on value $v : \mathcal{V}$, the result of evaluating $e$. Note that the postcondition is determined by the ambient expression, which also determines whether the operand expression of $wp_{CF}$ predicate appears in place or value context. As a simple example, the weakest precondition of a boolean literal in value context, $wp_{vexpr}$ true $\xi \{v.Q\}$, reduces via WP-VEXPR-LITERAL-BOOL directly to $Q$ (bool true): for any postcondition $Q$, true satisfies it as long as $Q$ holds for the value representing boolean true. Integer literals work similarly, via WP-VEXPR-LITERAL-INT. A path referring to a local variable, e.g. foo, is a place expression; obtaining $wp_{peexpr}$ foo $\xi$ amounts to asserting the variable is present in the current frame $\xi$ and returning its location (cf. WP-PEXPR-VAR). A local-variable path can also occur in value context. Move and copy semantics. When a place expression occurs in place context, or a value expression in value context, the weakest precondition is accumulated directly. When a place expression occurs in value context—e.g. in a pattern binding—it denotes the value held at that location. If the value's type implements the Copy trait, it is copied; otherwise it may be moved out, de-initializing the location. We represent moving out of a location with the $wp_{move}$ predicate: Definition 4.3 (Move semantics, $wp_{move} \mathcal{R} : \mathcal{L} \to wp_{CF} \mathcal{V}$).wp_{move} \ell Q \triangleq \exists v. \ell \mapsto v * (\ell \mapsto \text{uninit} [![v]!]_{\text{type}_R}) \dashv * Q v
When moving out of a location $\ell$, the postcondition $Q$ is enriched with a separation logic obligation of ownership of a value $v$ represented at the location, $\exists v. \ell \mapsto v$. The original postcondition is provided an assumption that location $l$ has been uninitialised. Note that the encoding logic is affine and thus, we can read the statement such that we are required to "exchange" the $\ell \mapsto v$ fact for $\ell \mapsto \text{uninit} [\![v]\!]_{\text{type}_R}$, i.e. move the value $v$ out of location $\ell$. To continue with the example of the local variable foo, variables that are not currently borrowed can be moved out$^7$. When foo occurs in value context, $wp_{vexpr}$ foo $\xi Q$ can be constructed using WP-VEXPR-VAR by sequentially first constructing the weakest precondition of the path expression in place context and then moving the variable's value out of the place. The definition of $wp_{move}$ ensures that the variable is not currently borrowed using the ownership obligation. A value is copied instead of moving when its type implements the Copy trait. At the level of semantics, we treat copy as an optimization of a move: moving a value when copy was correct uninitializes the location, resulting in an unsatisfiable goal if the value is accessed again. This allows generic functions to be verified once under move semantics, with proofs reused for Copy-type monomorphizations. We refer the reader to the Rocq formalization for details. Temporaries. When a value expression is evaluated in place expression context, a temporary unnamed memory location ($a$ temporary) is created. It is initialized to the value, to which the expression then evaluates, and dropped at the end of its drop scope, usually the end of the enclosing statement. We define the appropriate predicate: Definition 4.4 (Semantics of temporaries, $wp_{tmpp} \mathcal{R} : \mathcal{V} \to wp_{CF} \mathcal{L}$).wp_{tmpp} v Q \triangleq \forall \ell. \ell \mapsto v \dashv * Q (\ell : ds) \ell
The $wp_{tmpp}$-transformed postcondition in goal position means a universally qualified location $\ell$ can be introduced into context as a fresh location, as well as the fact on the left side of the separation implication that the location now contains a representation of value $v$. Building on our running example, consider the weakest precondition of borrowing a literal, $wp_{vexpr} \& true \xi \{v.Q\}$. Using the inference rule WP-VEXPR-BORROW-VALUE, the weakest precondition is reduced to $(v \leftarrow wp_{vexpr} \text{ true} \xi; wp_{tmpp} v) \{v.Q\}$ and, after inlining the definition of $wp_{tmpp}$, $^7$cf. [1, expr.move.movable-place] František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel into {_.∀ℓ, ℓ↪ bool true --* Q bool true}, that is, the postcondition holds for any fresh location ℓ that stores the boolean value true. The fresh location ℓ introduced above is itself a temporary, and is dropped once its enclosing scope ends; the full drop scope mechanism—including statement temporaries, block-scoped locals, and arm bindings—is described in Appendix D. Arithmetic and logical operators. Arithmetic and logical operators allow for largely uniform treatment. In particular, unary negation (WP-VEXPR-UNOP-NEG) is obtained by sequencing the weakest precondition of an operand with the following predicate: Definition 4.5 (Semantics of unary negation, wp_uneg ☹ : UOp → V → wp_CF V).\begin{aligned} \text{wp}{\text{uneg}} ! (\text{bool } b) Q \triangleq Q(\text{bool } (\neg b)) \ \text{wp}{\text{uneg}} - (\text{int } s w z) Q \triangleq \text{nooverflow } s w (-z) * Q (\text{int } s w (-z)) \end{aligned}
\begin{aligned} \text{wp}{\text{vexprs}} [ ] \xi \triangleq \text{ret}{\text{w}{\text{CF}}} [ ] \ \text{wp}{\text{vexprs}} (e::es) \xi \triangleq \nu \leftarrow \text{wp}{\text{vexpr}} e \xi ; \ \quad \nu s \leftarrow \text{wp}{\text{vexpr}} es \xi ; \ \text{ret}{\text{w}{\text{CF}}} (v::vs) \end{aligned}
Consider, e.g., wp_vexpr(True, 42u8){v.Q v}. Using the rule WP-VEXPR-TUPLE and the rules for literals, we obtain Q (tuple (0, bool true), (1, int u 8 42)). Indexing into tuples is captured by WP-PEXPR-TUPLE-INDEX. Indexing expressions are place expressions, and wp_pexpr of the operand expression is obtained, and then the precondition is enriched with an assertion that the location contains a value: Definition 4.7 (Value-at-location, wp_val : $\mathcal{L} \to wp_{CF} \mathcal{V}$).\text{wp}_{\text{val}} \ell Q \triangleq \exists \nu. \ell \mapsto \nu * (\ell \mapsto \nu * \neg Q \nu)
\mathrm{wp}{\mathrm{pexpr}}:\mathrm{Expr}\rightarrow\Xi\rightarrow\mathrm{wp}{\mathrm{CF}}\mathcal{L})
\begin{array}{l}\mathrm{WP-VEXPR-TUPLE}\textcircled{5}\\mathrm{vs}\leftarrow\mathrm{wp}{\mathrm{vexprs}}es\xi;\\mathrm{let}fs=[(i,v)|i\mapsto v\in\mathrm{vs}]in\\quad\mathrm{ret}{\mathrm{w}{\mathrm{PCF}}}tuple fs\\quad\mathrm{wp}{\mathrm{vexpr}}(es)\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-ADT}\textcircled{5}\\mathrm{vs}\leftarrow\mathrm{wp}{\mathrm{vexprs}}fs.2\xi;\\mathrm{let}fs=[(d,v)|d\mapsto v\in zip fs.1\mathrm{vs}]in\\mathrm{let}l=1\mathrm{layout}d\mathrm{in}\\quad\mathrm{ret}{\mathrm{w}{\mathrm{PCF}}}\mathrm{adt}lfs\\quad\mathrm{wp}{\mathrm{vexpr}}(\mathrm{adt}dfs)\xi\end{array}
\begin{array}{l}\mathrm{WP-PEXPR-TUPLE-INDEX}\textcircled{5}\\ell\leftarrow\mathrm{wp}{\mathrm{pexpr}}e\xi;\\nu\leftarrow\mathrm{wp}{\mathrm{val}}\ell;\\mathrm{if}\nu!!\mathrm{tuple}n\mathrm{then}\\quad\mathrm{ret}{\mathrm{w}{\mathrm{PCF}}}\ell.n\\mathrm{else}\perp\\quad\mathrm{wp}_{\mathrm{pexpr}}e.n\xi\end{array}
\begin{array}{l}\mathrm{WP-PEXPR-ADT-FIELD}\textcircled{5}\\ell\leftarrow\mathrm{wp}{\mathrm{pexpr}}e\xi;\\nu\leftarrow\mathrm{wp}{\mathrm{val}}\ell;\\mathrm{if}\nu!!\mathrm{adt}n\mathrm{then}\\quad\mathrm{ret}{\mathrm{w}{\mathrm{PCF}}}\ell.d\\mathrm{else}\perp\\quad\mathrm{wp}_{\mathrm{pexpr}}e.d\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-IF}\textcircled{5}\\nu\leftarrow\mathrm{wp}{\mathrm{vexpr}}e{c}\xi;\\mathrm{if}\nu\text{is true then}\mathrm{wp}{\mathrm{vexpr}}e{t}\xi\\mathrm{else if}e_{f}\text{then}\mathrm{wp}{\mathrm{vexpr}}e{f}\xi\\mathrm{else}\mathrm{ret}{\mathrm{w}{\mathrm{PCF}}}\mathrm{unit}\\mathrm{wp}{\mathrm{vexpr}}\mathrm{if}e{c}e_{t}(\mathrm{else}e_{f})^{2}\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-BLOCK}\textcircled{5}\\frac{\mathrm{wp}{\mathrm{block}}ss e\xi}{\mathrm{wp}{\mathrm{vexpr}}\left{ss;e^{2}\right}\xi}\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-MATCH-V}\textcircled{5}\\nu\leftarrow\mathrm{wp}{\mathrm{vexpr}}e{scrt}\xi;\\mathrm{wp}{arms}e{scrt}pes\xi;\\mathrm{guard match}{CF}\quad e{scrt}is vexpr\\mathrm{wp}{vexpr}match e{scrt}\left{pes\right}\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-MATCH-P}\textcircled{5}\\ell\leftarrow\mathrm{wp}{\mathrm{pexpr}}e{scrt}\xi;\\nu\leftarrow\mathrm{wp}{val}\ell\\mathrm{wp}{arms}e_{scrt}pes\xi;\\mathrm{guard match}{CF}\quad e{scrt}is pexpr\\mathrm{wp}{vexpr}match e{scrt}\left{pes\right}\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-LOOP}\textcircled{5}\\mathrm{wp}{\mathrm{block}}ss e\xi;\\mathrm{guard~continue}{\mathrm{CF}}\\mathrm{wp}{\mathrm{vexpr}}\mathrm{loop}\left{ss;e\right}\xi\\mathrm{guard~break}{\mathrm{CF}}\\mathrm{wp}_{\mathrm{vexpr}}\mathrm{loop}\left{ss;e\right}\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-BREAK}\textcircled{5}\\mathrm{throw~break}{\mathrm{CF}}\\mathrm{wp}{\mathrm{vexpr}}\mathrm{break}\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-CONTINUE}\textcircled{5}\\mathrm{throw~continue}{\mathrm{CF}}\\mathrm{wp}{\mathrm{vexpr}}\mathrm{continue}\xi\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-CALL-GLOBNAME}\textcircled{5}\\mathrm{vs}\leftarrow\mathrm{wp}{\mathrm{vexprs}}e{\mathrm{sargs}}\xi;\\frac{\mathrm{wp}{\mathrm{fin}}fn\mathrm{crate}\mathrm{vs}}{\mathrm{wp}{\mathrm{vexpr}}fn(e_{\mathrm{sargs}})\xi}\end{array}
\begin{array}{l}\mathrm{WP-VEXPR-RETURN}\textcircled{5}\\nu\leftarrow\mathrm{wp}{\mathrm{vexpr}}e\xi;\\frac{\mathrm{throw}(\mathrm{return}{\mathrm{CF}}\nu)}{\mathrm{wp}_{\mathrm{vexpr}}\mathrm{return}e\xi}\end{array}
Fig. 10. Weakest precondition predicates for structured values Definition 4.8 (Semantics of blocks, $wp_{block}$): list Stmt $\rightarrow$ Expr $\rightarrow$ $\Xi \rightarrow wp_{CF} \mathcal{V}$).\begin{aligned}\mathrm{wp}{\mathrm{block}}\left(s::ss\right)e^{2}\xi\triangleq\xi\leftarrow\mathrm{wp}{\mathrm{stmt}}s\xi;\mathrm{wp}{\mathrm{block}}ss e^{2}\xi\\mathrm{wp}{\mathrm{block}}[\quad]e\xi\triangleq\mathrm{wp}{\mathrm{vexpr}}e\xi\\mathrm{wp}{\mathrm{block}}[\quad]\oslash\xi\triangleq\mathrm{ret}{\mathrm{w}{\mathrm{PCF}}}\mathrm{unit}\end{aligned}
For a block with a leading statement, the weakest precondition of the first statement is accumulated, then those of the remaining statements; a final expression, if present, contributes its own, with the postcondition applied to its value (or unit otherwise). The rule WP-VEXPR-BLOCK in wp_vexpr then reduces a block's weakest precondition to wp_block; e.g. wp_vexpr {(); 42} ξ Q becomes (wpstmt () ξ ; wp_vexpr 42 ξ) Q. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel If expressions. The if expression is the simplest non-trivial case of control flow: a boolean condition operand, a block, and optionally an else block. The condition is evaluated; if true, the block is evaluated, otherwise the else block if present. It is a value expression yielding the value of the evaluated block, or () if none was. The semantics is captured by WP-VEXPR-IF. In this simple form, applying the inference rule duplicates the postcondition; we address this in Section 6 via join-point reasoning. Match expressions. A match expression sequentially compares the value of a scrutinee to the patterns of its arms, evaluating the expression of the first arm whose pattern matches. It is the first construct in this paper that combines pattern-match failure (nomatchCF) with control-flow-transferring constructs (matchCF) in the control flow monad. The weakest precondition of an arm is: Definition 4.9 (Semantics of match arms, $wp_{arms}$ ☹: $\mathcal{V} \to \text{list Pat} \to \Xi$ and $wp_{arm}$).\begin{aligned}&\mathrm{wp}{\mathrm{arm}}\ \mathrm{v}{\mathrm{scrt}}\left(pat\Rightarrow e\right)\xi\triangleq\mathrm{wp}{\mathrm{pat}}\ pat\ e{\mathrm{scrt}}\xi;\mathrm{wp}{\mathrm{vexpr}}e\xi;\mathrm{match}{\mathrm{CF}}\ &\ &\mathrm{wp}{\mathrm{arms}}\ \mathrm{v}{\mathrm{scrt}}\left(a,as\right)\xi\triangleq\mathrm{wp}{\mathrm{arm}}a\xi;\mathrm{guard}\mathrm{nomatch}{\mathrm{CF}};\mathrm{wp}{\mathrm{arms}}\ \mathrm{v}{\mathrm{scrt}}as\xi\ &\quad\mathrm{wp}{\mathrm{arms}}\ \mathrm{v}{\mathrm{scrt}}\left[\ \right]\xi\triangleq\bot\ \end{aligned}
The weakest preconditions of arms are collected in order. If an arms control flow results in nomatch$_{CF}$, this state is turned back to sequential by the guard and the accumulation continues with the remaining arms. The weakest precondition of an empty set of arms is unsatisfiable since patterns in a match expression are exhaustive. The precondition of an arm, $wp_{arm}$, is that of the arm's pattern, sequentially followed by that of the arm's expression and then the match$_{CF}$ operation. Recall that $wp_{pat}$ (Fig. 6) yields nomatch$_{CF}$ on failed matches, skipping the expression's precondition, and is guarded by the ambient $wp_{arms}$; similarly, $wp_{vexpr}$ may yield other control flow state, propagated outside $wp_{arms}$. A match expression semantics slightly differs depending whether the scrutinee is a value or a place expression and is captured by WP-VEXPR-MATCH-V and WP-VEXPR-MATCH-P respectively. Loop, break, and continue expressions. A loop expression repeats evaluation of its body. A break in the body immediately terminates the loop; a continue terminates the current iteration. We model loops in WP-VEXPR-LOOP by 1-unfolding of the loop body. The unfolded body's precondition is guarded by continue$_{CF}$, which sequences the next iteration's precondition when evaluation was terminated by continue. The whole unfolding is guarded by break, which sequences the precondition of the program following the loop when evaluation terminated by break. The semantics currently supports neither labels on break/continue (Def. 4.1) nor break values, though both should be straightforward to add; treating loops as 1-unfoldings requires user-supplied invariants. ### 4.5 Function Items, Function Specifications, and Return Expression Functions represent the key evaluation abstraction mechanism in Rust. A crate consists of items, among them functions with given parameters. Functions are called by call expressions that bind parameters to concrete arguments, and a value is passed to a caller via a return expression. Functions are moreover the primary unit of code at which we state specifications. The semantics of functions is given as follows: Definition 4.10 (Semantics of functions, $wp_{fn}$): $\mathcal{D} \to \text{Crate} \to \text{list} \mathcal{V}$.\begin{aligned}wp_{fn}fncratevs_{args}&\triangleq\text{if}crate[fn](returnis(pats,e_{fn})then\&\quad\xi\leftarrow wp_{pats}[;];;\&\quad wp_{vexpr}patsvs_{args}e_{fn})\xi;;\&\quad guardreturn_{CF}\&\quad else\bot\end{aligned}
{S p e c}\triangleq\forall({a r g s}:{l i s t}\mathcal{V})\to(\forall(r:\mathcal{V})\to\mathrm{i P r o p})\to\mathrm{i P r o p}
\mathrm{f n_{i} t e m_{o} kf nc r a t e~s p e c}\triangleq\Box(\forall Q;v s_{a r g s}.s p e c;v s_{a r g s};Q\dashv*{\mathrm{w p}{f n}};f n;v s{a r g s};Q)
\begin{aligned}\frac{BINOP-ADD}{wp_{vexpr}e_{l}\xi\left{r.r=v\right}\mathrm{wp}{vexpr}e{r}\xi\left{r.r=v\right}\mathrm{nooverflow}\left(v+v_{r}\right)}\ \mathrm{wp}{vexpr}e{l}+e_{r}\xi\left{v.v=v+v_{r}\right}\end{aligned}
We observe that BINOP-ADD is an instance of the axiom WP-VEXPR-BINOP from fig. 8. The proof of BINOP-ADD readily adapts to WP-VEXPR-BINOP, showing it holds relative to the ITrees semantics for binary operations. Having established the approach on a pure fragment, we now extend the ITree semantics to a larger class of expressions that includes heap effects, e.g. let mut x = v. The semantics of an assignment is an itree (heapE +' ubE) V, modeling a computation that can either result in a value, trigger an overflow ubE, or have an effect on the heap, described by the event type heapE. Intuitively, a heapE corresponds to get or set the value at a certain location l. For the triggering of heapE to satisfy a certain predicate $\Phi$, it is necessary to prove ownership of the location l and that the current or the updated value satisfy $\Phi$. As a consequence, the weakest pre-condition for let mut x = v to satisfy $\Phi$ requires x to point to a location l that, if updated with the value v, guarantees $\Phi$:\begin{aligned}&\frac{\mathrm{LET V-LEMMA}}{\left(x\mapsto l\right)*\left((l\mapsto v)\ast\Phi\right)}\&\frac{\mathrm{wp}_{\mathrm{stmt}}\left(\mathrm{let}\mathrm{mut}x=\vee\right)\xi\left{\Phi\right}}\end{aligned}
The modularity of this approach now becomes crucial. The ITrees library allows to naturally lift an itree ubE $\mathcal{V}$ into an itree (heapE +' ubE) $\mathcal{V}$ and, at the cost of proving an adequacy result (cf. [54]), to soundly use the weakest precondition rules proven for binary operation when reasoning about programs involving assignments. We can thus prove:\begin{aligned}&\frac{\mathrm{LET-ADDV-LEMMA}}{\left(x\mapsto l\right)\mathrm{nooverflow}\left(v_{l}+v_{r}\right)\left(v=v_{l}+v_{r}\right)*\left((l\mapsto v)\ast\Phi\right)}\&\quad\mathrm{wp}{\mathrm{stmt}}\left(\mathrm{let}\mathrm{mut}x=\left(v{l}+v_{r}\right)\right)\xi\left{\Phi\right}\end{aligned}
We observe that both LETV-LEMMA and LET-ADDV-LEMMA are instances of WP-STMT-EXPR from fig. 7, which can be proven by modularly extending the ITrees semantics to all $s \in Stmt$ following the approach illustrated above. To conclude, we establish the soundness of the axioms from Sec. 4 incrementally, by modularly extending the ITrees semantics to further terms in Expr and Stmt. Where necessary, we introduce new event types, e.g. heapE above, and show the reasoning principles for the events introduced are\begin{array}{r l}&{\mathrm{W P-B L O C K-C O N S}}\ &{\xi^{\prime}\leftarrow\mathrm{w p}{\mathrm{s t m t}};s;\xi;;}\ &{\frac{\mathrm{w p}{\mathrm{b l o c k}}^{\mathrm{s e a l}}\left{\mathrm{s s};;;e^{\prime}\right};\xi^{\prime}}{\mathrm{w p}_{\mathrm{s t m t}}\left{\mathrm{s};;;\mathrm{s s};;;e^{\prime}\right};\xi}}\ &\end{array}
\begin{array}{r l}&{\mathrm{W P-I F-J O I N}}\ &{\quad\mathrm{w p}{\mathrm{v e x p r}};e{T};\xi;(P;t r u e);--;R}\ &{\frac{\mathrm{w p}_{\mathrm{v e x p r}};e;\xi;(\lambda v.P vF)\quad\mathrm{w p}{\mathrm{v e x p r}};e{F};\xi;(P;f a l s e);--;R\quad RF;--*;Q}{\mathrm{w p}{\mathrm{v e x p r}};(\mathrm{i f};e;e{T};\mathrm{e l s e};e_{F});\xi;Q}}\end{array}
Fig. 11. Program logic, derived lemmata (full set, including WP-BLOCK-NIL-E, WP-BLOCK-NIL-NE, and WP-PAT-CONST, in Appendix F) adequate with respect to the reasoning principles established for the other event types. Completed proofs are final: ITrees's compositionality guarantees they remain valid as coverage grows, so lifting, e.g., an itree ubE · denotation into itree (heapE +' ubE) · costs one adequacy lemma for the new event type, never a re-proof of the existing fragment. We have completed this argument for the pure fragment and heap-manipulating statements illustrated above; per-axiom status for the remaining constructs is itemized in Appendix G. However, full soundness establishes only internal consistency– the axioms are satisfied by an operational model– and does not guarantee that the axioms capture the intended semantics of Rust as a programmer would expect; test-suite validation we discuss in Sec. 4 is therefore a necessary complement. ## 6 Program Logic The axiomatic semantics in Sec. 4 provides a basis for reasoning about program behavior. However, it operates at a low level of abstraction, making direct proofs detailed and unwieldy. Moreover, the direct encoding of Rust semantics leads to large proof goals in Rocq, which slow down both interactive proof development and final proof checking (Qed-time) in Rocq. To address these issues, we develop an additional reasoning layer in the form of a program logic. As motivated in Sec. 2, proofs need to be structured in a way that the axiomatic semantics does not provide: (1) Controlling WP accumulation through sealing, which improves readability, controls the evaluation order to limit proof term size and improves performance.(2) Reordering WP accumulation, which enables reasoning in an idiomatic manner, closely aligned with the structure of the Rust source code. (3) Join-point reasoning supporting modular reasoning about shared proof contexts. Directing evaluation. As discussed in Section 4, $wp_{block}$-the weakest precondition of a block expression—is defined recursively as a fixpoint over the block's sequence of statements: the $wp_{block}$ definition for a block expression containing many statements unfolds into a long, nested chain of sequentialized statements. To mitigate this issue, we employ a standard technique in Rocq: sealing definitions, that is, making them opaque and exposing only specific lemmata for controlled unfolding. In the case of $wp_{block}^{seal}$, we provide three such lemmata (Fig. 11): WP-BLOCK-CONS for blocks with a leading statement, and WP-BLOCK-NIL-E and WP-BLOCK-NIL-NE for empty blocks, depending on whether a trailing expression is present. The first rule enables evaluating the leading statement first, keeping the remaining block opaque until needed. $^9$ Note that these lemmata, and all others in the program logic, are proven from the axioms of the semantics and are thus sound relative to it. Reordering evaluation. WP accumulation in the semantics proceeds by structural traversal of the AST, which does not always align with the order in which a programmer would naturally reason about evaluation—for instance, matching against a literal pattern accumulates the WP of the scrutinee before that of the pattern's constant, though the constant's evaluation does not depend $^{9}$Appendix F gives the full walkthrough. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel on the scrutinee. We introduce a sealed definition delayed $_{cpat}$ that reorders this: it accumulates the WP of the pattern's constant expression first, then that of the scrutinee, checking the match once both are available. This reordering is sound because the two evaluations are independent—there are no side effects or dependencies that would constrain their order. $^{10}$ Join-point reasoning. A third situation in which the program logic substantially simplifies proofs arises with join-point reasoning. Several language constructs evaluate a scrutinee and dispatch control flow based on the result; the simplest instance is the if expression. When accumulating WPs, the value of the test expression may not be concrete, requiring both branches to be analyzed independently, and the remainder of the program after the conditional is often identical regardless of which branch was taken, leading to duplicated proof and inflated proof terms. To avoid this duplication, we employ join-point reasoning, captured by the inference rule WP-IF-JOIN (Fig. 11): we identify a common precondition $P$ sufficient for either branch to establish a shared intermediate postcondition $R$, discharge the branches independently against $R$, and prove the shared continuation once, composing $R$ with the frame $F$-the spatial resources not consumed by the branch proofs—to establish the overall postcondition $Q$. This technique is not limited to if expressions: the same style of reasoning applies to match expressions, and reasoning about loop expressions also requires join-point reasoning, with the loop invariant serving as the join-point pre- and post-condition connecting iterations.¹¹ Defunctionalized continuation stacks. Sealing $wp_{block}^{seal}$ controls proof goal size for straight-line code, but a deeper source of blowup remains: the $bind_{w_{PCF}}$ combinator accumulates the sequential postcondition $Q_{seq}$ as a nested closure at every step ( $bind_{w_{PCF}} f w Q_{seq} Q_{rt} = w (\lambda a. f a Q_{seq} Q_{rt}) Q_{rt}$), producing deeply nested closure trees in proof goals for long blocks. Guard combinators (Sec. 4) similarly rebuild both continuations at each scope boundary. These closure trees cause slow Qed-times and make proof states difficult to read. We address this by defunctionalizing the two continuations into sealed first-order stacks: Definition 6.1 (Continuation stacks).\begin{aligned}scont A::=SKnil(Q_{seq}:A\to iProp)\mid SKbind(f:A\to w_{PCF}B)(rest:scont B)\hcont::=HKnil(Q_{rt})\mid HK_{X}f(S:scont)rest\end{aligned}
scont A is a type-aligned list of pending Kleisli arrows—each SKbind frame corresponds to one application of $bind_{w_{PCF}}$. hcont is a list of installed guard scopes; $HK_X$ entries are pushed by $guard_{X-CF}$ combinators at loop, function, and match boundaries. The key algebraic fact is that $bind_{w_{PCF}}$ threads $Q_{rt}$ unchanged—only the guard combinators install a new control-flow handler—so the handler stack is shared across the entire $bind_{w_{PCF}}$ chain: a proof goal contains one hcont, not one per bind step. Branching constructs (if, match) do not break this sharing: as detailed below, join-point reasoning lets both branches continue into the same scont tail, so the shared continuation is not duplicated per branch either. The two stacks are given sealed denotation functions seqK and rtK:seqK Q_{rt}\left(SKnil Q\right)=Q
seq K Q_{rt}\left(SKbind f S\right)=\lambda a.f a\left(seq K Q_{rt}S\right)Q_{rt}
rtK\left(HKnil Q_{rt}\right)=Q_{rt}
rtK\left(HK_{X}f S H\right)=guard_{X}f\left(seq K\left(rt K H\right)S\right)\left(rt K H\right)
$^{10}$Appendix F gives delayed $_{cpat}$'s definition and the derivation in full. $^{11}$Appendix F walks through the general case. Sealing both functions with mlock prevents cbn/simpl from expanding the stacks back into closure trees. The equational lemmas seqK-unfold and rtK-unfold unfold exactly one frame per rewrite, driving the proof forward without exposing the full continuation. Each guard$_{X-CF}$ scope installation pushes one $HK_X$ handler and one $SKbind$ frame; each bind$_{WP_{CF}}$ step pushes one $SKbind$ frame. Proof-mode tactics ($tac\_bind\_norm$, $tac\_guard\_X$, etc.) are re-proved against seqK ($rtK H$) $S / rtK H$ and keep their existing names, so existing proof scripts require no changes beyond the renamed continuation arguments. Sequential join-points share $scont$ tails structurally (persistent linked lists), and $rtK H$ is let-bound once per scope so it is not syntactically duplicated in the proof goal. The result is a proof state that carries a compact pair $(S, H)$ of first-order data structures in place of a deeply nested closure tree, substantially reducing $Qed$-times and improving readability of intermediate goals. ## 7 Automation The inference rules of our program logic are syntax-directed and, importantly, can be formulated such that their conclusions are non-overlapping. This design choice directly enables proof automation: for any given sub-goal with a WP predicate in head position, the appropriate rule can be selected deterministically, allowing WP accumulation to proceed without manual rule selection. We develop an automation layer that drives proofs by repeatedly applying the program logic rules. Our automation pipeline proceeds through the following stages: (1) *Premise introduction and normalisation:* preprocessing the goal, introducing required hypotheses, and normalising its structure to expose the next reducible program construct. (2) *Logical inference rule selection:* deterministically choosing and applying the program-logic rule corresponding to the syntactic form of the current expression or statement. (3) *Sequentialisation of control flow:* restructuring the goal to reflect the sequential evaluation order imposed by the specification monad. (4) *Solving separation-logic side obligations:* discharging the spatial side conditions generated by the logic, such as ownership splitting, joining, or framing. This pipeline repeats until no further progress can be made, performing WP accumulation automatically for large fragments of the program—the resulting tactic we call wp_engage. We also provide specialized tactics, e.g. wp_fn for function prelude book-keeping, wp_if for join-point reasoning over if expressions, and wp_call for function calls; factoring these out of the main loop significantly improves the readability and maintainability of proof scripts [35]. Program-logic lemmata are not applied directly to entailments of the underlying separation logic; instead they are lifted into Iris Proof Mode (IPM) [28] entailments by generic transformers, dispatched on the term under the WP by a dedicated Rocq tactic. Whenever automation stalls, the full expressiveness of IPM remains available to continue the proof manually. The proofmode tactics operate directly on the defunctionalized continuation stacks (Sec. 6), so that e.g. a bind$_{WP_{CF}}$ application pushes a new $SKbind$ frame via seqK-unfold instead of building a closure.¹² A distinguishing feature of THIR-level proofs is that the Rocq proof goal displays the THIR AST under the WP, which pretty-prints directly to surface Rust—e.g. a Corten goal for $x + 1$ looks like $wp_{vexpr} \times + 1 \xi Q$. This contrasts with MIR-level tools, whose goals expose an explicit basic-block transition with temporaries, forcing users to reconstruct the correspondence to source code. This proximity to source, a direct consequence of working at THIR, is the primary ergonomic benefit over MIR-level foundational tools. ¹²Appendix F details the tactic-level mechanics. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel Evaluation. Our automation already yields a substantial reduction in proof effort. As noted in Sec. 4, the test suite serves as semantic validation; here we use it to compare proof effort per test, contrasting proofs carried out directly via the semantics against automated ones. Table 1 reports non-blank lines of code (measured by cloc¹³) for each test collection. <table border="1"><tr><td>test</td><td>src</td><td>spec</td><td>raw</td><td>auto</td></tr><tr><td>arith</td><td>90</td><td>174</td><td>624</td><td>238</td></tr><tr><td>arrays</td><td>25</td><td>78</td><td>222</td><td>106</td></tr><tr><td>assign</td><td>23</td><td>48</td><td>268</td><td>48</td></tr><tr><td>cf</td><td>24</td><td>41</td><td>88</td><td>43</td></tr><tr><td>ifs</td><td>27</td><td>36</td><td>112</td><td>140</td></tr><tr><td>impls</td><td>55</td><td>161</td><td>305</td><td>63</td></tr><tr><td>matching</td><td>143</td><td>200</td><td>1073</td><td>142</td></tr><tr><td>tuple</td><td>46</td><td>52</td><td>453</td><td>191</td></tr><tr><td>types</td><td>56</td><td>51</td><td>59</td><td>30</td></tr><tr><td>unary</td><td>18</td><td>32</td><td>112</td><td>39</td></tr></table> Table 1. Non-blank lines of code (src) and proofs in Rust source, and Rocq specification (spec), semantics based proofs (raw), and automated proofs (auto). Overall, the automated proofs are roughly two to four times shorter than their raw counterparts. Specifications are consistently about twice the size of the code, and automated proofs about two to four times the size of the underlying Rust programs. The anomaly for if expressions stems from the overhead of specifying join-point pre- and postconditions in a test file focused on them. ## 8 Case Study As a case study, we verify a buddy allocator [26], a standard memory-management data structure in operating systems, implemented without regard to ease of verification (approximately 300 lines of Rust, using idiomatic features such as extensive match expressions). The top-level specification of alloc is, abbreviating the representation predicate buddyRep relating the Rust value to an abstract state (bs, hs) of block-control and free-list-head lists—and folding in the free-list well-formedness invariant over that abstract state—and writing layoutRep l size align for the predicate relating the caller-supplied Layout argument l to the requested size and alignment:\begin{aligned}self\mapsto v* buddyRep v bs hs* layoutRep l size align*(bounds side-conditions on size,align)\\vdash wp_{fin}alloc\left[self,l\right]\left{v^{\prime}\mid\exists bs^{\prime}hs^{\prime}.self\mapsto v^{\prime}*buddyRep v^{\prime}bs^{\prime}hs^{\prime}\right}\end{aligned}
Allocation and deallocation are specified to preserve both the representation and the free-list well-formedness invariant it carries, with the concrete internal state existentially quantified in the post-condition. The specification does not claim functional correctness of the allocation strategy—e.g. best-fit selection or any fragmentation bound—only that whatever block is returned is disjoint from, and does not corrupt, the allocator's remaining state; this is the appropriate notion of correctness for a Rust allocator, which cannot rely on allocations actually happening $^{14}$. Establishing it requires functional specifications for all functions the allocator calls—mostly showing that the free-block lists remain well-formed after each operation—and is relative to (unproven) specifications of the Rust core functions it uses. The resulting proof script, including specifications, amounts to approximately 2800 lines of Rocq: around 250 lines of function specifications, around 800 lines $^{13}$https://github.com/AlDanial/cloc $^{14}$cf. https://doc.rust-lang.org/alloc/alloc/trait.GlobalAlloc.html#safety of general reasoning about Rust constructs (including around 100 lines for join-point pre- and postconditions), around 1400 lines of domain-specific lemmas re-establishing the free-block-list invariants, and the remainder generic Rocq lemmata. Automation and the program logic were instrumental in keeping this size down; in particular, join-point reasoning (Sec. 6) eliminated otherwise necessary proof duplication, leaving the Rust-specific reasoning mostly automated and the bulk of the effort in domain-specific invariant re-establishment. ## 9 Related Work Rust Verification. Table 2 compares Corten to the Rust verification tools discussed below. Miri [20] <table><thead><tr><th>Tool</th><th>Level</th><th>Found.</th><th>Automation</th></tr></thead><tbody><tr><td>Miri [20]</td><td>MIR, dynamic</td><td>—</td><td>Concrete execution</td></tr><tr><td>Kani [10, 52]</td><td>MIR → Goto-C</td><td>No</td><td>SAT/SMT</td></tr><tr><td>Verus [29]</td><td>Rust (ghost code) → SMT-LIB</td><td>No</td><td>SMT</td></tr><tr><td>Prusti [5]</td><td>MIR → Viper</td><td>No</td><td>SMT</td></tr><tr><td>RustHorn(Belt) [37]</td><td>Rust → CHC</td><td>No</td><td>CHC</td></tr><tr><td>Creusot [11]</td><td>MIR → Why3</td><td>No</td><td>SMT</td></tr><tr><td>Flux [30]</td><td>MIR</td><td>No</td><td>Highly automatic</td></tr><tr><td>RefinedRust [14]</td><td>MIR</td><td>Yes</td><td>Lithium</td></tr><tr><td>Aeneas [16]</td><td>Rust → functional</td><td>Semi</td><td>Manual/interactive</td></tr><tr><td>Corten</td><td>THIR</td><td>Yes</td><td>Syntax-driven</td></tr></tbody></table> Table 2. Rust verification tools comparison (cf. Table 3, Appendix E, for a full comparison). is the most widely used lightweight tool for detecting Rust memory-safety issues, executing programs against the Rust Abstract Machine to catch undefined behavior in concrete runs (Table 2). Kani [10, 52] similarly targets Rust's MIR, but via bounded model checking against CBMC's SAT/SMT backends rather than concrete execution. Verus [29] supports linear ghost types for separation-logic-style reasoning, and Prusti [5] builds on the Viper [42] verification infrastructure. RustHorn [38] inspired subsequent Horn-clause-based work including Creusot [11], which supports more expressive specifications than Prusti via Why3 [13]. Flux [30] takes a different, highly automatic approach via liquid (refinement) types with inferred invariants, requiring far less annotation than Prusti or Creusot. While these tools achieve a high degree of automation, they all rely on external solvers, which limits the expressiveness of specifications, precludes foundational end-to-end guarantees, and introduces solvers into the TCB. The tools most closely related to Corten are RefinedRust [14] and Aeneas [16]. RefinedRust, like Corten, is foundational, built on Iris, and supports modular reasoning, providing a semantic type model for Rust in Rocq. Two differences are worth highlighting. First, RefinedRust's MIR-level proof goals expose the control-flow graph, whereas Corten's THIR-level goals pretty-print directly to source Rust (Sec. 7 works through a concrete example). Second, the theoretical encodings differ: Corten is based on Hoare-type theory with a weakest-precondition specification monad (Sec. 4.1), while RefinedRust uses a refinement-type model. Aeneas [16] takes a different approach, translating a subset of Rust into a pure functional language verified in F*, Lean, or Rocq (Table 3 details its coverage). Hax [6] also extracts THIR, but as a multi-backend translation framework targeting F*, Rocq, Lean (via Aeneas), and domain-specific provers (ProVerif, SSProve) for security-critical code such as cryptographic libraries; unlike the tools above, hax does not itself verify, handing proof obligations to whichever backend is chosen—Corten builds directly on hax's THIR extraction rather than competing with it. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel RefinedC [46] is closest in aim to Corten outside Rust: Iris- and Rocq-based, targeting systems-level C with similar architectural choices, absent Rust's ADTs and pattern matching. VST [4] verifies C in Rocq via separation logic; Mansky and Du [36] re-ground it in Iris and want an Iris-style tactic interface for entering Iris Proof Mode inside automated proofs—a design Corten already supports. Semantics of Rust. RustBelt [19] gives the first foundational semantic model of λRust (a core Rust-subset calculus), via a logical relation proving type-system soundness and enabling formal reasoning about unsafe code. MiniRust [17], an ongoing reference model for Rust's memory semantics (value representation, ownership, undefined behavior), inspires Corten's memory model. Stacked Borrows [18] and Tree Borrows [53] are candidate operational aliasing models formalizing the provenance guarantees the borrow checker enforces, validated dynamically via Miri and not yet adopted as a normative part of the Rust specification; we intend to use the lifetime information they expose as an untrusted automation oracle (Sec. 3). KRust [56] gives an executable K-framework semantics of a Rust subset, automatically deriving an interpreter from rewriting rules; it provides no program logic and no proof-assistant mechanization. C and C++'s formal semantics predate Rust's by decades, despite sharing its concerns around memory ownership, provenance, and undefined behavior. Cerberus [39] and Krebbers' [27] C memory model give precise accounts of these rules; we plan to draw on their design as Corten develops further. Effectful semantics. ITrees [58] provide a framework for giving operational semantics to effectful computations as denotations to coinductive interaction trees in Rocq. Corten derives the soundness of its axiomatic semantics via the Program logics à la carte framework [54]; We have completed ITree denotations and soundness proofs for a fragment of the supported language constructs, and we are working towards covering the full semantics. Corten's control-flow sensitive specification monad $wp_{CF}$ · is an instance of the Dijkstra monad construction [3, 33, 34], which provides a foundation for deriving WP connectives for arbitrary monadic computations. As noted by Vistrup et al. [54] Dijkstra monads do not support concurrent reasoning and lack separation logic support for local reasoning about memory. Corten addresses both gaps by constructing the underlying continuation monad atop Iris's iProp, directly inheriting Iris's higher-order concurrent separation logic. The two-continuation design of $wp_{CF} A \triangleq (A \to iProp) \to CFpred \to iProp$ is a novel recombination of several independently well-established ideas. Structurally, the two barrels are an instance of Thielecke's double-barrelled CPS [51], generalized here to a monotone predicate over the five-constructor CF sum rather than a single generic control/jump continuation. Theoretically, the design falls within the Dijkstra monad lineage of Swamy et al. [50] through Ahman et al. [3] to Maillard et al. [34]; Maillard et al. [34] explicitly reconstructs and subsumes the classical weakest exceptional preconditions of Leino and van de Snepscheut [31] (wp(S, Q, R) with a normal and an exceptional postcondition) inside Dijkstra monads. The closest mechanized predecessor is VST's C-light continuation semantics [4], which carries a family of postconditions indexed by an exitkind (EK_brk, EK_con, EK_ret)—the same “postcondition per control-flow outcome” idea, realized as positional tuples rather than as a single monPred-indexed continuation threaded unchanged by bind. The algebraic-effects reading is also applicable: throw is an algebraic operation that commutes with $bind_{wp_{CF}}$ (the defining property of algebraic operations per Plotkin–Pretnar [44]), and the guard combinators at loop, function, and match boundaries are the corresponding handlers. The specific combination—Iris monPred-indexed control-flow barrel, threaded unchanged by $bind_{wp_{CF}}$, trapped by construct-specific combinators, packaged as a single WP specification monad in Rocq—is absent from other Rocq/Iris tools (Program Logics à la Carte [54], RefinedC/RefinedRust [14, 46], Katamaran [22], Silver and Zdancewic's ITree-based Dijkstra monads [48]), which all use a single return postcondition. The defunctionalized continuation stacks `scont/hcont` (Sec. 6) are an application of defunctionalization [45] to the two-barrel WP monad; the sequential stack `scont` is additionally an instance of the reflection-without-remorse / freer-monad Kleisli sequence representation of Kiselyov and Ishii [23]. ## 10 Conclusions and Future Work We have presented Corten, a foundational, THIR-level verification framework for Rust programs in the Rocq theorem prover, grounded in the Rust Reference (§4) and layered atop it with a program logic (§6) and a proof automation layer (§7), demonstrated on a buddy allocator case study (§8). The layered architecture—separating axiomatic semantics, program logic, and automation—allows language coverage and soundness to be grown incrementally as the framework matures. Several directions remain for future work. The long-term goal motivating Corten's design is end-to-end verification of systems across hardware-software boundaries in a shared Rocq foundation; this includes verified compilation of Rust to the target hardware, for which recent work proposed a promising path [2]. We are currently scaling Corten to larger case studies—a unikernel and a THIR to MIR compiler, both implemented in Rust. At the same time, we are extending soundness of the axiomatic semantics to all supported language constructs. On the automation side, adapting Iris automation frameworks such as Diaframe [41] or Lithium [14, 46] to Corten is a natural next step. ## References [1] [n. d.]. *The Rust Reference*. https://doc.rust-lang.org/stable/reference [2] Carmine Abate, Mohamed Elsheikh, Kleio Lotati, František Farka, and Sebastian Ertel. 2026. WP-Preserving Compilation—Preserving Weakest Preconditions for End-to-End Verification. In *Principles of Secure Compilation* (PriSC 2026). [3] Daniel Ahman, Catalin Hritcu, Kenji Maillard, Guido Martinez, Gordon D. Plotkin, Jonathan Protzenko, Aseem Rastogi, and Nikhil Swamy. 2017. Dijkstra monads for free. In *Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages*, POPL 2017, Paris, France, January 18-20, 2017, Giuseppe Castagna and Andrew D. Gordon (Eds.). ACM, 515–529. doi:10.1145/3009837.3009878 [4] Andrew W. Appel. 2014. *Program Logics - for Certified Compilers*. Cambridge University Press. http://www.cambridge.org/de/academic/subjects/computer-science/programming-languages-and-applied-logic/program-logics-certified-compilers?format=HB [5] Vytautas Astrauskas, Aurel Bily, Jonás Fiala, Zachary Grannan, Christoph Matheja, Peter Müller, Federico Poli, and Alexander J. Summers. 2022. The Prusti Project: Formal Verification for Rust. In *NASA Formal Methods - 14th International Symposium, NFM 2022*, Pasadena, CA, USA, May 24-27, 2022, *Proceedings (Lecture Notes in Computer Science, Vol. 13260)*, Jyotirmoy V. Deshmukh, Klaus Havelund, and Ivan Perez (Eds.). Springer, 88–108. doi:10.1007/978-3-031-06773-0_5 [6] Karthikeyan Bhargavan, Maxime Buyse, Lucas Franceschino, Lasse Letager Hansen, Franziskus Kiefer, Jonas Schneider-Bensch, and Bas Spitters. 2024. hax: Verifying Security-Critical Rust Software Using Multiple Provers. In *International Conference on Verified Software: Theories, Tools, and Experiments*. Springer, 96–119. [7] Richard Bornat, Cristiano Calcagno, Peter W. O'Hearn, and Matthew J. Parkinson. 2005. Permission accounting in separation logic. In *Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages*, POPL 2005, Long Beach, California, USA, January 12-14, 2005, Jens Palsberg and Martin Abadi (Eds.). ACM, 259–270. doi:10.1145/1040305.1040327 [8] John Boyland. 2003. Checking Interference with Fractional Permissions. In *Static Analysis, 10th International Symposium, SAS 2003, San Diego, CA, USA, June 11-13, 2003, Proceedings (Lecture Notes in Computer Science, Vol. 2694)*, Radhia Cousot (Ed.). Springer, 55–72. doi:10.1007/3-540-44898-5_4 Frantisek Farka, Carmine Abate, Sven Linker, and Sebastian Ertel [9] Adam Chlipala. 2011. Mostly-automated verification of low-level programs in computational separation logic. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2011, San Jose, CA, USA, June 4-8, 2011, Mary W. Hall and David A. Padua (Eds.). ACM, 234–245. doi:10.1145/1993498.1993526 [10] Rémi Delmas, Zyad Hassan, Qinheping Hu, Rahul Kumar, Felipe R. Monteiro, Thanh Nguyen, Adrián Palacios, Celina Val, Michael Tautschnig, Justus Adam, Daniel Schwartz-Narbonne, and Carolyn Zech. 2026. Kani: A Model Checker for Rust. arXiv:2607.01504 https://arxiv.org/abs/2607.01504 Accepted at the 39th IEEE/ACM International Conference on Automated Software Engineering (ASE 2026), Industry Showcase Track. [11] Xavier Denis, Jacques-Henri Jourdan, and Claude Marché. 2022. Creusot: A Foundry for the Deductive Verification of Rust Programs. In Formal Methods and Software Engineering - 23rd International Conference on Formal Engineering Methods, ICFEM 2022, Madrid, Spain, October 24-27, 2022, Proceedings (Lecture Notes in Computer Science, Vol. 13478), Adrián Riesco and Min Zhang (Eds.). Springer, 90–105. doi:10.1007/978-3-031-17244-1_6 [12] The Rocq development team. 2025. The Rocq prover reference manual. LogiCal Project. https://rocq-prover.org/doc/V9.1.0/refman/index.html Version 9.1.0. [13] Jean-Christophe Filliâtre and Andrei Paskevich. 2013. Why3 - Where Programs Meet Provers. In Programming Languages and Systems - 22nd European Symposium on Programming, ESOP 2013, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2013, Rome, Italy, March 16-24, 2013. Proceedings (Lecture Notes in Computer Science, Vol. 7792), Matthias Felleisen and Philippa Gardner (Eds.). Springer, 125–128. doi:10.1007/978-3-642-37036-6_8 [14] Lennard Gäher, Michael Sammler, Ralf Jung, Robbert Krebbers, and Derek Dreyer. 2024. RefinedRust: A Type System for High-Assurance Verification of Rust Programs. Proc. ACM Program. Lang. 8, PLDI (2024), 1115–1139. doi:10.1145/3656422 [15] Ronghui Gu, Zhong Shao, Hao Chen, Xiongnan (Newman) Wu, Jieung Kim, Vilhelm Sjöberg, and David Costanzo. 2016. CertiKOS: An Extensible Architecture for Building Certified Concurrent OS Kernels. In 12th USENIX Symposium on Operating Systems Design and Implementation, OSDI 2016, Savannah, GA, USA, November 2-4, 2016, Kimberly Keeton and Timothy Roscoe (Eds.). USENIX Association, 653–669. https://www.usenix.org/conference/osdi16/technical-sessions/presentation/gu [16] Son Ho and Jonathan Protzenko. 2022. Aeneas: Rust verification by functional translation. Proc. ACM Program. Lang. 6, ICFP (2022), 711–741. doi:10.1145/3547647 [17] Ralf Jung. 2025. MiniRust: A core language for specifying Rust. Talk presented at the RustWeek NL. Utrecht, The Netherlands. [18] Ralf Jung, Hoang-Hai Dang, Jeehoon Kang, and Derek Dreyer. 2020. Stacked borrows: an aliasing model for Rust. Proc. ACM Program. Lang. 4, POPL (2020), 41:1–41:32. doi:10.1145/3371109 [19] Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2018. RustBelt: securing the foundations of the rust programming language. Proc. ACM Program. Lang. 2, POPL (2018), 66:1–66:34. doi:10.1145/3158154 [20] Ralf Jung, Benjamin Kimock, Christian Poveda, Eduardo Sánchez Muñoz, Oli Scherer, and Qian Wang. 2026. Miri: Practical Undefined Behavior Detection for Rust. Proc. ACM Program. Lang. 10, POPL (2026), 1383–1411. doi:10.1145/3776690 [21] Ralf Jung, Robbert Krebbers, Jacques-Henri Jourdan, Ales Bizjak, Lars Birkedal, and Derek Dreyer. 2018. Iris from the ground up: A modular foundation for higher-order concurrent separation logic. J. Funct. Program. 28 (2018), e20. doi:10.1017/S0956796818000151 [22] Steven Keuchel, Sander Huyghebaert, Georgy Lukyanov, and Dominique Devriese. 2022. Verified Symbolic Execution with Kripke Specification Monads (and No Meta-Programming). In Proceedings of the ACM on Programming Languages (ICFP), Vol. 6. 97. doi:10.1145/3547628 [23] Oleg Kiselyov and Hiromi Ishii. 2015. Freer Monads, More Extensible Effects. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell. 94–105. doi:10.1145/2804302.2804319 [24] Steve Klabnik and Carol Nichols. 2018. The Rust Programming Language. No Starch Press, USA. [25] Gerwin Klein, Kevin Elphinstone, Gernot Heiser, June Andronick, David A. Cock, Philip Derrin, Dhammika Elkaduwe, Kai Engelhardt, Ralf Kolanski, Michael Norrish, Thomas Sewell, Harvey Tuch, and Simon Winwood. 2009. seL4: formal verification of an OS kernel.. In Proceedings of the 22nd ACM Symposium on Operating Systems Principles 2009, SOSP 2009, Big Sky, Montana, USA, October 11-14, 2009, Jeanna Neefe Matthews and Thomas E. Anderson (Eds.). ACM, 207–220. doi:10.1145/1629575.1629596 [26] Kenneth C. Knowlton. 1965. A fast storage allocator. Commun. ACM 8, 10 (Oct. 1965), 623–624. doi:10.1145/365628.365655 [27] Robbert Krebbers. 2016. A Formal C Memory Model for Separation Logic. Journal of Automated Reasoning 57, 4 (2016), 319–387. doi:10.1007/s10817-016-9369-1 Preprint: arXiv:1509.03339. [28] Robbert Krebbers, Jacques-Henri Jourdan, Ralf Jung, Joseph Tassarotti, Jan-Oliver Kaiser, Amin Timany, Arthur Charguéraud, and Derek Dreyer. 2018. MoSeL: a general, extensible modal framework for interactive proofs in separation logic. Proc. ACM Program. Lang. 2, ICFP (2018), 77:1–77:30. doi:10.1145/3236772 [29] Andrea Lattuada, Travis Hance, Chanhee Cho, Matthias Brun, Isitha Subasinghe, Yi Zhou, Jon Howell, Bryan Parno, and Chris Hawblitzel. 2023. Verus: Verifying Rust Programs using Linear Ghost Types. Proc. ACM Program. Lang. 7, OOPSLA1, Article 85 (April 2023), 30 pages. doi:10.1145/3586037 [30] Nico Lehmann, Adam T. Geller, Niki Vazou, and Ranjit Jhala. 2023. Flux: Liquid Types for Rust. Proc. ACM Program. Lang. 7, PLDI (2023), 1533–1557. doi:10.1145/3591283 [31] K. Rustan M. Leino and Joachim van de Snepscheut. 1994. Semantics of Exceptions. In Programming Concepts, Methods and Calculi (PROCOMET) (IFIP Transactions A, Vol. 56). 447–466. [32] Linux Kernel Developers. 2026. The Linux Kernel Documentation. https://docs.kernel.org/ Accessed: March 12, 2026. [33] Kenji Maillard. 2019. Principles of program verification for arbitrary monadic effects. Ph.D. Dissertation. Université Paris sciences et lettres. [34] Kenji Maillard, Daniel Ahman, Robert Atkey, Guido Martinez, Cătălin Hritcu, Exequiel Rivas, and Éric Tanter. 2019. Dijkstra monads for all. Proceedings of the ACM on Programming Languages 3, ICFP (2019), 1–29. [35] Gregory Malecha, Gordon Stewart, Frantisek Farka, Jasper Haag, and Yoichi Hirai. 2022. Developing With Formal Methods at BedRock Systems, Inc. IEEE Secur. Priv. 20, 3 (2022), 33–42. doi:10.1109/MSEC.2022.3158196 [36] William Mansky and Ke Du. 2024. An Iris Instance for Verifying CompCert C Programs. Proc. ACM Program. Lang. 8, POPL (2024), 148–174. doi:10.1145/3632848 [37] Yusuke Matsushita, Xavier Denis, Jacques-Henri Jourdan, and Derek Dreyer. 2022. RustHornBelt: a semantic foundation for functional verification of Rust programs with unsafe code. In PLDI '22: 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation, San Diego, CA, USA, June 13 - 17, 2022, Ranjit Jhala and Isil Dillig (Eds.). ACM, 841–856. doi:10.1145/3519939.3523704 [38] Yusuke Matsushita, Takeshi Tsukada, and Naoki Kobayashi. 2021. RustHorn: CHC-based Verification for Rust Programs. ACM Trans. Program. Lang. Syst. 43, 4 (2021), 15:1–15:54. doi:10.1145/3462205 [39] Kayvan Memarian, Victor B. F. Gomes, Brooks Davis, Stephen Kell, Alexander Richardson, Robert N. M. Watson, and Peter Sewell. 2019. Exploring C semantics and pointer provenance. Proc. ACM Program. Lang. 3, POPL (2019), 67:1–67:32. doi:10.1145/3290380 [40] Microsoft Security Response Center. 2019. A proactive approach to more secure code. Microsoft Security Blog. https://www.microsoft.com/en-us/msrc/blog/2019/07/a-proactive-approach-to-more-secure-code [41] Ike Mulder, Robbert Krebbers, and Herman Geuvers. 2022. Diaframe: automated verification of fine-grained concurrent programs in Iris. In PLDI '22: 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation, San Diego, CA, USA, June 13 - 17, 2022, Ranjit Jhala and Isil Dillig (Eds.). ACM, 809–824. doi:10.1145/3519939.3523432 [42] Peter Müller, Malte Schwerhoff, and Alexander J. Summers. 2016. Viper: A Verification Infrastructure for Permission-Based Reasoning. In Verification, Model Checking, and Abstract Interpretation - 17th International Conference, VMCAI 2016, St. Petersburg, FL, USA, January 17-19, 2016. Proceedings (Lecture Notes in Computer Science, Vol. 9583), Barbara Jobstmann and K. Rustan M. Leino (Eds.). Springer, 41–62. doi:10.1007/978-3-662-49122-5_2 [43] Andrei Paskevich, Paul Patault, and Jean-Christophe Filliâtre. 2025. Coma, an Intermediate Verification Language with Explicit Abstraction Barriers. In Programming Languages and Systems - 34th European Symposium on Programming, ESOP 2025, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2025, Hamilton, ON, Canada, May 3-8, 2025, Proceedings, Part II (Lecture Notes in Computer Science, Vol. 15695). Springer, 175–201. doi:10.1007/978-3-031-91121-7_8 [44] Gordon D. Plotkin and Matija Pretnar. 2009. Handlers of Algebraic Effects. In Programming Languages and Systems, 18th European Symposium on Programming (ESOP) (Lecture Notes in Computer Science, Vol. 5502). 80–94. doi:10.1007/978-3-642-00590-9_7 [45] John C. Reynolds. 1972. Definitional Interpreters for Higher-Order Programming Languages. In Proceedings of the ACM Annual Conference. 717–740. doi:10.1145/800194.805852 [46] Michael Sammler, Rodolphe Lepigre, Robbert Krebbers, Kayvan Memarian, Derek Dreyer, and Deepak Garg. 2021. RefinedC: automating the foundational verification of C code with refined ownership types. In PLDI '21: 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, Virtual Event, Canada, June 20-25, 2021, Stephen N. Freund and Eran Yahav (Eds.). ACM, 158–174. doi:10.1145/3453483.3454036 [47] Leon Schuermann, Brad Campbell, Branden Ghena, Philip Alexander Levis, Amit Levy, and Pat Pannuto. 2025. Tock: From Research To Securing 10 Million Computers. In Proceedings of the ACM SIGOPS 31st Symposium on Operating Systems Principles, SOSP 2025, Lotte Hotel World, Seoul, Republic of Korea, October 13-16, 2025, Youjip Won, Youngjin Kwon, Ding Yuan, and Rebecca Isaacs (Eds.). ACM, 36–49. doi:10.1145/3731569.3764828 [48] Lucas Silver and Steve Zdancewic. 2021. Dijkstra Monads Forever: Termination-Sensitive Specifications for Interaction Trees. In Proceedings of the 48th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), Vol. 5. doi:10.1145/3434307 František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel [49] Jeff Vander Stoep. 2022. Memory Safe Languages in Android 13. Google Online Security Blog. https://security.googleblog.com/2022/12/memory-safe-languages-in-android-13.html Accessed: 2026-03-12. [50] Nikhil Swamy, Joel Weinberger, Cole Schlesinger, Juan Chen, and Ben Livshits. 2013. Verifying Higher-Order Programs with the Dijkstra Monad. In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). 387–398. doi:10.1145/2491956.2491978 [51] Hayo Thielecke. 2001. Comparing Control Constructs by Double-Barrelled CPS. In Electronic Notes in Theoretical Computer Science (MFPS 2001), Vol. 45. 433–447. doi:10.1016/S1571-0661(04)80972-7 [52] Alexa VanHattum, Daniel Schwartz-Narbonne, Nathan Chong, and Adrian Sampson. 2022. Verifying dynamic trait objects in rust. In Proceedings of the 44th International Conference on Software Engineering: Software Engineering in Practice (Pittsburgh, Pennsylvania) (ICSE-SEIP '22). Association for Computing Machinery, New York, NY, USA, 321–330. doi:10.1145/3510457.3513031 [53] Neven Villani, Johannes Hostert, Derek Dreyer, and Ralf Jung. 2025. Tree Borrows. Proc. ACM Program. Lang. 9, PLDI (2025), 1019–1042. doi:10.1145/3735592 [54] Max Vistrup, Michael Sammler, and Ralf Jung. 2025. Program Logics à la Carte. Proceedings of the ACM on Programming Languages 9, POPL (2025), 300–331. [55] Andrew Wagner, Olek Gierczak, Brianna Marshall, John M. Li, and Amal Ahmed. 2025. From Linearity to Borrowing. Proc. ACM Program. Lang. 9, OOPSLA2 (2025), 3981–4007. doi:10.1145/3764117 [56] Feng Wang, Fu Song, Min Zhang, Xiaoran Zhu, and Jun Zhang. 2018. KRust: A Formal Executable Semantics of Rust. In 2018 International Symposium on Theoretical Aspects of Software Engineering (TASE). 44–51. doi:10.1109/TASE.2018.00014 [57] Robert N.M. Watson, Jonathan Woodruff, Peter G. Neumann, Simon W. Moore, Jonathan Anderson, David Chisnall, Nirav Dave, Brooks Davis, Khilan Gudka, Ben Laurie, Steven J. Murdoch, Robert Norton, Michael Roe, Stacey Son, and Munraj Vadera. 2015. CHERI: A Hybrid Capability-System Architecture for Scalable Software Compartmentalization. In 2015 IEEE Symposium on Security and Privacy. 20–37. doi:10.1109/SP.2015.9 [58] Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C Pierce, and Steve Zdancewic. 2019. Interaction trees: representing recursive and impure programs in Coq. Proceedings of the ACM on Programming Languages 4, POPL (2019), 1–32. [59] Jason Z. Yu, Fangqi Han, Kaustab Choudhury, Trevor E. Carlson, and Prateek Saxena. 2025. Securing Mixed Rust with Hardware Capabilities. In Proceedings of the 2025 ACM SIGSAC Conference on Computer and Communications Security (Taipei, Taiwan) (CCS '25). Association for Computing Machinery, New York, NY, USA, 1544–1558. doi:10.1145/3719027.3744861 [60] Yannick Zakowski, Calvin Beck, Irene Yoon, Ilia Zaichuk, Vadim Zaliva, and Steve Zdancewic. 2021. Modular, Compositional, and Executable Formal Semantics for LLVM IR. Proceedings of the ACM on Programming Languages 5, ICFP (2021), 67:1–67:30. doi:10.1145/3473572 ## A Syntax The syntax of the Rust language exposed in this paper is shown in Figure 5 $^{15}$. For the full account, we refer the reader to the Rocq formalisation. Types. The base types of $ty$ comprise primitive types, including the boolean type bool, the character type char, and numeric types num sgn w, references ($\&m$ $ty$), and the never type (!), which is used to formally type semantically unreachable computations. We use the usual abbreviations u8, i8, etc. Note that references are indexed by mutability ($m \in \{\text{mutable}, \text{shared}\}$), which makes syntactic representation more convenient to work with. Available type formers include tuples (( $\overline{ty}$)), functions of arbitrary arity (fn( $\overline{ty}$) $\to$ ty), fixed-size arrays ([ty;ce]), and slices ([ty]). Tuples include unit type (), which is a tuple of zero elements. Heterogeneous product types (struct) and enumerated types (enum) are represented as algebraic data types (ADTs) and indexed by their identifier (adt d). Patterns. Patterns are the primary means of inspecting and destructuring values, and appear uniformly across match expressions, let declarations, and function parameters. Patterns include the wildcard pattern (_), variable bindings (ref? mut? v) with a specified binding mode (whether binding is by reference and at which mutability), constant patterns, the never matching pattern (!), and reference pattern (&pat). Note that throughout the paper we use -? to denote optional part of syntax. Destructuring patterns over tuples ((pat)) and ADTs (adt d pat) decompose value into its constituent elements matched over a sequence of sub-patterns. Finally, slice pattern ([pat]) matches an array or a slice element-wise to sub-patterns. Statements. There are two kinds of statements in Rust, expression statements and declaration statements. Corten supports expression statements (expr) that evaluate an expression and ignore its result, and let declaration statements, that introduce a set of new variables via a pattern, optionally initialized with an initializer expression. This captures both uninitialized bindings such as let x; and initialized declarations like let x = 42;, reflecting Rust's block-scoped variables. Further, there are item declaration statement that lexically restrict scope of the item and impacts static semantics of the language. Corten doesn't currently support and we conjecture these does not impact dynamic semantics. Expressions. Expressions (Expr) represent the core construct of the language. The base building blocks of expressions are literal expressions (lit), Corten supports numeric literals and booleans, and path expressions that denote either local variables (v) or items in global scope (gn), e.g. constant items. There are unary operator expressions, including borrow (&e and &mut e), dereference (*e), and arithmetic (-e) and logical (!e) negation operators. There are binary operator expressions (e ⊙ e) where the operators range over binary and logical operators (+, -, *, /, %, |, ^, <<, >>, | |, &&), and comparison operators (=, !=, >>=, <, <=). Further, there are cast (e as ty) and assignment (e = e) expressions. There are array expression constructing arrays by a list of values ([e,]) and by repetition ([e; ce]), and indexing expressions ([e]), there are tuple ((e,)) and tuple indexing (e. n) expression, and there are struct expressions (gn {gn : e}^?) and field access expressions (e. gn). There is a range of control flow expressions; a block expression ( { stmt; e^? }) that sequentializes its statements and its final optional expression, a loop (loop e), break (break), and continue (continue) expressions, there are conditional (if e (else e)^?) and pattern matching (match e {pat => e, }) expressions. Finally, there are function call (gn (e,)) and return (return e^?) expressions. $^{15}$For the sake of readability, we present a simplified-surface level syntax; the formal development is carried out on parsed AST where these syntactic concerns are not relevant. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel ## B Memory The forgetful mapping from values to runtime types is defined as follows: Definition B.1 ([[-]]Type_R).\begin{array}{r l r l r l}{\left[\left[\mathrm{i n t~}sw\right]\right]{\mathrm{T y p e}{\mathrm{R}}}\triangleq\mathrm{i n t}_{\mathrm{R}}}&{\left[\left[\mathrm{b o o l}b\right]\right]{\mathrm{T y p e}{\mathrm{R}}}\triangleq\mathrm{b o o l}{\mathrm{R}}}&{\left[\left[\mathrm{s t r u c t~}df s\right]\right]{\mathrm{T y p e}{\mathrm{R}}}\triangleq\mathrm{s t r u c t}_{\mathrm{R}}d}\ {\left[\mathrm{p t r}\ell\right]{\mathrm{T y p e}{\mathrm{R}}}\triangleq\mathrm{p t r}{\mathrm{R}}}&{\left[\left[\mathrm{t u p l e~}\bar{r}\right]\right]{\mathrm{T y p e}{\mathrm{R}}}\triangleq\mathrm{t u p l e}{\mathrm{R}}\left[\left[\bar{r}\right]\right]{\mathrm{T y p e}{\mathrm{R}}}}&{\left[\left[\mathrm{e n u m~}d~d^{\prime}~f s\right]\right]{\mathrm{T y p e}{\mathrm{R}}}\triangleq\mathrm{e n u m}{\mathrm{R}}d}\end{array}
\mathrm{i t r e e~}E~R\ni t::={\mathrm{C o I n d u c t i v e}}\mathrm{R e t}(r)\mid\mathrm{T t}\mid\mathrm{V i s}{A}(e,k).
Ret(r) represents a terminating computation that evaluates to $r : R$, $\text{Tau}(t)$ represents a computation that takes a silent step and continues with computation $t : \text{itree} E R$, and $\text{Vis}(e, k)$ represents a computation that emits an event $e : E A$, and expects an answer $a : A$ that is then passed to a continuation $k : A \to \text{itree} E R$. For a concrete example, computations that modify heap, a partial map heap : $\text{loc} \to \mathcal{V}$ from locations to values, are represented with $\text{StateE}_{\text{heap}} : \text{Type} \to \text{Type}$. The $\text{StateE}_{\text{heap}}$ consists of two possible events (constructors): getE with answer type heap that returns the current state and setE(s) with answer type unit that overwrites the current state with s. The operation that stores the value v at location l of the heap, can be represented with the following itree\mathrm{V i s}(\mathrm{g e t E},\lambda\sigma:\mathrm{h e a p}.\mathrm{V i s}(\mathrm{s e t E}(\sigma[l\mapsto v]),\lambda u:\mathrm{u n i t}.u)).
Being their definition coinductive, ITrees come with a bisimulation relation $\approx$ that equate two itrees as long as they differ only in (finitely many) Tau steps. Vis(-,-) induces bind that, together with return Ret(-), give rise to a monad under equality up to finitely many Tau steps. Monadic notations allow us to write the example more conveniently as sequential code:\begin{aligned}&store l v:=\ &\quad\sigma\leftarrow trigger getE;\ &\quad u\leftarrow trigger setE(\sigma[l\mapsto v]);\ &\quad Ret(u)\ \end{aligned}
with trigger $E := \text{Vis}(E, \lambda x. \text{Ret}(x))$. ## Computational and logical interpretation of ITrees The events $E$ in itree $E R$ can be given a computational interpretation by handling them in a monad $M$. A computational handler$^{16} H : \forall A. E A \to M A$ can then be recursively extended over $t : \text{itree} E R$, thus interpreting ITrees into monadic computations. The handler for state$E_{\text{heap}}$ that maps getE, setE($\cdot$) to the get and set operation of a state monad can be used to interpret store as a stateful computation. The events $E$ in itree $E R$ can be given also a logical interpretation by specifying pre- and post-conditions for the triggering of the event. For example, the pre-condition for triggering setE($\sigma[l \mapsto$ $^{16}$Usually just called handler, however we want to distinguish them from the logical handlers introduced by Vistrup et al. [54]. $v]$) is to have ownership of the old state $\sigma$, while its post-condition – for every answer $u$ : unit – is to give back the ownership of the new state. Similarly, the pre-condition to getE is ownership of the state but the post-condition requires the state to be given back unchanged. Pre- and post-conditions to the triggering of an event can be given in a weakest pre-condition style by means of a logical handler $H_A(e, \Psi) := \text{Pre} * (\forall a : A. \text{Post}(a) * \Psi(a))$. From a logical handler $H$ it's then possible to define a weakest pre-condition calculus for itrees [54]. For an itree $t$ and a (resource-aware) predicate $\Phi$ the weakest pre-condition $\text{wpi}_H t \{ \Phi \}$ is defined by $^{17}$\mathrm{wpi}{H} t \left{ \Phi \right} := \begin{cases} \Phi(r) & \text{if } t = \mathrm{Ret}(r) \ \mathrm{wpi}{H} t' \left{ \Phi \right} & \text{if } t = \mathrm{Tr}' \ H_A(e, \lambda a. \mathrm{wpi}_{H} k(a) \left{ \Phi \right}) & \text{if } t = \mathrm{Vis}_A(e, k) \end{cases}
If $t = \mathrm{Ret}(r)$ then the returned value $r$ must satisfy $\Phi$, while if $t = \mathrm{Tr}'$ the same weakest pre-condition must be satisfied by $t'$. For $t = \mathrm{Vis}_A(e, k)$ it's necessary to satisfy the pre-conditions for triggering $e$ – specified by the handler $H$ – and to show that the post-condition – specified by $H$ as well – implies $\mathrm{wpi}_H k(a) \{ \Phi \}$ along every possible continuation $k(a)$. Recalling that trigger getE := Vis(getE, $\lambda \sigma$.Ret($\sigma$)), the readers can convince themselves that a proof of wpi$_H$ store $l v \{ \Phi \}$ consists of the following steps: (1) prove ownership of the current state $\sigma$ (pre-condition for getE) and get as post-condition for the continuation $u \leftarrow \text{trigger setE}(\sigma[l \mapsto v])$; Ret(u) the state unchanged and the ownership of the state (2) prove again ownership of $\sigma$ (pre-condition for setE($\cdot$)) get as post-condition for Ret(u) that $\Phi$ must hold in the updated state $\sigma[l \mapsto v]$. From steps (1) and (2) above we immediately derive the following rule\frac{\begin{array}{c}\mathrm{WP-STORE}\ (l \mapsto v) * \Phi\ \mathrm{wpi}_{H} \mathrm{store} l v \left{ \Phi \right} \end{array}}
## Modularly Extending Logics for ITrees The behavior of Rust programs can sometimes be undefined [24]. We therefore extend StateE_{heap} - i.e. getE and setE($\cdot$) – with an event modeling an undefined behavior, ubE and extend store to trigger ubE on invalid locations,\begin{aligned}store_or_ub l v&:=\ match valid(l)with\ | True&\Rightarrow store l v\ | False&\Rightarrow trigger ubE\ end.\end{aligned}
More rigorously, while store $l v$ : itree StateE_{heap} $\mathcal{V}$, its extension with ubE has typestore_or_ub l v:itree\left(StateE_{heap}+^{\prime}ubE\right)\mathcal{V}
where +' is the sum of two event types. Since ubE models an undefined behavior its logical handler $H_{ub}$ imposes to prove false in the post-condition. We can combine $H_{ub}$ with H - logical handler for StateE_{heap} - with the operation $\oplus$ $^{17}$Everything is wrapped in the update modality for updating Iris ghost state when necessary $^{[21]}$. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel and relying on an adequacy lemma [54]. Finally, we can extend the rule WP-STORE to\frac{\begin{array}{l}\mathrm{WP-STORE-UB}\ \lceil\mathrm{valid}(l)\rceil* (l\mapsto v)\ast\Phi\ \mathrm{wpi}{H\oplus H{ub}}\mathrm{store_or_ub}l v{\Phi}\end{array}}
## Program Logics from ITrees semantics So far we recalled how to define a weakest-precondition calculus for terms of type itree $E R$, for certain events $E$ and return values $R$. We also recalled how to modularly extend the calculus when extending $E$ with further events - ubE in our example above. Not surprisingly, the wp-calculus built for itree $E R$ is also a wp-calculus for the expressions of a language denoted with itree $E R$. As an example, we can give let mut x = e a denotation $[\cdot]$ into ITrees with events StateE_{heap} +' ubE and return values $\mathcal{V}$ from Figure 3,\begin{aligned}\left[\left[\mathsf{let}\ \mathsf{mut}\ x=\mathsf{e}\right]:=l_{x}\leftarrow\left[\left[\mathsf{x}\right]\right];\right.\ \left.\quad v_{e}\leftarrow\left[\left[\mathsf{e}\right]\right];\right.\ \left.\quad\mathsf{store_or_ub}l_{x}v_{e}\right.\end{aligned}
By interpreting wp $e \xi$ as $\mathrm{wpi}_{H \oplus H_{ub}}[\mathbf{e}]$ $\{\xi\}$ we can show\begin{aligned}&\frac{\text{LET-LEMMA}}{x\mapsto l*\quad e\mapsto v*\quad(l\mapsto v)\ast\Phi}\&\quad\text{wp let mut}x=e\xi\end{aligned}
by simply unfolding the denotation $[\text{let mut } x = e]$ and applying WP-STORE-UB. ### C.1 ITrees Semantics for THIR and Axioms Validated We are currently establishing the soundness of each of the axioms from section 4 by modularly extending the ITrees semantics to all terms in Expr and Stmt. The type of returned values is $\mathcal{V}$ from Figure 3 and the event type we started with is\mathrm{thirE}:=\mathrm{StateE}_{\mathrm{heap}}+^{\prime}\mathrm{ubE}+^{\prime}\mathrm{stepE}
[![e]!]:\mathrm{i t r e et h i r E}\mathcal{V}
\begin{aligned}\mathrm{wp}{\mathrm{block}}:\mathrm{list};Stmt\rightarrow Expr^{?}\rightarrow\Xi\rightarrow\mathrm{wp}{\mathrm{CF}}\mathcal{V}\ \mathrm{wp}{\mathrm{block}}\left(s::ss\right)e^{?}\xi\triangleq\xi^{\prime}\leftarrow\mathrm{wp}{\mathrm{stmt}}s\left(named\left[\right]::\xi\right);\mathrm{wp}{\mathrm{block}}ss e^{?}\xi^{\prime}\ \mathrm{wp}{\mathrm{block}}\left[\right]e\xi\triangleq\mathrm{wp}{\mathrm{vexpr}}e\xi\ \mathrm{wp}{\mathrm{block}}\left[\right]\varnothing\xi\triangleq\mathrm{ret}{\mathrm{wp}{\mathrm{CF}}}\mathrm{unit}\ \mathrm{wp}{\mathrm{drop}}:\mathcal{L}\rightarrow Type\rightarrow\Xi\rightarrow\mathrm{wp}{\mathrm{CF}}\Xi\ \frac{\mathrm{WP-DROP-INIT}}{\ell\mapsto\nu*\mathrm{wp}{\mathrm{callDrop}}ty\nu\xi Q}{\mathrm{wp}{\mathrm{drop}}\ell ty\xi Q}\end{aligned}
Fig. 12. Updated $wp_{block}$ and $wp_{drop}$ with the stack-structured frame [RR §6.1–6.5] Despite the simplicity of the model, we were able to instantiate the rules from Section 4 and several of the rules from Section 6. ## D Drop Scopes The Rust Reference [RR §6.1–6.5] defines five kinds of drop scopes that determine when owned values are destroyed: the function scope (outermost), block scopes, match arm scopes, statement scopes, and expression (scrutinee) scopes. When a scope exits—by normal completion, return, break, or continue—every value owned by that scope is dropped in reverse declaration order. Scopes are nested; early exits must drain all scopes from the innermost outwards. We give the function frame $\Xi$ (Sec. 4) the structure needed to support this: rather than a single flat map, $\Xi$ is a stack of scopes, each holding the name-to-location bindings introduced at that nesting level. Threading $\Xi$ through the WP calculus this way gives correct lexical shadowing (an inner scope's bindings are found before an outer scope's) and, as the same stack structure is already exactly the information needed to know what to clean up and in what order, supports drop-scope cleanup with no separate mechanism. Definition D.1 (Function frame, $\Xi$).\Xi\ni\xi::=[;]\mid n a m e d\ell^{?}\overline{{(\dot{\imath},\ell)}}::\xi\mid t m p\overline{{\iota}}::\xi
where $i$ ranges over local variable names, $\ell: \mathcal{L}$, and $\ell^{\prime}$ is an optional break/continue label. named entries are pushed by block, arm, and loop scopes and carry the name-location bindings of the locals owned by that scope; tmp entries are pushed by statement scopes and match expressions to track (unnamed) temporaries. A single interleaved list preserves the exact nesting order, enabling an early exit to drain both named and temporary scopes in one downward pass. The distinction is operationally relevant: break/continue target named entries by depth, while tmp entries are always drained as collateral when passing through them. Variable lookup, $\xi[id] = \ell$ (cf. WP-PEXPR-VAR, Fig. 9), searches $\xi$ top-down for the first named entry binding id. Block scopes. The updated $wp_{block}$ (Fig. 12) pushes a fresh named entry before evaluating each statement. Both $Q_{seq}$ and $Q_{rt}$ are implicitly wrapped to drain the scope at exit: on normal completion, the top named entry is popped and the locations of its bindings are dropped in reverse order; on any early exit ( $break_{CF}^{n}$, $continue_{CF}^{n}$, $return_{CF}$), the scope is drained before the exit is rethrown to the enclosing handler. tmp entries are pushed and popped by $wp_{stmt}$ around each statement, dropping temporaries created during evaluation before proceeding. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel 34 The denotation of each `let`-binding emits a StorageLive event, producing a fresh location $\ell$, and the denotation appends the pair $(i, \ell)$ to the top named entry—making cleanup fully explicit in the ITree with no implicit scope state in the handler. Match arm scopes. A match arm scope owns pattern bindings and guard bindings for a single arm. We split the existing $wp_{arm}$ into $wp_{guard}$ and $wp_{arm}$: $wp_{guard}$ pushes a fresh named entry and handles all failure paths—if the pattern does not match or a guard fails, the scope (with any partially introduced bindings) is drained before the next arm is attempted; $wp_{arm}$ receives an already-matched, already-guarded stack and runs the arm body, popping the named entry pushed by $wp_{guard}$ after completion. The match expression itself pushes a `tmp` entry for scrutinee temporaries, which outlive individual arms [RR §6.4]. Loops. $wp_{vexpr}$ for `loop` pushes a named entry and uses the one-unfolding semantics from Sec. 4.4: the sequential continuation of the unfolded body recurses on the loop (next iteration), and $Q_{rt}$ is wrapped to intercept $break_{CF}^n$ targeting this loop (depth $n = 1$)—draining the loop's scope and continuing sequentially—or, for $n > 1$, to decrement the depth and rethrow to the outer handler. Nested loops are thus handled without extending the CF type: the $Q_{rt}$ continuation bakes in the dispatch by depth alone. Drop semantics. $wp_{drop}$ (Fig. 12) dispatches on whether the location is initialized or not, avoiding runtime drop flags. For initialized locations (WP-DROP-INIT), $wp_{callDrop}$ runs the destructor: for types implementing Drop this calls the user-defined method and then recursively drops fields; for other compound types it directly drops fields. For types implementing Drop, this requires an assumed specification of the type's drop method to be available and dischargeable, consuming the value's ownership and releasing the specification's postcondition as a resource; for compound types without a Drop implementation, it instead requires the ownership of the value's fields to be directly available for recursive dropping. Determining which of these two cases applies to a given type—and, in the former case, locating the specification to instantiate—is static, type-directed information already available in THIR; threading it through the WP calculus, analogous to trait-method resolution (Sec. 9), requires a typing environment that we leave out of scope for this paper. For uninitialized locations (WP-DROP-UNINIT), no destructor call is needed; the axiom immediately hands off to $Q$. The $\ell \mapsto v$ vs. $\ell \mapsto \text{uninit}$ distinction is the separation-logic counterpart of MIR's runtime drop flags, handled purely at the proof level. $wp_{pat}$ (Fig. 6) already produces $\ell \mapsto \text{uninit}$ for moves, so the correct branch is always determined by the available separation-logic resources. Function scope. The function scope is handled by extending $wp_{fn}$ with an outermost named entry for function parameters, which are treated uniformly as block-scoped locals. This makes function-scope cleanup uniform with block cleanup and requires no separate mechanism. Drop scope events. Drop scopes introduce three further events to the ITree vocabulary (Sec. 5): * StorageLive : `Defld` $\to$ `size` $\to$ `align` $\to$ $\mathcal{L}$ — allocates a stack slot and returns a fresh location; its logical handler produces $\ell \mapsto \text{uninit}$ in the Iris context. * StorageDead : $\mathcal{L} \to \text{unit}$ — marks a stack slot dead; its logical handler consumes the $\ell \mapsto v$ or $\ell \mapsto \text{uninit}$ predicate. * Drop : $\mathcal{L} \to \text{Type} \to \text{unit}$ — runs the destructor of the value at the given location. For types implementing Drop, this calls the user-defined destructor and then recursively drops fields; for other compound types it directly drops fields. The compiler intrinsic `ptr`::drop_in_place<T> is given a derived specification: it resolves its pointer argument to a location $\ell$ and emits Drop($\ell, T$), semantically identical to the MIR drop terminator. The modular extension approach ensures that the logical handlers for these events are adequate with respect to the existing handlers for heapE and ubE: the separation-logic reasoning principles for StorageLive/StorageDead correspond directly to the fractional ownership model (Sec. 3), and Drop expands into further StorageLive/StorageDead/heapE events whose handlers are already justified. A StorageLive/StorageDead-pair per loop iteration ensures that pointers into a previous iteration's stack slot become invalid, which is the correct provenance behavior for stack allocations. ## E Rust Verification Tool Comparison Table 3 expands Table 2 (Sec. 9) with the theory, prover/solver backend, and language coverage of each tool. Vol. 1, No. 1, Article. Publication date: September 2026. <table><tr><td>Tool</td><td>Level</td><td>Found.</td><td>Theory / backend</td><td>Automation</td><td>Coverage</td></tr><tr><td>Miri [20]</td><td>MIR, dynamic execution</td><td>—</td><td>Operational (Rust Abstract Machine; Stacked/Tree Borrows)</td><td>Automatic (concrete execution)</td><td>unsafe code, most of std; single execution path only</td></tr><tr><td>Kani [10, 52]</td><td>MIR → Goto-C</td><td>No</td><td>Bounded model checking (CBMC); SAT (MiniSat) or SMT (Z3, cvc5, bitwuzla)</td><td>Automatic</td><td>unsafe code, panics, overflow; no concurrency</td></tr><tr><td>Verus [29]</td><td>Rust (ghost code) → SMT-LIB</td><td>No†</td><td>Linear ghost types / modes, FOL; Z3 (via SMT-LIB)</td><td>Automatic (SMT)</td><td>unsafe code (via ghost permissions), concurrency</td></tr><tr><td>Prusti [5]</td><td>MIR → Viper [42]</td><td>No</td><td>Implicit dynamic frames; Silicon (symb. exec., Z3) or Carbon (VCGen, Boogie)</td><td>Mostly automatic (SMT); loop invariants sometimes manual</td><td>primarily safe Rust; no concurrency</td></tr><tr><td>RustHorn(Belt) [37]</td><td>Rust subset → Horn clauses</td><td>No†</td><td>CHC solving; prophecies (RustHornBelt: parametric prophecies via Iris)</td><td>Automatic (CHC solver); RustHornBelt needs a front-end verifier (e.g. Creusot)</td><td>safe APIs over unsafe internals (Vec, iterators); concurrency (Mutex, spawn/join)</td></tr><tr><td>Creusot [11, 43]</td><td>MIR → Coma (Why3)</td><td>No</td><td>Deductive VCGen, prophecies for mutable borrows; Why3 → Alt-Ergo/CVC/Z3</td><td>Mostly automatic (SMT); invariants sometimes manual</td><td>generics, trait bounds; primarily safe Rust</td></tr><tr><td>Flux [30]</td><td>MIR, rustc plugin</td><td>No</td><td>Refinement (liquid) types; liquid-fixpoint (Z3 internally)</td><td>Highly automatic (liquid inference)</td><td>safe Rust, ownership-aware strong updates</td></tr><tr><td>RefinedRust [14]</td><td>MIR</td><td>Yes</td><td>Refinement types with an Iris semantic model in Rocq; Lithium proof search</td><td>High (Lithium automation); manual Iris proof for complex cases</td><td>safe and unsafe Rust, generics; single-threaded</td></tr><tr><td>Aeneas [16]</td><td>Rust subset → pure functional</td><td>Semi*</td><td>Functional translation of ownership/borrowing; F*, Lean, or Rocq</td><td>Automatic translation; manual/interactive proof</td><td>excludes unsafe code, concurrency; loop/trait coverage has expanded since ICFP'22‡</td></tr><tr><td>Corten</td><td>THIR</td><td>Yes</td><td>Hoare-type theory + WP specification monad, atop Iris; Rocq</td><td>Syntax-driven (proof-search tactics)</td><td>safe and unsafe (uniform), control flow, drop; traits partial, concurrency inherited from Iris but not yet exercised</td></tr></table> Table 3. Full comparison of Rust verification tools against Corten. † Verus's core linearity/mode metatheory is proved for a small calculus in the paper, but each verification instance is still discharged by trusting Z3/cvc5's result, so per-program verification is not foundational in Corten's sense. RustHornBelt mechanizes, in Rocq and Iris, the soundness of the Horn-clause encoding with respect to λRust semantics—a genuine foundational metatheorem—but each concrete verification run still trusts an external solver's answer (a CHC solver directly, or an SMT solver via a front-end verifier such as Creusot) rather than producing a kernel-checked certificate. ‡ As of the cited ICFP'22 publication, Aeneas's symbolic semantics did not support loops or most trait usage; loop support has since been substantially extended in Aeneas's public development (only a narrow nested-loop corner case remains unsupported), while unsafe code and concurrency remain excluded. * Aeneas's F*/Lean/Rocq proofs about the functional translation are kernel-checked, but a soundness argument connecting the translation to Rust's actual semantics is, per the authors, still future work—not yet established in any form, mechanized or otherwise. 36 Frantisek Farka, Carnine Abate, Sven Linker, and Sebastian Ertel ## F Program Logic and Automation Details This appendix gives the full versions of the program logic and automation material summarized in Secs. 6 and 7. ## F.1 Sealing: Full Set of Block Lemmata In the case of $wp_{block}^{seal}$, we provide three lemmata for controlled unfolding (Fig. 13): WP-BLOCK-CONS for blocks with a leading statement, and WP-BLOCK-NIL-E and WP-BLOCK-NIL-NE for empty blocks, depending on whether a trailing expression is present. The first rule transforms a block with a leading statement into the weakest precondition of that statement, sequentially followed by the (sealed) WP of the remaining block, enabling evaluation of the leading statement first while keeping the remaining block opaque until needed. WP-BLOCK-NIL-E and WP-BLOCK-NIL-NE handle the base case, dispatching on whether a trailing expression is present. This technique yields a cleaner and more readable proof state and significantly reduces proof term size and checking time.\frac{\text{WP-BLOCK-NIL-E}}{\text{WP}{\text{vexpr}} e \xi}{\text{WP}{\text{stmt}} { e } \xi} \qquad \frac{\text{WP-BLOCK-NIL-NE}}{\text{ret}{\text{wPCF}} \left( \right)} \qquad \frac{\text{WP-PAT-CONST}}{c \leftarrow \text{wp}{\text{cexpr}} ce ; \text{delayed}_{\text{cpat}} c e \xi}
Fig. 13. Remaining program logic lemmata, complementing Fig. 11 ## F.2 Reordering Evaluation: Full Derivation In the semantics, WP accumulation proceeds by structural traversal of the AST, which does not always align with the order in which a programmer would naturally reason about evaluation. Consider matching a value against a literal pattern. In the core semantics, pattern matching first accumulates the WP of the scrutinee expression via $wp_{\text{vexpr}}$, and only afterward accumulates the weakest precondition of the pattern via $wp_{\text{pat}}$. However, the literal appearing in a pattern is itself a weakest precondition of a constant expression, $wp_{\text{cexpr}}$, and contrary to the programmer's intuition this constant has not yet been evaluated when the scrutinee is processed. In idiomatic reasoning, one would expect the constant to be evaluated first, and only then proceed to evaluate the scrutinee and perform the match. To support this reasoning pattern, we introduce a derived rule for literal patterns that reverses the apparent order of evaluation. Technically, we introduce a sealed definition $\text{delayed}_{\text{cpat}}$ that encapsulates the continuation corresponding to the subsequent evaluation of the scrutinee and a derived inference rule for literal patterns (WP-PAT-CONST, Fig. 13): Definition F.1 (Reordering constant patterns).\text{delayed}{\text{cpat}} \triangleq \text{if } cv = \nu \text{ then } \text{ret}{\text{wPCF}} \xi \text{ else } \text{nomatch}_{\text{CF}}
This rule accumulates the WP of the constant expression $ce$ of the pattern first, binding its value $c$ into a continuation, and subsequently accumulating the WP of the scrutinee expression $e$. The pattern is checked once both values are available. Crucially, this reordering is sound because the evaluation of the constant expression is independent of the scrutinee—there are no side effects or dependencies that would constrain the order. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel ## F.3 Join-Point Reasoning: The General Case Join-point reasoning is not limited to if expressions. In the general case, where evaluation dispatches over an arbitrary scrutinee, the same style of reasoning applies to match expressions: each arm is discharged independently against a shared intermediate postcondition $R$, and the continuation following the match is proved once against $R$ composed with the frame not consumed by whichever arm was taken, exactly as for WP-IF-JOIN (Fig. 11) but with $n$-ary case analysis in place of the binary if/else split. Reasoning about loop expressions also requires join-point reasoning, though the join point here connects loop iterations rather than branches: because loops are modeled by one-unfolding (Sec. 4), a user-supplied loop invariant serves simultaneously as the postcondition establishing the unfolded body's obligations and as the precondition available at the start of the next iteration—the same common-precondition/shared-postcondition pattern as WP-IF-JOIN, instantiated with the invariant playing the role of $R$ and the loop's continuation (after a break$_{CF}$) playing the role of the final postcondition $Q$. ## F.4 Proofmode Tactics on Continuation Stacks The proofmode tactics (Sec. 7) operate directly on the defunctionalized continuation stacks (Sec. 6). A bind$_{WP_{CF}}$ application pushes a new SKbind frame, and a ret$_{WP_{CF}}$ application pops the top frame (or resolves directly at the base case), both via seqK-unfold, instead of building $\lambda a$. $f a Q_{seq} Q_{rt}$ closures. tac THROW dispatches on the head $HK_X$ constructor of hcont via rtK-unfold, firing or popping the top handler on the matching control-flow tag. Scope installers tac_guard$_{X-CF}$ push one $HK_X$ handler and one SKbind frame. The dispatch table of the main automation loop is structurally unchanged; only the continuation arguments in tactic right-hand sides become seqK(rtKH) $S / rtKH$. ## G Soundness Status and Validation This appendix itemizes the soundness status of the axiomatic semantics (Sec. 4) against the ITrees denotation (Sec. 5, Appendix C), and describes how the axioms are validated against the intended semantics of Rust independently of that proof. ### G.1 Per-Axiom Adequacy Status Table 4 lists every named rule in Figs. 6–10 and its adequacy status against the ITrees denotation. As established in Sec. 5, completed proofs are final: the compositional construction means that extending coverage never requires revisiting an already-adequate rule, only proving adequacy for the newly introduced event types. Completed entries have a closed Rocq proof relating the axiom to its ITrees denotation, following the pattern illustrated for BINOP-ADD and LET-ADDV-LEMMA in Sec. 5; Pending entries are stated as axioms only. ### G.2 Test-Suite Construct Coverage Table 1 (Sec. 7) reports the ten collections of the synthetic test suite by source and proof size; each collection's name indicates the constructs it targets—e.g. arith and unary exercise WP-VEXPR-BINOP/WP-VEXPR-UNOP-NEG, cf exercises WP-VEXPR-LOOP/WP-VEXPR-BREAK/WP-VEXPR-CONTINUE, ifs exercises WP-VEXPR-IFjoin-point reasoning, matching exercises wp$_{pat}$ and WP-VEXPR-MATCH-V/WP-VEXPR-MATCH-P, tuple exercises WP-VEXPR-TUPLE/WP-VEXPR-ADT and the corresponding place-expression rules, and impls exercises WP-VEXPR-CALL-GLOBNAME. The full test suite contains further collections beyond these ten, exercising language features (e.g. generics, trait dispatch) that the main body omits for space reasons (Sec. 9); those collections are not reflected in Table 1 or in <table><tr><td>Rule</td><td>Status</td></tr><tr><td>WP-VEXPR-LITERAL-BOOL, WP-VEXPR-LITERAL-INT</td><td>Completed</td></tr><tr><td>WP-VEXPR-UNOP-NEG, WP-VEXPR-BINOP</td><td>Completed</td></tr><tr><td>WP-STMT-EXPR</td><td>Completed</td></tr><tr><td>WP-STMT-LET</td><td>Completed</td></tr><tr><td>WP-VEXPR-VAR, WP-PEXPR-VAR</td><td>Pending</td></tr><tr><td>WP-VEXPR-BORROW-PLACE, WP-VEXPR-BORROW-VALUE, WP-VEXPR-BORROW-PLACE</td><td>Pending</td></tr><tr><td>WP-VEXPR-TUPLE, WP-VEXPR-ADT, WP-PEXPR-TUPLE-INDEX, WP-PEXPR-ADT-FIELD</td><td>Pending</td></tr><tr><td>WP-VEXPR-IF, WP-VEXPR-BLOCK</td><td>Pending</td></tr><tr><td>WP-VEXPR-MATCH-V, WP-VEXPR-MATCH-P</td><td>Pending</td></tr><tr><td>WP-VEXPR-LOOP, WP-VEXPR-BREAK, WP-VEXPR-CONTINUE</td><td>Pending</td></tr><tr><td>WP-VEXPR-CALL-GLOBNAME, WP-VEXPR-RETURN</td><td>Pending</td></tr><tr><td>wp_pat (Fig. 6, all clauses)</td><td>Pending</td></tr></table> Table 4. Adequacy status of the axiomatic semantics against the ITrees denotation. Completed proofs cover the pure fragment (literals, unary and binary operators) and heap-manipulating statements (Sec. 5). this appendix's per-construct breakdown. This test suite validates the axioms against the intended semantics of Rust independently of the adequacy proofs in Table 4: adequacy establishes that an axiom is consistent with some operational model, while the test suite checks that the axiom captures Rust's actual behavior as documented in the Reference and the standard library. ## G.3 The Test-Suite Oracle Each test in the suite is a Rust source file annotated with a hand-authored functional specification that states the outcome a programmer familiar with the Rust Reference and standard library documentation would expect (e.g. the postcondition of example in Fig. 2a, or the well-formedness invariant of the buddy allocator in Sec. 8). The oracle is this hand-authored specification, not an independent execution of the program: a test passes when the axiomatic semantics lets us discharge the specification via Corten's automation or manual proof. A discharged proof is therefore evidence that the axioms agree with the documented, human-understood semantics of the construct under test, complementing—but not replacing—the ITrees adequacy proofs of Table 4, which check agreement with a specific operational model rather than with the Reference's prose. ## G.4 Extraction Roadmap The ITrees library supports extracting an itree $E$ $R$ denotation to executable OCaml when the event handlers for $E$ are given a concrete interpretation [58]; Vellvm's LLVM IR semantics is extracted this way to obtain an executable interpreter validated against the reference LLVM toolchain [60]. We intend to follow the same route for Corten's ITrees denotation: extracting an interpreter for the covered THIR fragment would let us differentially test axiom coverage against rustc's and Miri's own execution. Concretely, we plan to annotate each test in the suite with its expected input/output pairs and run these as ordinary Rust #[test] functions over the crafted inputs already used to state the specifications described above, alongside the manual oracle. This would upgrade the test suite's validation from a hand-authored oracle to an automated, executable one, without requiring changes to the axioms or their adequacy proofs. František Farka, Carmine Abate, Sven Linker, and Sebastian Ertel ## H Borrows, Lifetimes, and the Trusted Computing Base This appendix works a mutable-reborrow example through the pattern rules of Sec. 4.2 (Sec. 3 states the general principle), itemizes Corten's trusted computing base (TCB), and sketches how the buddy allocator case study (Sec. 8) threads &mut self ownership across its call graph. ### H.1 Worked Example: A Mutable Reborrow Consider binding a mutable reference to an existing local, e.g. matching the pattern ref mut r against a place holding value v at some location. The relevant clause of wp_{pat} (Fig. 6) is\mathsf{w p}{\mathsf{p a t}}\left(\mathsf{r e f}\mathsf{m u t}i\right)v\xi\triangleq\exists\ell.\ell\mapsto v*\left(\ell\mapsto v-*\forall\ell{\mathsf{t m p}}.\ell_{\mathsf{t m p}}\mapsto\mathsf{p t r}\ell--*\mathsf{r e t}{\mathsf{w p}{\mathsf{C F}}}(\xi\cup i@\ell_{\mathsf{t m p}})\right).
Reading this as a borrow: the rule demands full ownership $\ell \mapsto v$ of the location being borrowed—not a fraction—reflecting that a mutable borrow is exclusive. It immediately returns that same fact behind a magic wand, so the continuation obtains it back unchanged; what is consumed and not returned is only the ability of the current proof step to use $\ell \mapsto v$ directly; the new binding $i$ instead points to a fresh location $\ell_{\text{tmp}}$ holding a pointer value to $\ell$. Any subsequent access to $\ell$ in the continuation must go through dereferencing $\ell_{\text{tmp}}$, which resolves to the same $\ell \mapsto v$ fact—there is exactly one owner of it in the proof context at a time. The borrow’s end is not a separate event: it coincides with whichever later WP rule is the next to consume $\ell \mapsto v$ again (e.g. a subsequent move out of $\ell$, or the drop of the original binding), at which point the reborrow through $\ell_{\text{tmp}}$ is no longer available to the continuation, matching Sec. 3’s account of borrow-end-via-ownership-transfer. ### H.2 Trusted Computing Base • Trusted: the Rocq kernel type-checker; rustc's parser, name resolution, and type checker, which determine the THIR AST that hax/hax2rocq (Sec. 2) transpile into Rocq; the hax/hax2rocq transpiler itself, which we do not independently verify against rustc's THIR; the pinned Rocq, Iris, and std++ versions fixed by the project's Nix flake, consistent with any foundational Rocq/Iris development. • Untrusted (oracle only): the borrow checker (Sec. 3). Its acceptance of a program is never consumed as a fact by the dynamic semantics or by any proof; it only predicts, ahead of time, that the fractional/affine obligations a borrow-checked program generates will in practice be dischargeable. A borrow-checker bug can at worst make an actually-safe program harder to verify (its obligations may fail to discharge); it cannot make an unsound proof go through, since no rule takes borrow-checker output as a premise. ### H.3 Ownership Threading in the Allocator The buddy allocator’s methods take &mut self, so each call in the allocator’s call graph (Sec. 8) both requires and returns exclusive ownership of the receiver’s representation: a caller’s precondition self→v is consumed by the callee’s wp_{fin}, and the callee’s postcondition returns a (possibly updated) self→v′ to the caller, exactly mirroring the exclusivity &mut enforces syntactically. This threading composes uniformly through the call graph: an intermediate helper that itself calls further &mut self methods on (a projection of) the same receiver passes the points-to fact along its own precondition/postcondition pair, so ownership never needs to be duplicated or reconstructed—each call in the chain hands off the single outstanding self→v fact to the next. The current boundary of what is handled this way is stored references and reborrows through struct fields: a method that takes &mut self and internally reborrows one of self's fields (e.g. operating on self.blocks or self.heads individually before returning) is verified by splitting buddyRep into its field-level representation predicates (blocksRep, headsRep, Sec. 8) and recombining them at the end of the method, following the same ownership-transfer pattern as the worked example above. References stored inside longer-lived data structures and returned across multiple call frames beyond this pattern are not exercised by the case study and are left to future work.