arXiv:2611.08685cs.PLNov 2026

Manuscript Offprint

arXiv:2611.08685

Fibered Separation Logic: Weakest Preconditions, Universal Constructions, and Local Independence

John M. Li, Ryan Doenges, Pedro H. Azevedo de Amorim

JOHN M. LI, Northeastern University, US

RYAN DOENGES, Boston College, US

PEDRO H. AZEVEDO DE AMORIM, University of Bath, UK

This paper introduces a categorical framework for models of higher-order separation logic including the weakest precondition modality. Weakest preconditions are interpreted by strong monads on a category fibered over a model of Moggi's computational lambda calculus. The fibered categories in question are termed bunched fibrations and shown to be equivalent to BI hyperdoctrines.

Well-known heuristic techniques for obtaining weakest preconditions are shown to be expressible in categorical terms and are proved sound. The “baking in the frame rule” trick is shown to satisfy a universal property. Constructions are given for extending a program logic with cost credits. Our largest case study is parametrized by a category having local independent product (LIP) structure, a notion due to Simpson that axiomatizes name generation, randomness, and local state. From an LIP category, we construct an allocation monad, a bunched fibration, and a monad lifting. We instantiate our construction to obtain a novel probabilistic separation logic for measure-theoretic probability that both simplifies and clarifies prior work.

1 Introduction

This paper introduces a systematic approach to the semantics of separation logic in terms of strong monads on models of bunched implications (BI). While BI, the logic of resources at rest, has been treated systematically by O'Hearn and Pym [49], Biering [11] and many others, we find the dynamic aspects of separation logic have not yet received a comparable treatment. This is not for lack of material, as the literature on separation logic is extensive, well understood by experts and workers in verification, and organized, to some extent, into heuristics and rules.

Separation logic extends ordinary Hoare logic with substructural logical connectives that permit compositional reasoning about resource-manipulating programs. The separating conjunction P∗QP * Q holds on resources that can be separated into one part that satisfies PP and another part that satisfies QQ. The frame rule says that a verified program cc respects this notion of resource separation, in the sense that whatever cc does to PP is stable in the presence of additional resources described by a separate FF.

{P}c{Q}  ⟹  {P∗F}c{Q∗F}\{P\} c \{Q\} \implies \{P * F\} c \{Q * F\}

In the original incarnation of separation logic [54], the resources in question were fragments of the heap. Subsequent developments vastly generalized the notion of resource, leading to logics for higher-order mutable state [34, 62], concurrency [16], probability [8, 9, 41], entropy [26], error [2], space [19, 44], and time [5, 26]. As a result, the semantics of separation logic have become fragmented, which presents problems both for scientific communication and the design of new logics.

The nascent theory of separation logic has improved the situation by identifying and classifying models of BI, the assertion language of separation logic [49, 52, 53]. Resources have been organized into resource algebras such as partial commutative monoids [17]. Cao, Cuellar, and Appel [18] showed the soundness of common rules like dereliction depends entirely on the algebraic properties of the underlying resource algebra. Well-behaved classes of duplicable propositions P⊢P∗PP \vdash P * P have been identified with persistence modalities □\Box, which in turn are related to the lattice of

Authors' Contact Information: John M. Li, li.john@northeastern.edu, Northeastern University, Boston, US; Ryan Doenges, doengesr@bc.edu, Boston College, Chestnut Hill, US; Pedro H. Azevedo de Amorim, phaa20@bath.ac.uk, University of Bath, Bath, UK.

John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim

Qv⊢wp(retv)QWP−RETURNwpc(λx.wp(fx)Q)⊢wp(x←c;fx)QWP−BINDF∗wpcQ⊢wpc(F∗Q)WP−FRAMEP⊢Q  ⟹  wpcP⊢wpcQWP−MONO\begin{array}{r l r l}{Q v\vdash\mathrm{w p}\left(\mathrm{r e t}v\right)Q}&{}&{\mathrm{W P-R E T U R N}}\\ {\mathrm{w p}c\left(\lambda x.\mathrm{w p}\left(f x\right)Q\right)\vdash\mathrm{w p}\left(x\leftarrow c;f x\right)Q}&{}&{\mathrm{W P-B I N D}}\\ {F*\mathrm{w p}c Q\vdash\mathrm{w p}c\left(F*Q\right)}&{}&{\mathrm{W P-F R A M E}}\\ {P\vdash Q\implies\mathrm{w p}c P\vdash\mathrm{w p}c Q}&{}&{\mathrm{W P-M O N O}}\end{array}

Fig. 1. Selected proof rules for weakest preconditions.

