Manuscript Offprint
arXiv:2611.08685Fibered Separation Logic: Weakest Preconditions, Universal Constructions, and Local Independence
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 holds on resources that can be separated into one part that satisfies and another part that satisfies . The frame rule says that a verified program respects this notion of resource separation, in the sense that whatever does to is stable in the presence of additional resources described by a separate .
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 have been identified with persistence modalities , 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
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 leads to the disappointing principle [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: .
The weakest precondition is meant to describe the resources and knowledge necessary for to produce a result satisfying postcondition . It is often defined by a logical formula involving the semantics of computations, the effects of 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 on a category 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 , giving a separation logic for reasoning about the pure computations embodied by the objects and morphisms of . 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 .
Finally, one lifts the monad and its effectful operations to a monad and operations on the total category 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.
Iris. The higher-order separation logic Iris has developed a generic wp that can be applied to a wide range of operational semantics; this combined with the ability to specify custom resource algebras makes Iris a powerful framework for building new program logics. In our view what distinguishes the present work from Iris is that Iris is focused on specific kinds of languages and logics; in particular, it is most suitable for step-indexed operational reasoning that makes use of features such as higher-order impredicative invariants and Löb induction. By contrast, our fibered framework aims to describe the general principles shared by all separation logics, including those that may be first-order, denotational in nature, and not defined directly in terms of a resource
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
Fig. 2. Syntax and selected formation rules for first-order separation logic. Programs c are typed by a judgment as in Moggi's monadic metalanguage and use the type constructor T for the monad.
algebra—indeed, the probabilistic logic presented in Section 7 provides an example. We similarly aim to describe constructions for building new separation logics and wps at this level of generality.
Models of effective program logics. The connection between Hoare logic and monads goes all the way back to Moggi, who noted a correspondence between algebras and “Hoare’s triples” [48]. Proximal to the present work are Dijkstra monads [4, 63], which Maillard has formulated as liftings of relative monads [45], and the fibered monad liftings of Aguirre et al. [3]. We take up the latter approach, extending it to separation logic, and further develop this research program by formalizing useful design patterns and intuitions from program logics as constructions on fibrations equipped with monad liftings.
The BI hyperdoctrines of Biering et al. [11, 12] isolate the essential features of higher-order BI in a category of models. They are the theoretical foundation of the Iris program logic and find both operational and denotational applications in program logic [1, 12, 50]. Our 2-category of bunched fibrations is equivalent to the 2-category of BI hyperdoctrines BIHy by design. The switch to fibrations significantly simplifies the presentation of monad liftings, which are achievable in BIHy in principle but difficult to manipulate in practice.
Probabilistic separation logic. Separation logic has been adapted to support probabilistic reasoning, where separating conjunction enforces probabilistic independence. Since PSL [9], there have been varied approaches to these probabilistic separation logics. For instance, the interpretation of separation is sometimes syntactic, based on separation of variable names [9, 65], and sometimes semantic, based on independence of -algebras [8, 30, 41]. The semantic interpretation of separation has recently been reformulated categorically in terms of monoidal categories of sample spaces [42, 57]. The model we present in Section 7 recovers these models while extending them with a new interpretation of wp. This new wp improves on prior work: whereas definitions of existing wps for PSLs introduce constraints that force the wp to validate the frame rule and respect substitution, these properties hold for our wp by construction.
3 Background
This section serves as a self-contained presentation of the standard heap semantics of separation logic and its categorical formulation. First we look at the assertion language of separation logic (Fig. 2).
Heaps are finite integer-valued partial maps . Two heaps are disjoint if they have disjoint domains. The disjoint union operation is the union of the two maps if they are disjoint and undefined otherwise.
Assertions with no free variables are interpreted in , the set of heap propositions, which is partially ordered by entailment:
This partially ordered set supports a collection of algebraic operations that soundly interpret the propositional connectives in Fig. 2.
Assertions with free variables drawn from , are interpreted as functions . In ordinary separation logic, the syntax also includes all the points-to predicates , which are interpreted by
In order to turn this assertion logic into a program logic, we will define a weakest precondition for computations in the state monad
Then we can define a weakest precondition wp for every computation and predicate as follows.
for all disjoint from
Note the use of a framing heap in the definition. Without this additional heap, the frame rule would not hold.
Modeling Separation Logic Categorically. The logical operations on hProp make it a BI algebra, which is both a Heyting algebra and a symmetric monoidal closed poset. This makes it a model of the intuitionistic connectives and the substructural connectives , respectively. Additionally, hProp is a complete BI algebra: it has all set-indexed meets and joins. The set inherits the complete BI algebra structure from hProp by applying operations pointwise. Furthermore, for each function , one has a “substitution” map defined by precomposition. This forms a homomorphism of BI algebras since the structure on is defined pointwise. All together this means defines a contravariant functor , where is the category of BI algebras and their homomorphisms.
Categorical models of BI codify this situation with the notion of BI hyperdoctrine, which encompasses all functors of the form that additionally support quantifiers and equality. As is typical in categorical logic, these are given by adjoints: quantifiers are left and right adjoint to substitution along the weakening map , and equality is left adjoint to substitution along the duplication map . A more detailed treatment of BI hyperdoctrines may be found in Biering et al. [12, Section 2.2].
A class of examples of BI hyperdoctrines that will be important to us later on comes from the notion of an ordered pcm—a resource algebra of the kind described in Section 2.
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
Definition 3.1 (ordered pcm). An ordered pcm is a partial commutative monoid (pcm) additionally equipped with a partial order such that the following monotonicity condition holds: if is defined and and , then is defined as well and .
PROPOSITION 3.2. Given an ordered pcm , the collection of upwards-closed subsets of forms a complete BI algebra.
The Heyting algebra structure is given by the usual Kripke semantics for intuitionistic propositional logic, and the monoidal closed structure is given by
PROPOSITION 3.3. Every ordered pcm gives rise to a BI hyperdoctrine hPred : Set BIAlg, defined by hPred(X) = X .
This recovers the standard linear heap model: the set of heaps forms an ordered pcm under the discrete ordering, the unit is the empty heap, and the partial multiplication is given by disjoint union of heaps. Ordering heaps by inclusion works too and yields an affine separation logic. A generalization appears in Section 7, where it is necessary to define a pcm object in an arbitrary topos in place of Set. This too gives rise to a higher-order BI hyperdoctrine, by taking the object hProp to be the collection of internally upwards-closed subsets of .
4 Fibered Semantics of BI
In this section we pass from indexed models to fibrations, replacing hyperdoctrines with a category containing the entire model equipped with a projection functor . We define a category of bunched fibrations and prove it is equivalent to the category of BI hyperdoctrines .
We choose fibrations over hyperdoctrines for reasons of expediency. BI hyperdoctrines are a convenient format for models, but they achieve this by organizing predicates and entailments into individual algebras that are functorial in . This makes it easy to extend an operations on algebras to an operation on the entire hyperdoctrine. For operations that work across indices, such as quantification, this becomes awkward; for constructions that involve additional data it becomes unmanageable.
Fibrations collate the algebras of a hyperdoctrine into a single category that puts substitutions on equal footing with entailments . There is a standard construction for passing from any functor valued in posets to a fibration.
Definition 4.1. For a functor we define the total category .
• The objects are pairs with and .
• The morphisms are morphisms such that .
Example 4.2. Recall the BI hyperdoctrine hPred of heap predicates discussed in Section 3. Its total category has objects where is a set and is a heap predicate. Morphisms are functions such that .
PROPOSITION 4.3. The projection out of the total category is a faithful functor.
Constructions on this category are in general one level of abstraction down from the corresponding construction on , which reduces the bureaucratic overhead involved in proving anything about them. For instance, morphisms of hyperdoctrines on the same base are natural transformations
(a 2-cell) , while morphisms of fibrations on the same base are just a functor (a 1-cell). Despite this, passing to the total category does not lose information. To see why, we need to properly introduce fibrations.
Notational conventions. We think of the total category of a fibration as being “upstairs” of the base category, which is “downstairs,” and draw diagrams accordingly. Variables like X and Y represent objects of the total category and will lie over objects of the base category denoted by variables like A and B. Our treatment of fibrations mostly follows Jacobs [31], but we caution the reader that the theory of posetal fibrations is much simpler than the general picture developed in that book.
Definition 4.4 ([31, Definition 1.1.3]). Let be a functor.
(1) A morphism in is cartesian if for any and with there exists a unique with making .
(2) A morphism of is vertical if .
(3) The functor is a fibration if for any morphism in , there exists a cartesian morphism such that and . This is called a cartesian lift of .
Cartesian lifts are unique up to unique isomorphism, but are not strictly unique in general. A fibration is cloven if it is equipped with a choice of lifts, which assigns to every object and morphism a cartesian morphism with with . For each object of there is a category called the fiber over . Its objects are all the such that , and the morphisms are all the morphisms such that . A fibration is said to be posetal when all of its fiber categories are posets. The following characterization makes working with posetal fibrations convenient.
PROPOSITION 4.5 ([61, THEOREM 9.1(A)]). p is posetal if and only if p is faithful.
This applies in particular to (Proposition 4.3). In , if a morphism is vertical, then and . So the fiber over of is isomorphic to the poset . Next we characterize the cartesian morphisms.
PROPOSITION 4.6. If a morphism of is cartesian over , then .
PROOF. We already know . Consider the morphism lying over . There is a commuting triangle in , so we apply the universal property of to get a vertical morphism , i.e., a proof that .
Definition 4.7. For each in the base of a cloven fibration , there is a reindexing functor defined on objects as the chosen lift of against . The action on morphisms is given by the universal property of the lift.
PROPOSITION 4.8. Suppose is posetal.
(1) p has a unique choice of lifts.
(2) is split: we have and for all and all composable in .
(3) Every vertical morphism f is both epi and mono in .
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
We now have enough to recover the action of on morphisms: it is the contravariant reindexing functor sending morphisms of to monotone functions between the fibers. Altogether we have proved the following, which is a special case of the more general theory of the Grothendieck construction. See Jacobs [31, Theorem 1.10.7] or Johnstone [32, §B1.3].
PROPOSITION 4.9. For all functors , the total category is a posetal fibration with the following properties.
(1)
(2) is vertical if and only if
(3) is cartesian if and only if
(4)
Fibrations generalize categories and as such come with their own notions of functor and natural transformation. These assemble into a 2-category Fib with a subcategory Fib_{pos} of posetal fibrations.
Definition 4.10. Given fibrations and , a fibered functor from to is a commutative square
in which preserves cartesian morphisms. Inline, we write or just , pars pro toto.
Definition 4.11. Let and be fibered functors from to . A fibered natural transformation from to is a pair of natural transformations and such that . It is vertical if its components are vertical.
4.1 Modeling BI
In this section we introduce 2-categories of bunched fibrations that are equivalent to the 2-category of BI hyperdoctrines via the total category construction. We briefly review posetal fibrations for ordinary first-order and higher-order logic, which are known to be equivalent to ordinary first-order and higher-order hyperdoctrines.
Definition 4.12. A posetal fibration is first-order if
(1) The base category has finite products.
(2) Each fiber is a Heyting algebra and each is a homomorphism of Heyting algebras.
(3) (Simple products) Reindexing along a projection has a right adjoint such that for all ,
(4) (Simple coproducts) Reindexing along a projection has a left adjoint such that for all ,
(5) (Equality) Reindexing along a duplication has a left adjoint such that for all ,
A first-order fibration is higher-order if it has a generic object: an object true lying over over an object such that for any there is a unique characteristic morphism with .
We now define bunched fibrations and their morphisms, which are certain fibered functors. Taking 2-cells to be fibered natural transformations between morphisms, they assemble into the 2-categories BIFib and HOBIFib.
Definition 4.13. A bunched fibration is a first-order posetal fibration equipped with an additional symmetric monoidal closed structure on each fiber that is preserved by reindexing. A morphism of bunched fibrations and is a fibered functor such that preserves finite products, strictly preserves bicartesian closed and symmetric monoidal closed structure on fibers, and preserves , and Eq [31, Defs. 1.9.13, 3.4.7].
Definition 4.14. A first-order bunched fibration is higher-order if it has a generic object and is cartesian closed. A first-order bunched fibration morphism is a morphism of higher-order bunched fibrations if the canonical map is an isomorphism.
The equivalence with BI hyperdoctrines is a straightforward consequence of Proposition 4.9 and the more general theory of the Grothendieck construction.
THEOREM 4.15. The total category construction defines equivalences of 2-categories and .
This gives rise to an interpretation of BI (i.e., the syntax in Fig. 2 aside from the weakest precondition) in any bunched fibration. Types and contexts are interpreted by objects of and propositions are interpreted by objects of over . We give a few representative clauses for propositions under a context .
The result above (Theorem 4.15) follows easily because the definition of bunched structure on a fibration is done fiberwise. However, in the sequel we will frequently work with monoidal and monoidal closed structures on all of .
Definition 4.16. A posetal fibration is (externally) symmetric monoidal if is symmetric monoidal, is cartesian, and is a strict symmetric monoidal functor. Likewise for (externally) symmetric monoidal closed.
External and fiberwise monoidal structure are tightly related provided one has a cartesian or cartesian closed structure on the base category. For instance, the following is a consequence of Theorem 12.8 in Shulman's magisterial study of monoidal fibrations [55, Theorem 12.8].
PROPOSITION 4.17. Every first-order bunched fibration is externally symmetric monoidal with tensor product
The same correspondence does not go through for the monoidal closed structure for the simple reason that first-order BI hyperdoctrines do not assume exponentials on their base and our definition aligns with that one. However, assuming closed suffices. This of course applies to higher-order bunched fibrations.
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
PROPOSITION 4.18. If is a first-order bunched fibration and is cartesian closed then is externally monoidal closed.
COROLLARY 4.19. Every higher-order bunched fibration is externally monoidal closed.
4.1.1 Base change for bunched fibrations
Definition 4.20. Given a fibration and a functor , the change-of-base fibration is the pullback in Cat of against . Explicitly, this is
(1) A category with objects and morphisms with .
(2) A fibration sending to and with cartesian lifts of given by the cartesian lifts of in .
(3) A projection functor sending to .
The projection is a fibered functor .
We note in passing that change of base along for a total category fibration is equivalently the total category of the precomposition .
PROPOSITION 4.21. If is a first-order bunched fibration and preserves products, then is a first-order bunched fibration and the fibered functor is a morphism of first-order bunched fibrations.
PROOF. Fiberwise structure exists and is preserved by the projection because . For quantifiers and equality, we need only observe that and .
PROPOSITION 4.22. If is a higher-order bunched fibration, is cartesian closed, and is a cartesian closed functor with a right adjoint, then is a higher-order bunched fibration. If , then is a morphism of higher-order bunched fibrations.
PROOF. The first-order structure is handled by Proposition 4.21. Let be the right adjoint to . Set . Given over , we already have with . Let be the transpose of . We calculate
Remark 4.23 (Models of Iris). In a paper on BI hyperdoctrines, Bizjak and Birkedal temporarily pass to fibrations in order to obtain the model of Iris as a pullback along the inclusion of total presheaves (COFEs) into [15, Theorem 6.8]. An analysis of the adjunction between COFEs [20] and the topos of trees [13] shows the hypotheses of Proposition 4.22 are satisfied, establishing that their pullback square is a morphism of higher-order bunched fibrations.
We now present the lax slice, a generalization of Proposition 3.3 to internal BI algebras. Lax slices over resource algebras shall be taken over the canonical BI algebra . A similar construction appears in Aguirre et al. [3].
Definition 4.24 (lax slice). Let be a BI algebra internal to a topos . Set if factors through the order relation . The lax slice is the category with objects and morphisms laxly commuting triangles
5 Fibered Weakest Precondition
This section develops the necessary technical machinery for monad liftings and their relationship to weakest precondition modalities.
5.1 Monads and Adjunctions
We make use of the formal theory of monads in a 2-category. This generalization of monads and adjunctions is due to Street [60] but for an accessible tutorial consult Hinze and Marsden [29]. While this section contains no new results, it will be heavily used throughout this paper.
Definition 5.1. A monad internal to a 2-category consists of an object and a 1-cell equipped with a unit , and multiplication satisfying the usual monad laws.
Definition 5.2. Given monads and , a monad morphism from to is a 1-cell and 2-cell satisfying the following unit and multiplication laws.
Definition 5.3. A adjunction in a 2-category consists of two objects and with a left adjoint , a right adjoint , a unit , and a count such that and . We abbreviate this as following the direction of the left adjoint.
Definition 5.4. A morphism of adjunctions from to is a pair such that , and .
For , the internal definitions recover the usual definitions of monad, monad morphism, and adjunction.
We briefly record some facts about the Huber envelope, which is the construction that “sandwiches” a monad in an adjunction.
Definition 5.5. The Huber envelope of a monad within an adjunction is the monad with unit and multiplication . This assignment is functorial in and .
PROPOSITION 5.6. Let be an adjunction with count and let be a monad. There is a monad morphism given by .
We briefly recall the definition of monoidal strength due to Kock [38] and introduced to the semantics of effects by Moggi [48].
Definition 5.7. A monoidal strength for a monad on a symmetric monoidal category is a natural transformation satisfying well-known coherence conditions. A strong monad is a monad equipped with a strength, and a morphism of strong monads is a monad morphism such that is strong monoidal with natural isomorphism
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
and the following diagram commutes.
5.2 Strong Monad Liftings for Weakest Preconditions
Definition 5.8. A monad lifting on a fibration is a fibered functor where is a monad on , is a monad on , and is a strict monad morphism.
Monad liftings are the monads in the 2-category Fib of fibrations, fibered functors, and fibered natural transformations. With this in mind, we take a morphism of monad liftings to be a monad morphism in Fib. These definitions accord with the theory of monad liftings developed in Aguirre et al. [3].
The monad liftings of loc. cit. validate a conjunctive frame rule if they are equipped with a fibered cartesian strength. To model the tensorial frame rule of separation logic, we shall require a fibered monoidal strength. Recall (Proposition 4.17) that although bunched fibrations are defined in terms of fiberwise tensors, they have a canonical external monoidal structure .
Definition 5.9. Let be a bunched fibration. A bunched monad lifting is a monad lifting on such that is strong, is strong with respect to the external tensor on , and is a strict morphism of strong monads. A morphism of bunched liftings is a morphism of monad liftings whose upper and lower components are each morphisms of strong monads.
We now have enough semantic scaffolding to justify useful proof rules. The strong monad lifting implies the soundness of the rules WP-RETURN, WP-BIND, WP-FRAME and WP-MONO from Figure 1.
The next few propositions follow from posetal fibrations being faithful functors.
PROPOSITION 5.10 ([3, LEMMA 12]). Let be a monad lifting on a bunched fibration. Strengths for correspond bijectively to strengths for such that for all over and over .
PROPOSITION 5.11. Let and be monad liftings on with a monad (resp. strong monad) morphism from to . If is fibered over and is fibered over , then it is automatically a monad (resp. strong monad) morphism and is a morphism of monad liftings (resp. bunched monad liftings).
COROLLARY 5.12. If and are monad liftings (resp. bunched monad liftings) of the same monad , any vertical natural transformation defines a monomorphism of monad liftings (resp. bunched monad liftings) .
THEOREM 5.13. Bunched monad liftings on first-order bunched fibrations are stable under pullback along cartesian functors.
PROOF. Apply Azevedo de Amorim et al. [7, Theorem VIII.1]. To do this, we need a 2-category whose internal monads are strong monads. Such a 2-category was defined in Example VIII.3 of op. cit. for the cartesian case, which readily generalizes to the monoidal case. Furthermore, we need this 2-category to have enough pullbacks; this follows from Proposition 4.21.
Katsumata [37, Theorem 4.7] offers a more concrete presentation of a slightly simpler version of this construction. We note also that a similar theorem can be proved for higher-order fibrations, for pullback along functors satisfying the hypotheses of Proposition 4.22.
Example 5.14. A monad on the base category of a bunched fibration may have several distinct liftings, as we now show for the standard heap model (Section 3) and its corresponding total category fibration (Example 4.2). The monad on the base is an ordinary state monad in which all computations are total. A lifting has to be a monad on , and in particular must be a functor sending where is a heap predicate on computations that is monotone in .
(1) The evaluation lifting is determined by setting
(2) The frame-preserving lifting, which is equivalent to the WP given in Section 3, is determined by setting
The frame rule is unsound for the evaluation lifting. The computation wipe = that unconditionally deallocates the entire heap satisfies wp wipe emp but not wp wipe , which ought to follow from a use of the frame rule with .
The frame rule is sound for the frame-preserving lifting. While this is an improvement on the evaluation lifting, the frame-preserving lifting permits verifying strictly fewer programs. For example, no specification wp wipe Q is valid. To see why, suppose such a specification holds and select a nonempty framing heap . Certainly wipe , so the spec says that there is some making . But this is impossible.
5.3 Interpreting Separation Logic
We now extend the semantics of BI discussed in §4.1 to support the weakest precondition modality. Recall that types and contexts denote objects of the base category, terms denote morphisms , and predicates on denote elements of the fiber over . Entailment between predicates defined in the same context is modeled by , the partial ordering of the fiber over .
The subexpressions of wp are a term and a predicate prop. Assume a fibration equipped with a monad lifting where has a strength . Then define
This defines an element of the fiber over by reindexing, as depicted in the following diagram.
\begin{array}{c}\left[\mathbf{wp}c Q\right]\xrightarrow{\quad}\sigma_{[\Gamma],[A]}^{*}W[\![Q]\!]\\\downarrow\quad\downarrow\quad\downarrow\\\left[\Gamma\right]\xrightarrow{\langle\mathbf{id}_{[\Gamma]},\![c]\!}\left[\![\Gamma]\!]\times T[\![A]\!]\xrightarrow{\sigma_{[\Gamma],[A]}}T(\left[\![\Gamma]\!]\times[\![A]\!]\right)\end{array}Aside from the lifting this interpretation only requires a cartesian base category and a strength for , which are both already required in order to model Moggi's monadic metalanguage in the base.
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
6 General Constructions
This section considers three generic constructions that take unique advantage of our fibered formulation of BI and of bunched weakest precondition. One of the benefits of our approach is that we can transform certain informal design patterns from separation logic into crisp formal constructions that can be reasoned about and reused. This contrasts with existing approaches where even though there are guiding design principles, they have to be proven sound for every new application.
While there are other useful constructions from separation logic that are not presented in this work, the examples below suggest that they might also be within reach of our formalism. We leave a more thorough investigation of such constructions to future work.
6.1 Imposing a Strength on a Monad Lifting
We saw in Example 5.14 that the evaluation lifting for the global state allows deriving specifications like wp wipe emp that cannot be framed. In that example, a frame rule is recovered by replacing the definition of wp with one that quantifies over framing heaps . In theory, this amendment to the defining formula of the weakest precondition incurs a tedious re-proving of everything that had been proved about the old definition, but in practice those proofs tend to go through without a hiccup.
The practice of “baking in the frame rule” obtains a frame-preserving WP from a non-frame-preserving one by quantifying over framing propositions [14]. A new weakest precondition is defined as follows:
This validates WP-FRAME and refines wp in the sense that implies . This is the universal such refinement of wp, as it imposes no new constraints besides the frame rule.
We will now reconstruct as an operation on monad liftings we term the frame-preserving core. The frame-preserving core is always a bunched lifting (Proposition 6.3), so it satisfies the frame rule, and it comes with a morphism of monad liftings into (Corollary 6.8). It is optimal in a sense made precise by Corollary 6.12: it satisfies a universal property among bunched liftings with ordinary monad lifting morphisms into .
6.1.1 Constructing the core. Fix a higher-order bunched fibration and a monad lifting with a strength for . This gives us enough structure to interpret Equation (1) as an assignment of objects over to objects over . To wit, for let
This suggests a Huber envelope, with tucked into the indexed monoidal closed adjunction and the simple product adjunction, but an indexed adjunction is not a fibered one. Instead, we recover as the fibered Huber envelope of the fibered adjunctions and monad lifting shown in Figure 3, which we now explain from left to right.
The first adjunction in Figure 3 is the fibered analogue of the indexed simple product adjunction. It relies on a construction that adds a fixed proposition representing the frame to a higher-order fibration as follows.
As noted by Hermida [28], the simple product adjunctions assemble into a fibered weakening functor that sends to . Its action on morphisms
Fig. 3. The adjunctions and monads that define the frame-preserving core.
is obtained from the universal property of cartesian morphisms and the naturality of . By the same token, the right adjoints assemble into a fibered right adjoint .
A few words about are in order. The fiber over is isomorphic to , so each fiber inherits monoidal closed and cartesian closed structure from . Reindexing functors are also inherited: for , we have . As a consequence, the fiberwise structure is preserved by reindexing. It also contains an object we call the invariant. All reindexing functors of preserve the invariant.
The second adjunction in Figure 3 is the invariant adjunction. We already have an indexed family of vertical adjunctions -. Since the indexed adjoints are preserved by reindexing, they assemble into the adjunction - fibered over the identity.
The last ingredient is the monad lifting. We cannot take the Huber envelope of within the fibered adjunction we just constructed because is a monad on . In any case, we do not want monadic computations downstairs to alter the invariant . We address this by reindexing along the strength of to ignore the invariant as follows.
Definition 6.1. The oblivious monad oblivious W on is the functor .
The action of oblivious W on morphisms into X is obtained from the naturality of the strength and the universal property of . The unit and multiplication at X are determined by the unit and multiplication laws for and the universal property of . The monad laws hold automatically because the fibration is faithful.
We can now construct a lifting for T that recovers the indexed definition from Equation (2). Applying Definition 5.5 and Proposition 5.6 to the adjunction and monad in Figure 3 gives:
LEMMA 6.2. is a monad lifting.
Our fibrations are posetal, so making this into a bunched lifting amounts to proving an inequality (Proposition 5.10). We leave these proofs to Appendix A.1, as they are an algebraic version of the usual syntactic proof that a weakest precondition defined by Equation (1) validates the frame rule.
PROPOSITION 6.3. is a bunched monad lifting.
6.1.2 The frame-preserving core is universal. The frame-preserving core is in some sense the smallest change one could make to a monad lifting in order to get a strong monad lifting. We make this precise with a universal property that says any (non-strong) monad lifting morphism from a strong monad lifting into factors uniquely through . The argument hinges on classifying as the right adjoint to an inclusion.
Definition 6.4. The category PreHOMnd of pre-strong bunched liftings is all the higher-order bunched fibrations equipped with monad liftings where is strong. Morphisms are monad lifting morphisms such that is a
16 John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim morphism of higher-order bunched fibrations and (𝐹, 𝜆) : 𝑆 → 𝑇 is a morphism of strong monads. The category of strong bunched liftings HOMnd restricts PreHOMnd to bunched liftings and their morphisms. The strong bunched liftings form a full subcategory of the pre-strong bunched liftings because any morphism that preserves strengths downstairs will preserve them upstairs if they exist. Proposition 6.5. The category with an invariant construction is a functor −[inv] : HOBIFib → HOBIFib. Moreover, if 𝐹 : 𝑝 → 𝑞 in HOBIFib and 𝐿𝑝 ⊣ 𝑅𝑝 and 𝐿𝑞 ⊣ 𝑅𝑞 are instances of Figure 3 then (𝐹, 𝐹 [inv]) is a morphism of adjunctions. Proof. First, (− × Ω) ∗𝑝 is a higher-order bunched fibration. Quantifiers are straightforward to construct even though − × Ω is not product preserving. The generic object is Ω ⇒ Ω. Let (𝐹,𝐺) : D → E be a morphism of higher-order bunched fibrations. Since 𝐹 (𝐴 × ΩD) = 𝐹𝐴 × ΩE, we define 𝐺[inv] (𝐴, 𝑋 ∈ D𝐴×ΩD ) = (𝐹𝐴,𝐺𝑋 ∈ E𝐹𝐴×ΩE ). Composition and identity laws are immediate. The morphism of adjunctions comes from the fact that the adjunctions in question are defined using only higher-order bunched structure and 𝐹 preserves all of that structure. □ Proposition 6.6. The oblivious monad construction defines a functor obliv : PreHOMnd → PreHOMnd. Proposition 6.7. The frame-preserving core defines a functor Core : PreHOMnd → HOMnd. We will now construct a monad morphism into𝑊 showing that the frame-preserving core refines the original monad. Corollary 6.8. For any 𝑋, there is a vertical morphism 𝜉𝑋 : 𝑊 f𝑋 ≤ 𝑊 𝑋. This defines a morphism 𝜉 : 𝑊 f → 𝑊 in PreHOMnd. If 𝑊 is strong, 𝜉 is in HOMnd. Lemma 6.9. If (𝑇 ,𝑊 ) is a bunched monad lifting then 𝑊 f = 𝑊 . Together, Lemma 6.9 and Proposition 6.3 give: Lemma 6.10. If (𝑇 ,𝑊 ) is a monad lifting then (𝑊 f ) f = 𝑊 f . Details can be found in Appendix A.2. Theorem 6.11. The functor Core : PreHOMnd → HOMnd that constructs the frame-preserving core of a monad lifting is right adjoint to the functor 𝑈 : HOMnd → PreHOMnd that forgets the tensorial strength of a bunched lifting. Proof. The unit 𝜂 : 𝑋 → Core𝑈 𝑋 for 𝑋 strong is an identity (Lemma 6.9) and the counit 𝜖 : 𝑈Core𝑌 → 𝑌 for 𝑌 pre-strong is the refinement vertical natural transformation (Corollary 6.8). Now for the laws. Core𝑋 Core𝑈Core𝑋 𝑈 𝑌 𝑈Core𝑈 𝑌 Core𝑋 𝑈 𝑌 𝜂 id Core 𝜖𝑋 𝑈 𝜂 id 𝜖 The unit 𝜂 is always an identity. In the first diagram, the interesting morphism for Core 𝜖𝑋 is a vertical natural transformation with components (𝑊 f ) f𝑍 ≤ 𝑊 f𝑍, where 𝑍 is an actual object of some total category and 𝑊 is the lifted monad associated with 𝑋. The inequality is actually an identity (Lemma 6.10). In the second diagram, the morphism 𝜖𝑌 is an identity because 𝑌 is already strong (Lemma 6.9). □
Since is full and faithful, Theorem 6.11 exhibits HOMnd as a coreflective subcategory of PreHOMnd. As a right adjoint, the frame-preserving core enjoys a co-free universal property with respect to morphisms of bunched liftings.
COROLLARY 6.12. For any higher-order bunched fibration with a strong monad lifting , every morphism of monad liftings factors uniquely through the refinement .
6.2 Credit-Based Cost Reasoning
This section shows how to extend monad liftings to reason about cost. This is inspired by work on credits for separation logic, pioneered by Atkey [5] and widely applied since then [2, 19, 26, 43, 47, 51, 64]. We follow the methodology explained in Section 1.
Semantic monad. Assuming the existence of a monad , we want a monad that extends with a cost model. There has been much work done in finding such extensions [6, 25, 35, 39]. We base our semantics on the writer monad transformer used in the decalf type theory [25]. Therefore, assuming a commutative partially ordered monoid internal to a topos , we use the monad .
Bunched fibration. For the sake of making our construction more concrete, we assume that our base bunched fibration is of the form , where is a resource algebra internal to the topos . In order to model the cost information, we want to also grade our predicates by elements of . Therefore, we take as our new bunched fibration — i.e. predicates are graded by the base resource algebra and by the cost monoid .
Monad lifting. We now define a lifting of . Assuming that we have a monad lifting , we define our lifting in three steps. First, we apply the following change of base transformation that threads the cost information through .
THEOREM 6.13. The lifting transports to a lifting on .
PROOF. We define the following monad lifting
where . We have to show that this is indeed a monad and that it lies over . Because our bunched fibrations are assumed faithful, these properties hold by construction. It remains to show that the underlying monad structure does indeed lift. The proof can be found in Appendix F.
Then, we define a lifting of the object as where we are using the equality internal to . We conclude this construction by combining these two liftings as . Concretely, applying it to , results in the following -graded predicate over :
We now illustrate what this weakest precondition modality gives us in the context of costful global state where the predicates are indexed by sets of heaps.
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim

Fig. 4. Pullback definition of fibered inclusion functor
Example 6.14. We assume the bunched fibration defined in Example 5.14. Given a postcondition and a computation , the weakest precondition modality given above unfolds to
for all disjoint from
6.3 Persistence via Fibered Limits
In this section we show how to obtain persistence-like modalities by using familiar constructions from fibered category theory. These modalities are an important component of modern higher-order separation logics, as they are used for handling persistent knowledge, including Hoare triples and invariants. Our construction generalizes Definition 4.24 from a lax slice fibration to a general hyperdoctrine, presented using first-order fibrations [31, Definition 4.2.1].
Example 6.15 (cf. [27, Definition 3.3.4]). If is a bunched fibration and a monoidal category then there is a bunched fibration . The intuitionistic connectives are given pointwise; the substructural ones are given by Day's convolution. Pulling this back along , the constant presheaf functor , produces a fibration .
The universal property of pullbacks then gives a fibered inclusion , shown in Figure 4. To define adjoints to , we have to remember that, in ordinary category theory, (co)limits of a given shape in a category are equivalently adjoints to the constant-functor functor . In the case of fibered category theory, this generalizes as follows: fibered (co)limits are equivalently defined as fibered adjoints to functors defined just like . these fibered adjoints exist whenever and have -shaped (co)limits that are strictly preserved by [31, Exercise 9.2.4]. These assumptions are satisfied by the kinds of fibrations we have encountered so far. Taking the right adjoint performs universal quantification over the base resource, as in “for every resource , this proposition holds”. The following example illustrates.
Example 6.16. Consider the heap model from Section 3. In this case, the starting fibration is the predicate fibration over Set. The total category then becomes the category whose objects are pairs of a set and a heap-graded predicate , and morphisms are predicate-preserving functions. The inclusion maps a predicate to the constant graded predicate. Its right adjoint maps a graded predicate to the predicate “for every heap holds”. Resolving this adjunction yields the comonad that maps a graded predicate to its resource-invariant fragment. Since the empty heap is the least heap, this is equal to mapping a predicate to , the usual definition of the persistent modality in the heap model.
Therefore, it is sensible to define our persistence modality as an adjunction between an intuitionistic fibration and a bunched one. We call them resourceful-non-resourceful (RNR) adjunctions as a nod to linear-non-linear adjunctions from the linear logic literature [10]. We begin by defining monoidal adjunctions.
Definition 6.17 ([46, Proposition 13]). If and are monoidal categories, a monoidal adjunction is a pair of adjoint functors such that is strong monoidal.
We now present the definition of RNR adjunctions. For the sake of simplicity, we have defined first-order RNR adjunctions, but this readily generalizes to the higher-order case as well.
Definition 6.18. An RNR adjunction consists of a first-order fibration , a first-order bunched fibration and a fibered monoidal coreflective adjunction:

6.4 Idempotent core of a quantale
There is a nice proportionality analogy “Heyting algebras are to locales like BI algebras are to quantales”. Explicitly, quantales are complete BI algebras. This structure has received much attention as a way of capturing non-commutative notions of space and algebra. In this example we show known constructions from the quantale literature can be used to construct RNR adjunctions. We start with some preliminary definitions.
Definition 6.19. A quantale is affine if its monoidal unit is the top element.
Definition 6.20. A quantale morphism is a function that preserves the whole quantalic structures.
Definition 6.21. An element of a quantale is idempotent if .
Definition 6.22. Given an element of an affine quantale , its idempotent part is .
LEMMA 6.23. For every idempotent element , if, and only if, . More abstractly, the - operation is right adjoint to the inclusion .
A direct calculation shows that every quantale morphism maps idempotents to idempotents: .
LEMMA 6.24. Given an affine quantalic bunched fibration , its idempotent restriction is a first-order fibration.
THEOREM 6.25. Given an affine quantalic bunched fibration , there is an RNR adjunction between and its idempotent restriction .
PROOF. There is a fibered inclusion . We now use the - construction to define the right adjoint . On objects, it maps to and it is identity on morphisms. We now have to show that this is a fibered adjunction. We start by showing that it is an adjunction. The unit and counit can be readily defined using the - adjunction.
We now show that the functors are fibered. While the inclusion is fibered by construction, the right adjoint needs a bit more work, which we now show. In this case, fibered-ness reduces to showing that for every morphism . For the direction , consider an idempotent element . It suffices to show that . We do this by
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
noting that by the adjoint functor theorem, the quantale morphism has a left adjoint f^!\ and, therefore,. The first inequality is the unit of theadjunction. As for the second one, we use monotonicity ofandwhich impliesand, therefore,.
As for the direction , we begin by unfolding the definition of and using the fact that preserves suprema, meaning that we have to show
For every idempotent less than or equal to . By the definition of and because is an idempotent, it suffices to show that , which follows from monotonicity of and .
From RNR adjunctions to weakest preconditions. Though the definition above captures the interaction between structural and substructural logics, it does not account for the weakest precondition modality, nor does it capture the interaction between traditional Hoare logic and separation logic. To remedy this, we incorporate monad liftings into our definition by requiring two monad liftings and , respectively, with a mediating monad morphism .
We conclude this section by showing that given an RNR adjunction and a bunched lifting, there is a universal non-bunched lifting we can construct for the intuitionistic fibration , given by the Huber envelope. We now formalize this universal property.
Definition 6.26. The category is defined as
-
The objects are RNR adjunctions over and with two liftings and , connected by a monad morphism .
-
The morphisms are monad morphisms between the liftings.
In order to prove our universal property, we define a variant of where the objects only require existence of the bunched lifting . We call such category . We can now state the main theorem of this section.
THEOREM 6.27 (CF. SECTION G). The Huber envelope is the left adjoint to the forgetful functor .
7 Bunched Liftings for Local Independence
This section introduces a generic allocation monad for any situation involving local independence as axiomatized by Simpson [57], alongside a higher-order separation logic for it. Then, it combines this with the pullback-stability theorems presented in the preceding sections to give a novel separation logic for the Giry monad.
7.1 A Generic Allocation Monad
In brief, local independence structure equips a category with what is called a system of independent pullbacks. This consists of a collection of commuting squares in , called independence squares, with some squares called independent pullbacks if they are universal among independent squares with the same bottom cospan. Independent squares and independent pullbacks must satisfy five axioms resembling properties of ordinary pullbacks (e.g., the two-pullbacks lemma). Details can be found in Simpson [57, Definition 6.1].
In this section we work with an arbitrary category C that has a system of independent pullbacks as well as a terminal object.
Definition 7.1. The allocation monad Alloc on has action on objects defined by a colimit denotes the canonical projection out of a slice category):
Explicitly, elements of are equivalence classes where is a morphism and , with if and only if the cospan completes to a square such that .
Notably, the colimit just given does not come with an evident contravariant action, as it uses covariantly to form . To make a functor, its action on morphisms is defined by independent pullback: where is the independent pullback of along .
Thinking of objects of as possible worlds, each represents an expansion of the current world into a new world where new resources can be allocated before producing . The strong monad structure on Alloc reflects this:
The unit yields computations that perform no expansion, the multiplication combines expansions using composition, and the strength uses the action of P to transport x to the expanded world d.
Suitable choices of C recover monads used in the semantics of name generation, local store, and synthetic probability.
-
When , the opposite of the category of finite sets and injective functions, Alloc becomes the name generation monad used by Stark [58] to model the -calculus.
-
When , the category of heap layouts and initializations from Kammar et. al. [36, §IV.B], Alloc becomes the hiding monad that models locality of full ground reference cells.
-
And when , the category of Polish probability spaces and measure-preserving functions, Alloc becomes the probability monad defined by Simpson [56] that provides an analog of the Giry monad on his topos of probability sheaves.
This final example has recently been generalized to an arbitrary Markov category with conditionals, providing a notion of abstract sample space for discrete and Gaussian probability as well as nondeterminism [59]. Each such choice of Markov category makes Alloc an accompanying notion of probabilistic or nondeterministic computation. We note in passing that Alloc always produces atomic sheaves—a proof can be found in Appendix C.
7.2 Local Independence as Bunched Fibration
This section presents a higher-order bunched fibration over . The starting point for this construction is the following observation, which provides a monoidal analog of the standard fact that a category with pullbacks and a terminal object has products:
PROPOSITION 7.2. C is symmetric semicartesian.
As in the cartesian case, the tensor product is defined by taking the independent pullback of the unique morphisms and into the terminal object of . Though we will not use it, we note a stronger form of Proposition 7.2 showing that independent pullbacks create locally symmetric semicartesian structure.
PROPOSITION 7.3. Let C be an arbitrary category with a system of independent pullbacks. Then
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
(1) each slice is symmetric semicartesian;
(2) independent pullback along defines a strong monoidal functor ;
(3) and , making the slice construction a contravariant pseudofunctor from to the category of symmetric semicartesian categories.
The proof is analogous to the case of ordinary pullbacks, except one must take care to check that mediating maps into a pullback are given by independent squares. Details can be found in Appendix B.
Proposition 7.2 makes a symmetric semicartesian category as well, by Day convolution. This structure can be reflected into a pcm object Res of resources: the idea is that a morphism models local knowledge of the current world . For instance, when , such a morphism is an injective map picking out a subset of visible to a particular observer.
Definition 7.4. The presheaf of resources is defined by the colimit , where is the Yoneda embedding and is the groupoid of isomorphisms in .
Explicitly, elements of are equivalence classes with if and only if for some isomorphism . The quotient makes the specific appearing in a given resource irrelevant, in much the same way that a subobject is an equivalence class of monomorphisms.
PROPOSITION 7.5. Res forms a commutative monoid object in the monoidal category ([C^op; Set], ⊗, 1).
PROOF. Via the coend formula for Res Res, the product operation of this monoid object is given by the cowedge that sends to . The unit is . The commutative monoid laws follow from the symmetric semicartesian structure of .
The following characterization of the Day convolution Res Res shows that this commutative monoid can be reexpressed as a partial commutative monoid in the cartesian monoidal category .
PROPOSITION 7.6. (Res Res)(c) is isomorphic to the subset of (Res Res)(c) consisting of pairs ([r,f], [s,g]) such that! is an independence square (! denotes the unique morphism into 1), and this isomorphism is natural in c.
PROPOSITION 7.7. (Res, , e) forms a pcm in .
The multiplication (•) is the partial function that is defined if and only if the resources that it is given are independent. Finally, elements of Res are ordered by the amount of knowledge that they capture to give an ordered pcm object.
Definition 7.8. Let be the subpresheaf of consisting of those elements such that for some .
PROPOSITION 7.9. (Res, , , e) is an ordered pcm in .
A proof that satisfies the requisite monotonicity condition can be found in Appendix D. With Res in hand, one can define a presheaf RProp of resourceful propositions as the presheaf of internally upwards-closed subsets of Res. RProp is a complete BI algebra object in by construction, so the lax slice over RProp is a higher-order bunched fibration.
In what follows, it will be convenient to have the following explicit definition of this bunched fibration. Say that a predicate on a presheaf is a subfunctor of such that if for some and and , and factors as for some
PROPOSITION 7.10. The lax slice of over RProp is equivalent to the fibration where
• Objects of are pairs with a predicate on ;
- Morphisms of from to are maps of presheaves such that implies for all objects of , and ;
• The functor is the projection .
7.3 Lifting the Allocation Monad
Definition 7.11. The lifting of Alloc is defined by , where the predicate contains a pair if and only if there exists a representative of and a new resource such that and there is a morphism such that forms an independence square.
Intuitively, says that a piece of local knowledge about the current world is enough to establish as a postcondition for a computation if the result produced by satisfies given upgraded knowledge , formed by amalgamating with any new resources used to produce . That this amalgamation forms an independence square captures the idea that one's state of knowledge before running is independent of the resources will allocate. This independence is crucial for establishing that validates the frame rule.
THEOREM 7.12. forms a bunched monad lifting of Alloc along the higher-order bunched fibration .
PROOF. The axioms for a system of independent pullbacks ensure that the strong monad structure for Alloc lifts to a strong monad structure for . For instance, the unit of Alloc lifts to a map by axiom IP1. Similarly, the multiplication of Alloc lifts because independence squares can be pasted together by axiom IP3, and the strength lifts because independence squares satisfy a two-pullbacks-lemma-type property by axiom IP4. The monad laws for these lifted unit, multiplication, and strength maps follow from the monad laws for Alloc because the lax slice fibration is posetal. Finally, an explicit calculation verifies that is a fibered functor. Details can be found in Appendix E.
We conclude this section by showing how this generic construction yields logics for name generation, used in the semantics of dynamic allocation and abstract garbage collection, and for continuous probability.
Example 7.13 (name generation). When , objects of are finite sets that can be thought of as sets of names that are in use at a given point in time. Morphisms are injective functions . These functions have two readings: as an expansion of into , or as local knowledge of the part of hit by . A resource in is precisely a subobject of , hence equivalent to a subset of .
The bunched fibration models a separation logic for disjointness of names. Objects of are pairs where and is a predicate on pairs satisfying the property that if and then . The separating conjunction of two predicates on a presheaf is defined by if and only if there exist disjoint subsets of such that and .
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
The allocation monad Alloc is equivalent to the name generation monad Gen defined by Stark [58], where is the set of pairs quotiented by an equivalence relation that identifies the results x up to renaming of names in .
The lifted monad Alloc is defined by where if and only if . Intuitively, this states that a piece of local knowledge suffices to establish a postcondition if and only if holds of the result when is upgraded with knowledge of the newly generated names.
Example 7.14 (continuous probability). Let be the category of Polish probability spaces and measure-preserving maps. Objects of are the sample spaces of standard probability theory. Morphisms can be interpreted either as an expansion of into , or as local knowledge of restricted to those observable quantities on that factor through .
The bunched fibration over models a separation logic where separating conjunction means probabilistic independence. Objects of are pairs where is a predicate on pairs of shape such that if and for some , then . The separating conjunction of two predicates on a presheaf is defined by if and only if there exist random variables with domain such that and are probabilistically independent and and .
The allocation monad Alloc is the probability monad on defined by Simpson [56]. The lifting given by Theorem 7.12 yields a bunched weakest precondition for . From here, a bunched weakest precondition for the more familiar Giry monad , restricted to the category of Polish spaces and universally-measurable maps, can be obtained by taking a series of pullbacks:
The square on the right pulls back along the inclusion of atomic sheaves on into presheaves. The inclusion preserves finite products because it has a left adjoint (sheaffication); hence the fibration in the middle is a first-order bunched fibration by Proposition 4.21. Moreover, inclusion of sheaves into presheaves forms a strong monad morphism because sends sheaves to sheaves [56, Theorem 7], giving a bunched monad lifting for the middle fibration by Theorem 5.13.
The square on the left depicts a pullback along the functor RV that sends a Polish space A to the atomic sheaf of A-valued random variables quotiented by almost-everywhere equality [56, Prop.1]. This functor preserves finite products, making the fibration on the left a first-order bunched fibration by Proposition 4.21. RV is also strong-monad-preserving [56, Theorem 8], so applying Theorem 5.13 a second time gives a bunched monad lifting for the fibration on the left.
All told, this gives a model of first-order BI where separating conjunction models probabilistic independence, complete with a bunched weakest precondition for the Giry monad.
An explicit description of this weakest precondition is as follows. Objects of are pairs where is a Polish space and is a predicate on . The lifting of then sends to where contains those tuples consisting of (equivalence classes of) Markov kernels , Polish probability spaces , and measure-preserving maps such that:
(1) factors as the Bayesian inversion of a measure-preserving map followed by pushforward along a random variable ;
(2) for some Polish probability space and measure-preserving map ;
(3) , and complete to a commutative square and and are conditionally independent given .
It is fruitful to compare this weakest precondition with the weakest preconditions used by existing probabilistic separation logics for measure-theoretic probability [8, 30, 41]. Points (1) and (2) in the above definition recover the usual conditions that can be found in existing work, stating that the kernel is simulated by random variable defined on an expansion of the underlying resource, and also that satisfies the postcondition . Point (3) is new and follows from our generic construction of Alloc. The strength and fiberedness of Alloc ensure that our weakest precondition has a frame rule and commutes with substitution by default—both properties that had to be imposed via additional side conditions in prior work.
8 Conclusion and Future Work
We introduced and developed the general theory of bunched fibrations and bunched monad liftings, a fibered framework for separation logic with weakest precondition. We showed that this framework captures design patterns of workers in separation logic, and introduced a new construction based on Simpson's categories with local independence structure that simplifies and clarifies existing work on intricate separation logics for measure-theoretic probability.
As future work, we hope to generalize our notion of bunched fibration to support proof-relevance, and to consider further applications of our fibered framework (e.g., to modeling step-indexed logics and logics with invariants). We also hope to relate our bunched fibrations with the theory of Dijkstra monads [45] and our liftings for local independence with the recently-introduced epiregular categories [21].
References
[1] Frederik Lerbjerg Aagaard, Jonathan Sterling, and Lars Birkedal. 2023. A denotationally-based program logic for higher-order store. Mathematical Foundations of Program Semantics (MFPS) (2023).
[2] Alejandro Aguirre, Philipp G Haselwarter, Markus De Medeiros, Kwing Hei Li, Simon Oddershede Gregersen, Joseph Tassarotti, and Lars Birkedal. 2024. Error credits: Resourceful reasoning about error bounds for higher-order probabilistic programs. Proceedings of the ACM on Programming Languages 8, ICFP (2024), 284–316.
[3] Alejandro Aguirre, Shin-ya Katsumata, and Satoshi Kura. 2022. Weakest preconditions in fibrations. Math. Struct. Comput. Sci. 32, 4 (2022), 472–510. doi:10.1017/S0960129522000330
[4] Daniel Ahman, Catălin Hritcu, Kenji Maillard, Guido Martínez, Gordon 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. 515–529.
[5] Robert Atkey. 2011. Amortised resource analysis with separation logic. Logical Methods in Computer Science (2011).
[6] Pedro H. Azevedo de Amorim. 2025. Denotational foundations for expected cost analysis. Proceedings of the ACM on Programming Languages OOPSLA (2025).
[7] Pedro H. Azevedo de Amorim, Satoshi Kura, and Philip Saville. 2025. Logical relations for call-by-push-value models, via internal fibrations in a 2-category. In Logic in Computer Science (LICS).
[8] Jialu Bao, Emannele D'Osualdo, and Azadeh Farzan. 2025. Bluebell: An alliance of relational lifting and independence for probabilistic reasoning. Proceedings of the ACM on Programming Languages 9, POPL (2025), 1719–1749.
[9] Gilles Barthe, Justin Hsu, and Kevin Liao. 2019. A probabilistic separation logic. Proceedings of the ACM on Programming Languages 4, POPL (2019), 1–30.
[10] P Nick Benton. 1994. A mixed linear and non-linear logic: Proofs, terms and models. In Computer Science Logic (CSL).
[11] Bodil Biering. 2004. On the logic of bunched implications. Master's thesis. IT University of Copenhagen.
[12] Bodil Biering, Lars Birkedal, and Noah Torp-Smith. 2007. BI-hyperdoctrines, higher-order separation logic, and abstraction. ACM Transactions on Programming Languages and Systems (TOPLAS) 29, 5 (2007), 24–es.
[13] Lars Birkedal, Rasmus Ejlers Mogelberg, Jan Schwinghammer, and Kristian Støvring. 2011. First steps in synthetic guarded domain theory: Step-indexing in the topos of trees. In LICS. IEEE Computer Society, 55–64. https://doi.org/10.1109/LICS.2011.16
[14] Lars Birkedal, Bernhard Reus, Jan Schwinghammer, and Hongseok Yang. 2008. A simple model of separation logic for higher-order store. In International Colloquium on Automata, Languages, and Programming. Springer, 348–360.
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
[15] Aleš Bizjak and Lars Birkedal. 2018. On models of higher-order separation logic. Electronic Notes in Theoretical Computer Science 336 (2018), 57–78.
[16] Stephen Brookes. 2007. A semantics for concurrent separation logic. Theoretical Computer Science 375, 1-3 (2007), 227–270.
[17] Cristiano Calcagno, Peter W O'Hearn, and Hongseok Yang. 2007. Local action and abstract separation logic. In 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007). IEEE, 366–378.
[18] Qinxiang Cao, Santiago Cuellar, and Andrew W Appel. 2017. Bringing order to the separation logic jungle. In Asian Symposium on Programming Languages and Systems. Springer, 190–211.
[19] Arthur Charguéraud and François Pottier. 2019. Verifying the correctness and amortized complexity of a union-find implementation in separation logic with time credits. Journal of Automated Reasoning 62, 3 (2019), 331–365.
[20] Pietro Di Gianantonio and Marino Miculan. 2004. Unifying recursive and co-recursive definitions in sheaf categories. In International Conference on Foundations of Software Science and Computation Structures. Springer, 136–150.
[21] Matthew Di Meglio, Chris Heunen, Jean-Simon Pacaud Lemay, Paolo Perrone, and Dario Stein. 2025. Dagger categories of relations: The equivalence of dilatory dagger categories and epi-regular independence categories. arXiv preprint arXiv:2508.01146 (2025).
[22] Robert Dockins, Aquinas Hobor, and Andrew W Appel. 2009. A fresh look at separation algebras and share accounting. In Asian Symposium on Programming Languages And Systems. Springer, 161–177.
[23] Didier Galmiche, Daniel Méry, and David Pym. 2005. The semantics of BI and resource tableaux. Mathematical Structures in Computer Science 15, 6 (2005), 1033–1088.
[24] Daniel Gratzer, Mathias Adam Møller, and Lars Birkedal. 2025. Idempotent resources in separation logic: The heart of core in Iris. In International Conference on Foundations of Software Science and Computation Structures. Springer, 45–66.
[25] Harrison Grodin, Yue Niu, Jonathan Sterling, and Robert Harper. 2024. Decalf: A directed, effectful cost-aware logical framework. In Principles of Programming Languages (POPL).
[26] Philipp G Haselwarter, Kwing Hei Li, Markus de Medeiros, Simon Oddershede Gregersen, Alejandro Aguirre, Joseph Tassarotti, and Lars Birkedal. 2024. Tachis: Higher-order separation logic with credits for expected costs. Proceedings of the ACM on Programming Languages 8, OOPSLA2 (2024), 1189–1218.
[27] Claudio Hermida. 1993. Fibrations, logical predicates and indeterminates. Ph.D. Dissertation. University of Edinburgh, UK.
[28] Claudio Hermida. 1999. Some properties of Fib as a fibred 2-category. Journal of Pure and Applied Algebra 134, 1 (1999), 83–109.
[29] Ralf Hinze and Dan Marsden. 2025. The graphical theory of monads. Journal of Functional Programming 35 (2025), e11.
[30] Shing Hin Ho, Nicolas Wu, and Azalea Raad. 2026. Bayesian separation logic: A logical foundation and axiomatic semantics for probabilistic programming. Proceedings of the ACM on Programming Languages 10, POPL (2026), 1557–1585.
[31] Bart Jacobs. 1999. Categorical logic and type theory. Elsevier.
[32] Peter T Johnstone. 2002. Sketches of an elephant: A topos theory compendium. Vol. 1. Oxford University Press. doi:10.1093/oso/9780198515982.001.0001
[33] Ralf Jung, Robert Krebbers, Jacques-Henri Jourdan, Aleš Bizjak, Lars Birkedal, and Derek Dreyer. 2018. Iris from the ground up: A modular foundation for higher-order concurrent separation logic. Journal of Functional Programming 28 (2018), e20.
[34] Ralf Jung, David Swasey, Filip Sieczkowski, Kasper Svendsen, Aaron Turon, Lars Birkedal, and Derek Dreyer. 2015. Iris: Monoids and invariants as an orthogonal basis for concurrent reasoning. ACM SIGPLAN Notices 50, 1 (2015), 637–650.
[35] Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja, and Federico Olmedo. 2018. Weakest precondition reasoning for expected runtimes of randomized algorithms. Journal of the ACM (JACM) (2018).
[36] Ohad Kammar, Paul B Levy, Sean K Moss, and Sam Staton. 2017. A monad for full ground reference cells. In 2017 32nd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). IEEE, 1–12.
[37] Shin-ya Katsumata. 2005. A semantic formulation of TT-lifting and logical predicates for computational metalanguage. In International Workshop on Computer Science Logic. Springer, 87–102.
[38] Anders Kock. 1972. Strong functors and monoidal monads. Archiv der Mathematik 23, 1 (1972), 113–120.
[39] Satoshi Kura. 2023. Higher-order weakest precondition transformers via a CPS transformation. arXiv preprint arXiv:2301.09997 (2023).
[40] Imre Lakatos. 1976. Proofs and refutations: The logic of mathematical discovery. Cambridge University Press.
[41] John M Li, Amal Ahmed, and Steven Holtzen. 2023. Lilac: a modal separation logic for conditional probability. Proceedings of the ACM on Programming Languages 7, PLDI (2023), 148–171.
[42] John M. Li, Jon Aytac, Philip Johnson-Freyd, Amal Ahmed, and Steven Holtzen. 2024. A nominal approach to probabilistic separation logic. In Proceedings of the 39th Annual ACM/IEEE Symposium on Logic in Computer Science
(Tallinn, Estonia) (LICS '24). Association for Computing Machinery, New York, NY, USA, Article 55, 14 pages. doi:10.1145/3661814.3662135
[43] Kwing Hei Li, Alejandro Aguirre, Simon Oddershedte Gregersen, Philipp G Haselwarter, Joseph Tassarotti, and Lars Birkedal. 2025. Modular reasoning about error bounds for concurrent probabilistic programs. Proceedings of the ACM on Programming Languages 9, ICFP (2025).
[44] Jean-Marie Madiot and François Pottier. 2022. A separation logic for heap space under garbage collection. Proceedings of the ACM on Programming Languages 6, POPL (2022), 1–28.
[45] Kenji Maillard. 2019. Principles of program verification for arbitrary monadic effects. Ph.D. Dissertation. École Normale Sup'erieure.
[46] Paul-André Mellies. 2009. Categorical semantics of linear logic. Panoramas et syntheses (2009).
[47] Glen Mével, Jacques-Henri Jourdan, and François Pottier. 2019. Time credits and time receipts in Iris. In European Symposium on Programming (ESOP).
[48] Eugenio Moggi. 1991. Notions of computation and monads. Information and computation 93, 1 (1991), 55–92.
[49] Peter W O'Hearn and David J Pym. 1999. The logic of bunched implications. Bulletin of Symbolic Logic 5, 2 (1999), 215–244.
[50] Miriam Polzer and Sergey Goncharov. 2020. Local local reasoning: A BI-hyperdoctrine for full ground store. In Foundations of Software Science and Computation Structures (FoSSaCS). 542–561.
[51] François Pottier, Armael Guéneau, Jacques-Henri Jourdan, and Glen Mével. 2024. Thunks and debits in separation logic with time credits. Proceedings of the ACM on Programming Languages POPL (2024).
[52] David J Pym. 1999. On bunched predicate logic. In Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158). IEEE, 183–192.
[53] David J Pym. 2002. The semantics and proof theory of the logic of bunched implications. Vol. 26. Springer Science & Business Media.
[54] John C Reynolds. 2002. Separation logic: A logic for shared mutable data structures. In Proceedings 17th annual IEEE symposium on logic in computer science. IEEE, 55–74.
[55] Michael Shulman. 2008. Framed bicategories and monoidal fibrations. Theory and Applications of Categories 20, 18 (2008), 650–738.
[56] Alex Simpson. 2017. Probability sheaves and the Giry monad. In 7th Conference on Algebra and Coalgebra in Computer Science (CALCO 2017). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 1–1.
[57] Alex Simpson. 2024. Equivalence and conditional independence in atomic sheaf logic. In Proceedings of the 39th Annual ACM/IEEE Symposium on Logic in Computer Science. 1–14.
[58] Ian David Bede Stark. 1994. Names and higher-order functions. Ph.D. Dissertation. University of Cambridge PhD thesis.
[59] Dario Stein. 2025. Random variables, conditional independence and categories of abstract sample spaces. In 2025 40th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). 472–484. doi:10.1109/LICS65433.2025.00042
[60] Ross Street. 1972. The formal theory of monads. Journal of Pure and Applied Algebra, 2, 2 (1972), 149–168.
[61] Thomas Streicher. 2018. Fibered categories à la Jean Bénabou. arXiv preprint arXiv:1801.02927 (2018).
[62] Kasper Svendsen and Lars Birkedal. 2014. Impredicative concurrent abstract predicates. In European Symposium on Programming Languages and Systems. Springer, 149–168.
[63] Nikhil Swamy, Joel Weinberger, Cole Schlesinger, Juan Chen, and Benjamin Livshits. 2013. Verifying higher-order programs with the Dijkstra monad. In ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '13, Seattle, WA, USA, June 16-19, 2013, Hans-Juergen Boehm and Cormac Flanagan (Eds.). ACM, 387–398. doi:10.1145/2491956.2491978
[64] Bohua Zhan and Maximilian PL Haslbeck. 2018. Verifying asymptotic time complexity of imperative programs in Isabelle. In International Joint Conference on Automated Reasoning (IJCAR).
[65] Noam Zilberstein, Alexandra Silva, and Joseph Tassarotti. 2026. Probabilistic concurrent reasoning in outcome logic: Independence, conditioning, and invariants. Proceedings of the ACM on Programming Languages 10, POPL (2026), 235–264.
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
A The frame-preserving core of a monad lifting
A.1 Strength
The following lemma is almost a strength for , but the right hand side uses W instead of .
LEMMA A.1. The inequality holds in the fiber for any over and over .
PROOF. As a preliminary remark, the count of the adjunction is a vertical natural transformation in . for all in the base and all . The image in of the count at is a vertical proof
We now address the lemma itself. Since we are working in a higher-order fibration, there is a characteristic morphism with true. We now derive a sequence of inequalities in the fiber over .
This concludes the proof.
PROOF OF PROPOSITION 6.3. We have already shown is a monad lifting (Lemma 6.2). By Proposition 5.10 it suffices to show . We construct a chain of logical equivalences by working backwards from our goal.
Taking and in Lemma A.1 concludes the proof.
A.2 Universality
PROOF OF PROPOSITION 6.6. We only need to describe the action on the upper half of a monad morphism drawn from PreHOMnd. Let and be higher-order bunched fibrations. Let be a monad morphism from to fibered over . We seek a fibered natural transformation
We construct it by a backwards calculation.
by defn.
G fib'd. over F cart.
reindexing in
projection law
but this follows from the monotonicity of .
PROOF OF PROPOSITION 6.7. Huber envelopes are functorial in both their adjunction and monad arguments, so this follows from Propositions 6.5 and 6.6.
PROOF OF COROLLARY 6.8. By Proposition 5.11 it suffices to construct . Isomorphisms in are always cartesian arrows. In particular, the right unitor isomorphism is cartesian over and its inverse is cartesian over . As a consequence, for any and
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
for any Y over a product . We calculate
PROOF OF LEMMA 6.9. We already have (Corollary 6.8), so we prove the other direction. Let be a bunched monad lifting and let lie over . Using the defining adjunctions from Figure 3 and the fact that , we calculate a chain of equivalent inequalities beginning with .
The last inequality follows from Proposition 5.10.
B Proof of Proposition 7.3
The monoidal product in is defined by taking independent pullbacks of cospans into . The action on morphisms is defined by:

Given two morphisms and in the slice over , their product is the dashed arrow into the independent pullback . To establish the existence of , the following diagrams show that the two morphisms from to and are independent over the morphisms from and to .

The diagram on the left is copied from above. The triangles on the side commute by assumption and the inner quadrilateral is the independent pullback used to define . The diagram in the middle performs a rearrangement and introduces an identity morphism; this makes it clear the independent pullback square for pastes with the square beneath it, which is independent by IP1, making an independent rectangle. The diagram on the right simplifies this independent rectangle, and then performs a similar operation on the remaining triangle, introducing a second identity morphism so that it becomes an independent square by IP1; the pasting of these two rectangles gives the independence square needed to define .
Each functor has action on morphisms defined by:

In this diagram the left and right rectangles depict the independent pullback of two objects x and y of along . The bottom triangle depicts a morphism from to . As with ordinary pullbacks, the action of on the morphism is to yield the dashed morphism, defined by the universal property of as an independent pullback. The only extra proof obligation is to check the independence of the two morphisms from to and with respect to the two morphisms from and to . This independence is exhibited by the following transformation of diagrams.



The diagram on the left is copied from above: the top quadrilateral is an independent pullback and the triangle commutes. The diagram in the middle pulls the bottom triangular face out front. The diagram on the right introduces an identity morphism. This shows that the original diagram is a composite of an independent pullback and a square that is independent by IP1; hence, it is independent with respect to the two morphisms from and y to c.
From these definitions, the standard proofs for pullbacks work to show the axioms of a symmetric semicartesian category hold, that each satisfies the functoriality laws, that each is strong monoidal, and that pullback forms a pseudofunctor.
C Proof that Alloc produces atomic sheaves
First note that is separated: if for some and in and some , then there is a commutative diagram of the following shape:

John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
In this diagram we have that the rhombuses are independent pullbacks, and , and and are made equal by applying and respectively. From this it follows that and witness as needed.
For the existence of amalgamations, suppose and is an -invariant element of in the sense of Simpson [56]. Form the independent pullback of against itself, giving for some . The -invariance of then implies , which gives the dashed arrows in the following commutative diagram, where all solid squares are independent pullbacks and and are made equal by and .
Let and so forms an element of . The following calculation then shows that is an amalgamation for :
D Proof of Proposition 7.9
Monotonicity reduces to showing that if the front face of a commutative cube

is an independence square, then the back face is an independence square too, and that there is an induced morphism between the independent pullbacks.
Consider the following diagrams.

By the universal property of , the front face decomposes into the diagram shown on the left. Similarly, the back space decomposes into the diagram in the middle, although we do not yet know whether the upper-left boomerang commutes. Finally, because is semicartesian (Proposition 7.3), the morphisms and form a morphism making the diagram on the right, whose shape is that of two rectangles glued together. Placing all of these diagrams into the cube gives:

The dashed morphism is defined to be the composite , making the rectangle that it is incident to commute by fiat. But now this makes the dashed morphism a morphism into an independent pullback that recovers the morphisms and when composed with the projections out of . Since the independent pullback classifies independence squares with this property, it must be that and form an independence square with respect to and .
E Proof of Theorem 7.12
First we check naturality and monotonicity.
(1) For naturality, suppose is witnessed by for some fitting into an independence square of the form just shown above, and let be an arbitrary morphism of . Taking the independent pullback of and
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
and pasting with the above square gives the independence square which, combined with naturality of , establishes as needed to show .
(2) For monotonicity, consider the following diagram:

The front face of the
square shows an independence square witnessing , and the bottom triangle shows a hypothetical new resource that is larger than . To show that this new resource also satisfies , form the right square using independent pullback. Now and are independent given the unnamed morphisms and , giving the morphism into the independent pullback and making the whole prism commute. Now the back rectangle is an independence square by IP4. Hence .
For the monad structure on ,
-
The unit is , well-defined because if then the independence square witnesses .
-
The multiplication is , well-defined because if for some coming from a tower of independence squares of the form
witnesses ([c', p, [c'', p', x]], (r, f)) ∈ then the pasting of these two squares into a rectangle witnesses ([c'', pp', x], (r, f)) ∈ .
To show that the strength map lifts to a morphism , consider the following diagram.

The solid lines depict a given witness to , consisting of some such that and some fitting into an independence quadrilateral, with bottom cospan , such that . This quadrilateral can be rearranged into an independent square with bottom cospan , as follows:

The top square is just the independent quadrilateral drawn another way, hence an independent square; the bottom square is independent by axiom IP1. Hence the pasting of these two polygons forms an independent rectangle. This gives a mediating dotted morphism above, into the independent pullback whose projections are the dashed morphisms. Now applying IP4 to the back quadrilateral and the dashed square shows that the rectangle involving is independent. Putting this together with gives as needed to lift the strength .
To show that the lifting is fibered, let be a cartesian arrow above . Unwinding what it means to be cartesian in a lax slice, this says that for any and , it holds that if and only if . We now show that for any and , it holds that if and only if .
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
so we have that . Now we have
Putting this all together, we have that (1) and (2) the outer kite of

is independent because the square is and (3) ,
which is enough to show .
F Proof of Theorem 6.13
In our proof we will implicitly use the internal higher order logic of the topos S and the resource algebra semantics of separation logic.
Functorial action Let be a morphism. We want to show that . Assuming that , we want to show that . Unfolding the definitions, we want to show that if , then . This follows by the assumption that is a monad lifting and by instantiating its functorial action to the -predicate .
Unit Assume that . We want to show that . By assumption, for every predicate , if , then . By instantiated this with the predicate , we recover what we want to prove.
Multiplication Assume that . We want to show that . Unfolding the definitions, we have to prove that if then .
Strength Assuming the usual BI semantics, when we unfold the separating conjunction, we get
The first inequality follows from the assumption that satisfies the frame rule for the resource . The last inequality follows from using the elimination rules of existential quantification – introducing free variables and – applying the assumed monotonicity of and concluding by introducing the first two RHS existential quantifications with and , respectively.
G Proof of Theorem 6.27
We approach this proof by proving a 2-categorical generalization that specializes to Theorem 6.27. At a high-level, we want to show that the Huber envelope has a natural universal that can be proved at the 2-categorical level. Let be a 2-category and an adjunction internal to . The categories and are defined as follows:
Definition G.1. The category of is defined as
-
The objects are monads over
-
The morphisms are monad morphisms.
Identity and composition are given componentwise.
Definition G.2. The category is defined as.
-
The objects are pairs of monads over and , and a monad morphism .
-
The morphisms are pairs monad liftings morphisms such that it commutes with the underlying monad morphism .
These categories can be seen as generalizations of and . We now prove the following universal property of the Huber envelope.
THEOREM G.3. The forgetful functor has a left adjoint.
PROOF. A monad is mapped to its Huber envelope . It is straightforward to establish the functionality of this operation, which we denote . We now have to show that there is a natural isomorphism , which follows from a simple calculation.
We can see that our categories of RNR structures are almost of the shape and for an appropriate underlying 2-category. We finish the proof by proving a lemma that allows us to restrict adjunctions up restrictions, in a sense we make precise now.
Definition G.4. A 1-cell is an ff-morphism if for every object , the induced functor is full an faithful.
When a 1-cell satisfies this property, we use . We now need the following lemma.
LEMMA G.5. Consider the pullback below:
If the left adjoint factors through the inclusion as a morphism , then the adjunction lifts to an adjunction .
PROOF. The unit and counit are defined using the full and faithful functors and given by postcomposition with the inclusions and . Showing that they satisfy the adjunction triangle laws follows by injectivity and the triangle laws of the adjunction .
John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
Fig. 5. Unit and multiplication strength laws
We want to finish the proof by applying the theorem and lemma above. Given a cartesian base category , consider the 2-category . We can now construct the adjunction given by the theorem above, which almost gives us the theorem we want. In order to bridge this gap, we restrict to the appropriate subcategories where we ask the right hand fibration to be a bunched fibration and the left hand fibration to be a first-order fibration, and then we apply the lemma above. In order to do so, we need to show that the left adjoint does indeed factor through the restriction. Concretely, we want to show that the Huber envelope of a strong monad is a strong monad, when the adjunction is monoidal.
LEMMA G.6. Assuming a pre RNR structure, the Huber envelope of the monad is a strong monad.
PROOF. Let . The monad structure is defined using the Huber envelope. The strength at and is the dashed morphism below, which is the composition of the other morphisms.
Where is the multiplicative part of the lax monoidal structure we can define for , which can be defined using our assumption that is left adjoint to and that it is strong monoidal, i.e. it has coherent natural isomorphisms and :
Strong monads must satisfy the following laws depicted in Figure 5. The strength laws follow from some diagram chases which we now present. In order to simplify notation, we refer to as simply T. We begin by showing that our proposed strength satisfies the unit law.

We now describe the commutativity of the diagram (*). As a reminder, the natural transformation is the lax monoidal structure of .

John M. Li, Ryan Doenges, and Pedro H. Azevedo de Amorim
We now present the multiplication diagram

We now present the proof of the diagram (*).

Fibered Separation Logic: Weakest Preconditions, Universal Constructions, and Local Independence 41 We conclude by presenting the proof of the diagram (+). (𝐿(𝐴) ⊗ 𝐿𝑅𝑇 𝐿(𝐵)) 𝐿(𝐴 × 𝑅𝑇 𝐿(𝐵)) 𝐿(𝑅𝐿(𝐴) × 𝑅𝑇 𝐿(𝐵)) 𝐿(𝑅𝐿(𝐴) × 𝑅𝑇 𝐿(𝐵)) 𝐿𝑅𝐿(𝑅𝐿(𝐴) × 𝑅𝑇 𝐿(𝐵)) 𝐿(𝐴) ⊗ 𝐿𝑅𝑇 𝐿(𝐵)) 𝐿𝑅𝐿(𝐴) ⊗ 𝐿𝑅𝑇 𝐿(𝐵) 𝐿𝑅(𝐿𝑅𝐿(𝐴) ⊗ 𝐿𝑅𝑇 𝐿(𝐵)) (𝐿(𝐴) ⊗ 𝑇 𝐿(𝐵)) (𝐿(𝐴) ⊗ 𝑇 𝐿(𝐵)) 𝐿𝑅(𝐿(𝐴) ⊗ 𝑇 𝐿(𝐵)) (𝑖𝑑⊗𝜀 ′𝑇 𝐿) 𝐿(𝜂 ′×𝑖𝑑) −1 𝐿𝜂′ −1 𝜀 ′𝐿 𝐿𝑅 −1 𝐿𝜂′⊗𝑖𝑑 (𝑖𝑑⊗𝜀 ′𝑇 𝐿) 𝜀 ′𝐿⊗𝜀 ′𝐿 𝐿𝑅(𝜀 ′𝐿⊗𝜀 ′𝐿) 𝜀 ′ (naturality) (adjunction) (adjunction) (naturality) □ Theorem 6.27 is now a simple consequence of the results above.