idempotent elements of the underlying resource algebra [15, 24]. For higher-order BI, it has been shown that introducing rules for subset types {x:X∣P(x)}\{x: X \mid P(x)\} leads to the disappointing principle P∗Q⊣P∧QP * Q \dashv P \land Q [12, §2.2], establishing that desirable categorical models of higher-order BI are are not toposes but rather BI hyperdoctrines.

Despite these insights into the logic of resources at rest, separation logics are still designed and verified by alternately following heuristics and proving soundness by exhaustive case analysis. This happens because the dynamic aspects of separation logic have so far eluded systematic analysis. In a modern logic, dynamic assertions, i.e., assertions about program behavior, are defined in terms of a weakest precondition modality: {P}c{Q}  ⟺  P⊢wpcQ\{P\} c \{Q\} \iff P \vdash \text{wp} c Q.

The weakest precondition is meant to describe the resources and knowledge necessary for cc to produce a result satisfying postcondition QQ. It is often defined by a logical formula involving the semantics of computations, the effects of cc on resources, and the invariants the logic is meant to enforce. Presentations of these formulas in the literature either simply record the definition of weakest precondition without comment or show how to build it up by proof and counterexample [40] until all desired rules are true, as in Jung et al. [33, §§6.3, 7.3]. This reflects the design process, in which a designer writes down a list of desired rules and then gradually adjusts the defining formula for wp as they rotate between proposing candidate definitions, proving soundness of rules, and consulting the literature for ideas. In the end, one obtains a wp that validates at the very least those rules shown in Figure 1, which permit decomposing monadic computations (WP-RETURN and WP-BIND), framing out unused resources (WP-FRAME), and incorporating static reasoning from the assertion language (WP-MONO).

This paper presents a systematic, categorical foundation for weakest preconditions satisfying the rules in Figure 1. First, we replace the BI hyperdoctrines of Biering [11] with an equivalent category of bunched fibrations. Then, following the analysis of weakest preconditions for Hoare logic by Aguirre et al. [3], we interpret wp as a monad on a bunched fibration. We show that any such monad validates the laws WP-MONO, WP-BIND, and WP-RET, and that WP-FRAME amounts to the existence of a tensorial strength for the monad (Section 5).

Our bunched fibrations provide a fibered account of first- and higher-order BI (Section 4.1). We prove that bunched fibrations correspond to existing models of BI, based on BI hyperdoctrines (Theorem 4.15), and give conditions under which bunched fibrations are stable under pullback (Propositions 4.21 and 4.22).

We provide two demonstrations of the utility of our fibered framework for defining separation logics. First, Section 6 shows how it provides the language to precisely express the kinds of design patterns used to build complex separation logics. It considers three examples: a common pattern of “baking in” the frame rule, a pattern of adding credit-based cost reasoning to a program logic by upgrading the underlying resource algebra, and a pattern of defining a persistence modality in terms of universal quantification over all possible resources à la modal necessity. In two of these three cases we are able to find an accompanying universal property for the construction, giving it a canonical status with respect to other constructions for the same purpose.

Our second demonstration showcases how our fibered framework can be used to build a new kind of separation logic. First, we leverage Simpson's newly-introduced axiomatization of local independence structure [57] to define a new monad that captures an abstract notion of allocation effect arising in the context of name generation, local store, probability, and nondeterminism. Then, we build a bunched fibration and a bunched lifting that generically construct a higher-order separation logic for this abstract notion of allocation. Finally, by using this abstract construction in combination with our pullback-stability theorems, we obtain a novel probabilistic separation logic for measure-theoretic probability that simplifies and clarifies the probabilistic separation logics put forward by prior work [8, 30, 41].

A Recipe for Making Separation Logics. Our hope with this fibered framework is to lay the foundations of the following three-step recipe for making new separation logics in a systematic manner.

First, one fixes a monad TT on a category CC that interprets the effectful operations of interest. This could be plucked from the functional programming literature, like the state monad or the reader monad, or constructed from an algebraic signature. It can be a sophisticated model, like the model of full ground store [36], or an elementary one, like an ordinary state monad on Set.

Next, one builds a bunched fibration E→C\mathcal{E} \to C, giving a separation logic for reasoning about the pure computations embodied by the objects and morphisms of CC. This bunched fibration can be built in a number of ways. It could be one of the canonical kinds of bunched fibration, such as the versatile lax slice fibration described in Definition 4.24; it could come from a BI hyperdoctrine, via the correspondence to bunched fibrations; or it could come from the use of a change-of-base theorem. The resulting separation logic can be first- or higher-order depending on the structure of the fibration and of the category CC.

Finally, one lifts the monad TT and its effectful operations to a monad and operations on the total category E\mathcal{E} of the bunched fibration. This too can be done in a number of ways, either by using a stock lifting — e.g., the frame-preserving state example — by the application of general constructions such as free frame, credits, or the independence lifting, or by change of base along a suitable functor.