Manuscript Offprint
arXiv:2610.41202Iris on Indirection Theory: Lightweight Higher-order Ghost State
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Today, semantic models of languages with concurrency and higher-order state are constructed using step-indexed predicates over resources and higher-order ghost state. There are two main lines of work for constructing such models. On the one hand, Iris provides these in full generality, at the cost of a large body of mechanised domain theory that is difficult to learn and port to new proof assistants. On the other hand, Indirection Theory is much simpler through the use of ordinary dependent types, but its foundation in separation algebra limits the expressiveness of its resource model compared to Iris-style higher-order ghost state. We resolve this conundrum by showing that Indirection Theory can be as expressive as Iris. To that end, we give a lightweight mechanisation of Indirection Theory in Lean, generalised so knots contain resources from an Iris-style resource algebra functor. We then reconstruct the Iris base logic on top of it. The advantage of this approach is in the elementary metatheory: a user can follow the whole construction without domain theory. We conduct two case studies to show that the base logic is expressive and faithful to Iris: a biorthogonal logical relation for higher-order state, and an Iris-style program logic with invariants and user-definable ghost state, complete enough to verify concurrent and higher-order programs.
Keywords: separation logic, step-indexing, indirection theory, higher-order ghost state, Iris, Lean
1 Introduction
In the semantics of programming languages, one often encounters definitions that are apparently circular, and hence not well-founded. Step-indexing breaks this circularity by stratifying the definitions by a natural number index.
For example, to define a (binary) logical relation for the untyped lambda calculus, we can state the relation on values as follows ( is the relation on expressions).
Having the recursive occurrences at makes the definition well-founded.
Despite its elegance and conceptual simplicity, explicit low-level index manipulation does not scale well, obscuring proofs with index arithmetic. Modern presentations thus hide indices behind modal logics [13, 6], which provide essential high-level facilities such as defining guarded recursive predicates, and reasoning by Löb induction. Lightweight implementations of these modal logics exist. In IxFree [26], for example, one can write the following definition instead, using the (later) modality.
For this calculus, the domain of step-indexed propositions that IxFree provides is sufficient. For more advanced language features such as state and concurrency, however, we would need a domain of propositions over heaps, and even defining one is a problem. A classic example of this occurs in a language with first-class locks [15], each guarding a resource invariant [25], a proposition describing the resources the lock protects. A naive model may be given as follows.
There is a circularity in the semantic domains: unfolding Heap and HProp in Res gives
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org. Conference acronym 'XX, Woodstock, NY
© 2018 Copyright held by the owner/author(s). Publication rights licensed to ACM.
ACM ISBN 978-1-4503-XXXX-X/2018/06
https://doi.org/XXXXXXX.XXXXXXX
where Res occurs negatively. This equation has no solution in the category of sets, and a proof assistant would reject it.
The problem of circular domain equations has been extensively studied, and has led to two main lines of work. The more well-known one is Iris [17], which solves the equations in the category of complete ordered families of equivalences (COFEs). The other is Indirection Theory, which uses “only
Foo et al.
simple, elementary mathematics” [16], i.e., ordinary dependent types, to construct a knot containing approximations of predicates.
Researchers building on these frameworks today face a tradeoff. Due to its maturity and generality, Iris is a large and complex framework, and working at its core demands deep expertise. The developers of PulseCore noted the requirement for “considerable expertise and effort in mechanized domain theory” [14] when considering a port to F★. A faithful port such as Iris-Lean [18, 12] is a similarly substantial development of about 60K lines of code. In contrast, Indirection Theory is substantially simpler (the original construction is only 400 LoC [16], though that is the core alone, without a base logic, ghost state or a program logic), and has been used successfully in the Verified Software Toolchain (VST) [3, 4] and more recently in PulseCore [14]. However, it is built on separation algebra, which restricts the model from having the full expressiveness of Iris’s higher-order ghost state: Indirection Theory-based VST “could express only limited higher-order ghost state”, motivating a reimplementation on top of Iris [24], and PulseCore implements “two primitive kinds of higher order ghost state: invariants and predicates”, relying on encodings for the others [14]. Whether these limitations are inherent or an artifact of these developments is unclear.
We show that the limitations are not inherent. To that end, we develop a lightweight mechanisation of Indirection Theory in Lean [11], generalised to carry resources from a resource algebra functor. It is lightweight in that the metatheory is elementary: a user can follow the whole construction without domain theory. We implement the Iris base logic on top of it, which is small yet expressive. The development is self-contained and compact, taking under 1,700 LoC.
To demonstrate that the base logic is faithful to Iris, we use it in two case studies: a biorthogonal logical relation for a heap-manipulating language, and a program logic for a concurrent, heap-manipulating one. The program logic is complete enough to verify concurrent and higher-order programs, as we show on several small examples.
In summary, we make the following contributions:
- A lightweight implementation of Indirection Theory in Lean, generalised to support user-definable higher-order ghost state, thus making the construction of higher-order semantic models accessible to a wider audience and clarifying the connection to Iris’s machinery (§3)
- A case study in direct use of the library: a biorthogonal logical relation for a language with higher-order state (§4)
- A reconstruction of Iris-style higher-order ghost state, impredicative invariants, and weakest preconditions atop Indirection Theory, complete enough to verify concurrent and higher-order programs (§5)
Figure 1. The primitive connectives of the Iris base logic.
2.1 The base logic
The Iris base logic [17] is a higher-order affine separation logic with two further groups of connectives (Figure 1). The first has to do with step-indexing: the later modality and an internalised equality . The second has to do with separation logic resources. asserts ownership of the resource . The persistence modality says that holds of the core of the resource at hand, a duplicable part of it. The basic update says the resource at hand can be updated to one satisfying , without invalidating any framing resource. We make this more precise in §2.3. Invariants, higher-order ghost state and fancy updates are derived from these.
2.2 From to
To see how is constructed, we begin with uniform predicates , predicates on a step index and a type of resource .
Intuitively, uniform predicates remain true (1) when there are fewer steps left to observe, and (2) on larger resources. The first condition makes them downward-closed in the step index: a remains true one step later, i.e. . The second condition makes them upward-closed under resource extension , in turn making them affine, i.e. .
To reach , we need to instantiate with some type of resource , which we have thus far left abstract. As a first approximation, we give three requirements on .
Firstly, it must have enough structure to interpret the connectives of Figure 1: composition to split resources for , a duplicable core for , and a notion of when a resource is valid to ensure does not invalidate frames. Iris packages these properties as the notion of a unital camera; more detail on this is given in §2.3. Secondly, must be able to contain propositions , which we have not yet defined. Therefore, what we instantiate with must be defined mutually recursively with .
Given is a user-chosen unital camera functor , Iris takes the fixed point of the following equations.
Unfolding, this is , a recursive domain equation. Its solution gives us .
2.3 Constructing : COFEs and UCMRAs
Making §2.2 precise requires a substantial amount of structure, almost all of it for solving the domain equation. We recall it briefly, to fix terminology, and because §3.6 compares it against what Indirection Theory needs.
Because of cardinality, no type satisfies the equation as given in the category of sets. The idea of the solver is to move to a setting of types with approximate equality, under which two elements are considered equal up to steps if they cannot be distinguished within that many steps. A solution is then a type isomorphic to its own unfolding with respect to approximate equality. An OFE provides a canonical structure for capturing this notion of approximation. Cameras then equip resources with an OFE structure. The OFE structure serves purposes beyond solving the recursive domain equations: in particular, the stronger COFE structure supports Löb induction and guarded recursive definitions.
(C)OFEs. An ordered family of equivalences is a type with an equivalence and a family of equivalences , satisfying and . Every type carrying step-indexed data must be an OFE, and every function between such types must be non-expansive: . It is contractive if the weaker already gives . An OFE may further be complete (a COFE), which gives contractive functions unique fixed points, allowing guarded recursive definitions.
Resource algebras and (unital) cameras. A type of resources satisfying the requirements of §2.2 is called a resource algebra (RA). Concretely, it is a type with a composition operation which combines two resources, a predicate which says whether a resource is valid, and a partial core operation which returns the duplicable part of a resource when it has one. A camera (CMRA) is a resource algebra whose carrier is an OFE, so that its resources inherit the corresponding notion of approximate equality. In addition, a camera is equipped with step-indexed validity , which can be viewed as the validity analogue of step-indexed equality. A unital camera (UCMRA) has an additional empty resource .
Functors and the solver. Since resources store propositions, the user does not supply a unital camera but a unital camera functor : given a COFE of propositions, builds the unital camera of resources storing them. must be locally contractive, meaning that resources built from propositions equal up to steps are equal up to steps. The solver is the theorem that such an admits the fixed point of §2.2, a COFE with .
Löb induction and guarded recursive definition. In Iris, is a COFE, which allows us to reason by Löb induction; under the hood, this corresponds to strong induction on the step-index. also supports guarded recursive definitions. In such definitions, recursive occurrences typically appear under the modality, which ensures that they are contractive and hence admit a unique fixed point.
2.4 An alternative route to
The Iris base logic (§2.1 and Figure 1) is expressive, well-understood, and widely used. We thus take as a specification, viewing the construction of §2.2 and §2.3 as one way to satisfy it. We then explore the use of Indirection Theory [16] as an alternative way to realise this base logic, in a form that suffices for common applications such as logical relations (§4) and program logics (§5). The next section (§3) gives the construction, concluding with a comparison to Iris (§3.6).
3 The Indirection Theory Library
In this section, we construct a replacement for the base logic of Figure 1: the type of propositions , standing for hereditary predicates, over a user-chosen type of resources . This is done in four layers: resources (§3.1), knots (§3.2), hereditary predicates (§3.3), and logical connectives (§3.4). §3.5 then discusses two important features of our step-indexing model: Löb induction and guarded recursive definitions. Finally, §3.6 concludes the section by comparing our construction with Iris's.
3.1 Resources
The logic we are building is a separation logic. We thus begin by recalling the notion of a resource algebra, an abstraction of the resources the propositions of our logic describe. An RA is a type of resources equipped with a composition operator , a validity predicate , and an operation ("partial core"), satisfying the laws of Figure 2. Resource algebra inclusion is defined as .
Foo et al.
Figure 2. Resource algebra laws.
Composition is associative and commutative. Validity is closed "downward", so subparts of a valid resource are also valid. Some resources may be duplicated and shared freely: a is duplicable if . pcore a is the duplicable part of a, if it exists. The fourth law says a contains its core, and the fifth that the core is its own core. Both of these together imply that the core is duplicable. The last law says that the core is monotone: if a is included in b, the core of a is included in the core of b.
A separation logic also needs a resource standing for ownership of nothing. A unital resource algebra (URA) is a resource algebra with such an element, . The unit is valid ( ), is the identity under composition ( ), and is its own core. The unit is included in every resource, so by monotonicity every element of a URA has a core, which we denote by core a.
In a separation logic with higher-order ghost state, a resource may contain a proposition of the logic, which itself describes a resource. To break the cycle, we must abstract over the type of propositions. Later, we will tie the knot by choosing to be the type of propositions being defined.
Next, it is not enough to only parameterise resources over , as we will need to work with approximations of the propositions stored in them. We must be able to weaken these approximations without changing the structure of a resource. This leads us to the (new) notion of a resource algebra functor (RAF), a type . is the type of resources containing propositions , and has an operation satisfying the laws of Figure 3, which are that is functorial (first two) and commutes with all the resource algebra operations (next three).
Figure 3. Resource algebra functor laws.
A unital resource algebra functor is simply a resource algebra functor where is a unital resource algebra. The last law of Figure 3 lets us derive that map preserves the unit, i.e. , which would otherwise have to be assumed.
3.2 Knots
We now have resources that store propositions of an arbitrary type , but not yet the type of propositions itself.
Propositions should be predicates on resources, and resources should store propositions, so the type we want would have to satisfy . This has no solution in set theory. Iris solves a variant of this equation in the category of COFEs. We will take a more elementary route, based on the idea of working with approximations of propositions.
The idea is to assign every proposition a level . A proposition of level is a predicate on resources storing propositions of level . At level 0, there are no lower levels to refer to, so there is a single trivial proposition. Intuitively, the level says how good an approximation a proposition is, or how much information it has. More concretely, it measures how deeply a proposition can inspect the propositions stored in the resources it describes.
One more refinement is required. A proposition true at level must remain true at every lower level, as it contains “more” information. However, a predicate on level-n resources says nothing about resources at lower levels. We therefore pair each predicate with its own “truncation” to the level below, so that a level-n proposition is really a sequence of n predicates of successively smaller levels.
We now make this precise, building up to the propositions of the logic ( ). Let be a (user-chosen) resource algebra functor. We write for a valid resource of . We then define a type of “raw” predicates at a level:
The first element of the pair in the recursive case is the “truncation” of the predicate, while the second element is the predicate itself. Thus these predicates are over resources containing the (raw) predicates of the level below, the first step towards tying the knot as promised earlier.
RawPredAt is a type family, i.e. with one type per level, but we would like a type of propositions usable at every level. The next step towards that is to hide the level using a dependent pair. A knot is hence a level and a valid resource of that level.
For a knot , we write for its level and for its resource. We also name the type of predicates over knots.
The two types are related by a projection and an embedding. projects a predicate over knots onto a level- one, retaining its value at every knot with . embeds a level- predicate as a predicate over knots that is false at levels . The two operations satisfy
Differences from the original construction [16] are in the pervasive use of RA validity, and the use of a concrete knot and stratify/unstratify, rather than the abstract squash/unsquash.
3.3 Hereditary predicates
A proposition true of a knot should remain true as the knot is approximated further or gains resources. We laid some groundwork for the former earlier in RawPredAt, but nothing yet ensures that a predicate over knots (RawPred) will respect either. We now define these two ways in which knots may change. The predicates closed under them, hereditary predicates, will be the propositions of the logic.
Aging. The first way a knot changes is by aging, which approximates it one level further. A proposition that holds of a knot should continue to hold once the knot is aged, since an aged knot carries strictly less information. Because the level strictly decreases, recursion through stored propositions is well-founded, which is what gives the logic and Löb induction.
Aging a knot from level to replaces every stored proposition by its truncation. Truncation of a RawPredAt simply projects its first component (). Because a knot contains a resource algebra functor, we can use its map to age all its stored propositions. We can therefore define the function as follows.
We write to mean “ aged by one level is , i.e. . and are its reflexive-transitive and transitive closures. strictly decreases the level, while never increases it.
Resource extension. The second way a knot changes is by gaining resources. A proposition that holds of a resource should continue to hold of a larger resource, which is what makes the logic affine and validates the frame rule.
Concretely, a knot may gain a frame at its own level.
Composing the two gives us a monotonicity relation:
Hereditary. A predicate is hereditary when it is closed under .
was not part of the original construction [16], but is present as the join order in MSL [4]. is Iris's monotonicity condition.
3.4 The base logic
Having defined knots and hereditary predicates, we can finally define the connectives of the base logic (Figure 4).
Figure 4. Definition of the connectives of the base logic.
Entailment, conjunction, disjunction, and quantifiers are pointwise. Implication quantifies over the -successors of , which is what makes it hereditary. Separating conjunction splits the resource at the knot's own level. The magic wand quantifies over -successors and over frames, again to be hereditary. The basic update modality is the primitive for updating ghost resources in the presence of a frame. Persistence evaluates its argument at the core of the resource. Later evaluates its argument at every knot strictly below the current level. Internal equality of propositions holds at when both agree at every knot at or below 's level. The except-0 modality , meaning “ at every level above ”, is derived, and is used in §5.
Ownership is the only construct that differs significantly from Iris: Iris's takes a fixed resource , but here the resource depends on the level, so a single does not suffice. Here, takes instead a coherent family of resources : one resource per level, with a coherence condition saying that it is compatible with aging:
This is a sufficient condition to prove that is hereditary. The definition in Figure 4 reads: holds at a knot when the resource at 's level, , is included in .
We also overload the notation for the case where is an element of a resource algebra , rather than a coherent family. A resource algebra can be turned into a resource algebra functor using the constant resource algebra functor
Foo et al.
whose map ignores its first argument. Coherence is then trivial by the definition of . We thus write for when comes from a resource algebra embedded via a constant functor; §4 and §5 both rely on this for the resources that do not depend on the level.
3.5 Löb induction and guarded recursion
The logic of hereditary predicates enjoys Löb induction, strong induction on the level of the knot, as well as guarded recursion. Definitions such as the weakest precondition of §5 are recursive, and are taken as the fixed point of a contractive function on families of propositions indexed by a type (the arguments of the recursive definition).
This intuitively means that recursive occurrences of the family being defined are guarded by . Every contractive has a fixed point, , obtained by recursion on the level of the knot.
3.6 Comparison with Iris
The differences between our construction and Iris's have been discussed throughout §2 and this section. We recap them here.
Solving the domain equation. Iris defines for any unital camera , and obtains by solving (§2.3). Requiring a single type isomorphic to its own unfolding is what necessitates the category of COFEs and the solver of America and Rutten [2]. We define for any unital resource algebra functor , and obtain the resources of each level by recursion on , storing the propositions of level . Requiring a type per level is what allows us to get away with an ordinary recursive definition, without the solver, at the cost of the level being part of every knot.
Propositions. Iris propositions are predicates on , so the index and the resource are independent. Lowering the index leaves the resource unchanged. Ours are predicates on , so the resource depends on the level. Lowering the level maps the resource by .
Resources. The user of Iris supplies a unital camera functor, so resources are OFEs and have step-indexed equality and validity . The user of our logic supplies a unital resource algebra functor (§3.1) instead, so resources only have ordinary equality and a single validity predicate.
Ownership. Iris's takes a single : iRes, since the type of a resource does not depend on the index. The same is used at every index. Ours takes a coherent family
(§3.4), since the type of a resource depends on the level. The resource is used at level .
Internal equality. Iris's internal equality works on both propositions and resources, as they are both OFEs. Ours works on propositions only, with first-order resources handled with Leibniz equality.
4 Case Study: Logical Relations
Our first case study uses the library directly, without the program logic of §5. We formalise a binary logical relation for an untyped, call-by-value, stateful lambda calculus, extending the biorthogonal construction of Balik et al. [7] with a heap.
A heap is a finite, partial mapping of locations to live cells or tombstones (which represent deallocated locations). For a location , is a tombstone and is a live cell holding . Allocation deterministically chooses a fresh location, dereferencing and updating require a live cell, and deallocation replaces a live cell with a tombstone. Configurations are pairs of a heap and a closed expression. Evaluation contexts specify left-to-right call-by-value evaluation. We write for the expression obtained by filling the hole of with .
4.1 Biorthogonal logical relations
A binary logical relation is a useful device for proving contextual equivalence, a strong form of program equivalence under which no enclosing program context can distinguish two expressions by their observable behaviour. The observable behaviour we use here is termination: both expressions either terminate or do not terminate. To capture this notion, we define an approximation relation over two configurations as follows. If the expression in is already a value, then the expression in must terminate. If instead takes a step to , must hold later. The observation relation is in both directions.
The recursive occurrence of is guarded by , so its body is contractive, allowing to be defined using the library's fixed-point operator (§3.5). The basic update permits ghost state to be updated between operational steps. We use ghost state to define the notion of related heaps next.
4.2 Related heaps
To relate two heap-manipulating programs, we must relate the two heaps they execute on. Intuitively, the locations in the two heaps should correspond, so we maintain a finite, partial bijection from locations in the left heap to locations in the right.
We record this bijection using the authoritative map resource algebra, which supports reasoning about a shared map. One owner may hold the complete map as the authoritative source of truth, while others hold fragments: knowledge of specific entries in the map. Fragments can be duplicated and distributed freely, but they must all remain compatible with the authoritative map; an update of the authoritative map must therefore preserve every fragment.
It is represented as a pair of an exclusive, optional map and a part of that map. Exclusivity ensures that there can be at most one authoritative map at a time. An element of this resource algebra is valid if the fragment component is included in the authoritative component, whenever the authoritative component is present. and denote full and fragmentary ownership of and respectively.
To allow several owners to agree on a single value, we use the agreement resource algebra . Any number of owners may hold for a value and freely duplicate it, but two such instances are valid only if they refer to the same value.
The bijection is tracked using an authoritative map of agreements of locations . asserts ownership of the authoritative finite map recording the mapping, and fragment assertions record that .
where is the pointwise lifting of to agreement values. The use of ensures that two fragments for the same left location agree on the right location.
The mapping between locations must be well-formed. We state this using an assertion , meaning that is injective (required for the map to be a bijection), tied locations occur in their respective heaps, and both cells are either live or deallocated.
Given a candidate value relation , related heaps must also contain related values at every pair of tied locations. We denote this condition by .
The heap relation is then the packaging of these three conditions.
There are two complementary reasons for the in . Technically, and are defined mutually recursively: depends on through , while is eventually used to define . The makes this recursive definition well-founded. Intuitively, this also makes sense because, if two locations are related, we must first spend one step reading the locations before we can inspect their contents and determine that the resulting values are related. Thus, the values obtained from related locations are related later.
is preserved by all heap manipulations programs may perform.
Updating tied locations requires the values they are updated with to be related one step later. We write for an update of to a live cell containing . Similarly, tied locations can be freed, which replaces both cells with the tombstone none. Only allocation of tied locations changes the ghost state: a basic update extends and produces a new tied fragment.
4.3 The logical relation
We can now define the relations on contexts and expressions, which are also mutually recursive with . They depend on the observation relation , and so need to talk about related heaps.
is with a on . They differ in that is the main expression relation and must also relate values, in which
Foo et al.
case no step occurs and and are evaluated now, so no later can be afforded. is for expressions guaranteed to take a step, and is used to define .
For lambda abstractions, relates those whose applications are in when given -related arguments. This relation must be persistent, since a pair of related lambda abstractions may be used any number of times. Additionally, the arguments can only be used after one step of -reduction, so they only need to be related later. Locations are related if they are tied. All other mismatched value shapes are unrelated.
4.4 Open terms
To deal with open terms, we define a relation on substitutions: two substitutions are related when they map every variable to -related values. relates open terms by closing them under related substitutions.
With the relations defined, we can state and prove the fundamental theorem.
The restriction reflects the fact that the fundamental theorem is stated for source programs. Source programs cannot contain literal locations, which only arise at runtime. Moreover, a literal location cannot be interpreted without a pair of heaps, which is not available in the definition above.
5 Case Study: Iris on Indirection Theory
In our second case study, we reconstruct an Iris-style program logic [17] using the base logic. We cover three main aspects: invariants, user-definable ghost state, and weakest preconditions. The object language is HeapLang, an untyped, call-by-value, concurrent lambda calculus with a heap. Its small-step operational semantics reduces a thread pool (a list of expressions) over a heap.
5.1 The ghost heap
The first thing we will need is an abstract heap to model various assertions about ownership of ghost state. We thus call this heap the ghost heap, and define it to be a finite map from ghost names to cells. The type of cells is parameterized by a resource algebra functor .
is itself a unital resource algebra functor. We can thus instantiate Knot and HPred with ; we do so for the remainder of this section.
For convenience when working with , we define ownership of a single ghost cell by specialising to a singleton heap. Given a location and a coherent family , the family is also coherent, and we define
We follow the same convention as for : we also write when is an element of a resource algebra , assuming that has been lifted to a resource algebra functor via the constant functor .
It remains to provide a usable type of cells. Intuitively, it is a sum of a number of resource algebras. We introduce each resource algebra as it is needed below, before defining their sum. A more precise definition can be found in the formal development. Our goal in this section is to provide intuition for how the ghost heap is organised and made extensible, and how it supports the resulting program logic.
5.2 The concrete heap
Our model must provide meaning to the points-to assertion , which denotes ownership of a piece of the concrete heap, the actual heap that programs execute on. The concrete heap occupies a single cell of the ghost heap, at a distinguished location . We formulate the concrete heap as a resource algebra over a set of values . We define it as a composition of resource algebras.
The authoritative component models the whole concrete heap, while fragments model points-to claims to individual cells. Since map values are exclusive, two points-to facts cannot refer to the same location. Concretely, points-to assertions represent ownership of a fragment
and the state interpretation is a new assertion denoting ownership of the entire concrete heap
where is its pointwise lifting to exclusive values. is used to define the weakest precondition later, but does not normally appear in user-level proofs.
The use of an authoritative map over exclusive values ensures that fragments are consistent with the whole heap.
Owning both allows updates
and if , there is no compatible fragment mentioning , allowing allocation.
These rules capture precisely the intuition about concrete heap manipulation in a program, and they are used to prove weakest precondition rules for heap-manipulating operations.
5.3 Invariants
Next, our model gives meaning to invariants: named assertions whose resources are maintained throughout execution. An invariant body can be any proposition. In particular, may own resources from the concrete heap or ghost state. Invariants are moreover impredicative: may itself mention invariants, including the invariant of which is the body.
asserts that the invariant named by has body . Invariants may be allocated from , yielding with a fresh name . They may be opened to obtain , and must later be closed, relinquishing the resources and reestablishing the invariant. An invariant cannot be opened while it is already open, for soundness.
To implement this, ghost heap cells must contain at least three more resource algebras. First, invariants themselves, where is a location in the ghost heap storing an approximation of . Since is a proposition, we use the resource algebra functor to map its approximation to a resource algebra. Second, an invariant registry, the set of allocated invariant names, stored at the distinguished location . Third, a mask, a finite or cofinite set of invariant names.
We can now understand the definition of . It records the agreement that is the invariant body stored at , as well as ownership of a fragment of the registry indicating that the name has been allocated.
We then define a new assertion wsat to keep track of which invariants are allocated and govern their allocation, opening, and closing. It plays an analogous “global” role to SI, and is likewise used to define the weakest precondition.
wsat owns the registry, a finite set of allocated invariant names . regAuth asserts exclusive ownership of the registry, similar to SI.
Each invariant is in one of two states.
The first disjunct represents a closed invariant: wsat owns its body (under ) together with a disabled token, which
may be understood as the obligation to close it. The second represents an open invariant, where the body and disabled token are absent, and wsat has an enabled token, indicating that the invariant is currently open. The protocol allows these tokens and resources to move in and out of wsat. An invariant cannot be opened while it is already open, since two copies of enabled cannot be owned for the same mask. Both tokens are defined for masks using ownership of disjoint masks, and require two additional dedicated ghost names, and .
5.4 User-defined ghost state
Having seen the setup of the concrete heap and invariants, we can now define the cell type mentioned when we first talked about the ghost heap.
As a first approximation, we define it as the sum of the four resource algebras used by the program logic. InvF depends on the type of propositions stored in a cell, so it is a functor. We turn the others into functors using the constant resource algebra functor , and define:
, a sum of resource algebra functors, is a resource algebra functor. Thus BaseCell(V) is also a resource algebra functor.
This would be sufficient if we only ever worked with the aforementioned kinds of ghost state. However, the motivation for having a rich vocabulary of resource algebras is that users can compose them, to build new problem-specific abstractions, like transition systems or protocols. These would have to be stored in the ghost heap as well. As such, the cell type of the ghost heap should be somehow left extensible.
We do this by following the recipe given in Data types à la carte [29]. To illustrate this, suppose the user wants to extend the ghost heap with a proposition-free resource algebra . A natural first step would be for the user to replace BaseCell(V) with
Assuming the sum is nested to the right, the injection of the invariant resource into BaseCell(V) is
whereas the corresponding injections into are
The path for InvF changed by one inr constructor. This would be a problem if existing client code asserted ownership of an invariant by mentioning the path concretely, as it would then have to be changed to accommodate the extension. The same issue would occur for 's path if we further extended with another sum.
A cofinite set is one whose complement is finite. The set of all invariant names is cofinite because its complement is empty.
The DisjMask resource algebra allows splitting/joining these sets disjointly.
Foo et al.
A better approach would be to abstract over the concrete path by synthesising an injection and proofs of associated laws. Hence, we use a typeclass , with one main operation , which must be shown to respect the resource algebra structure. The proofs are assembled compositionally by typeclass search.
Clients then only need instances to assert that the functors they need are present in an ambient cell type , rather than requiring to be exactly or some other concrete type. Consequently, for the resource algebra from earlier, the ownership assertion a requires only the membership . The added component may more generally be a resource algebra functor , allowing user-defined ghost state to contain propositions.
This is one place where our development diverges from Iris, which uses (conceptually) a list of ghost heaps, making ghost names tuples of a list index and a heap location, instead of an extensible sum. We take this route largely for simplicity.
5.5 Weakest preconditions
Following Iris, the weakest precondition is the assertion
The resources threaded through the weakest precondition are given by . If is a value, the postcondition must hold immediately, while the resources in are preserved. Otherwise, must be reducible, and for every possible new configuration must satisfy the weakest precondition with preserved. The list contains the threads forked during a reduction step. Each forked thread must satisfy a weakest precondition with postcondition , meaning that it must execute safely. Its return value is discarded.
The argument is a mask specifying the invariants that may be opened during the execution of the expression. It must be restored after each physical step. Forked threads begin with no invariants open and therefore use the full mask . The waive the obligations in the reducible case at index 0, where there are no steps remaining and we cannot distinguish stuck expressions from reducible ones. The allows ghost state updates both before and after a logical step. A common example is proving that an invariant is preserved by an atomic step: the first basic update opens the invariant and obtains its body under , the physical step consumes the , and the second update can then reestablish and close the invariant. The both synchronises program steps with logical steps and guards the recursion.
We may then define the Hoare triple as
and use it to derive all the standard program logic rules.
5.6 Verified programs
We validate the program logic on simple but characteristic examples. First, parallel increment, where two threads perform a non-atomic increment on a shared location. We prove specifications of varying strength using different techniques, including a plain invariant, and a three-state protocol using a combination of the one-shot and fraction resource algebras.
Second, we verify Landin's Knot [21]: both by ordinary induction and by Löb induction [8], where an invariant owns the self-referential cell. The resulting proof exercises impredicative invariants, persistent higher-order specifications, and guarded recursion together.
5.7 Discussion
This case study validates the claim that Indirection Theory can serve as an alternative foundation for Iris. To this end, the construction of the program logic intentionally follows Iris closely, to sufficient depth that we can reconstruct a program logic usable for verifying simple programs.
The proofs are written using Lean tactics for rewriting logical entailments, permitting separating conjunctions, frame inference, biabduction, and ramified Hoare triples. They therefore resemble conventional [10] interactive separation-logic proofs; an equivalent to the Iris Proof Mode [19] is not implemented. Reuse of the Iris-Lean implementation of it [12] is likely to be possible, given that our separation logic is a standard affine BI logic.
6 Related Work
From step-indexing to higher-order separation logic. Step-indexing originated as a technique for modelling recursive types [5] and higher-order state [1]. Appel et al. [6] then abstracted it into the operator of a modal logic, a presentation that later works [13] established as a standard way of handling step-indexing. Hobor et al. [15] used this approach to build a higher-order concurrent separation logic, later generalising the construction to Indirection Theory [16, 4]. Meanwhile, Birkedal et al. [9] developed a different construction, based on ultrametric spaces, and used the theorem of America and Rutten [2] to solve recursive domain equations. This construction, adapted to (complete) ordered families of equivalences and (unital) cameras, is the foundation of Iris [17].
Indirection Theory. Indirection Theory was introduced by Hobor et al. [16] and mechanised in Rocq in the Mechanized Semantic Library (MSL) [4]. MSL was later extended and used as the foundation of VST [3]. We mostly follow the MSL development, with the main difference being that we replace separation algebras with Iris-style resource algebras. Additionally, MSL supports some minor generalisations beyond our presentation. For example, MSL supports functors of mixed variance, whereas ours are covariant. These extensions are straightforward and not central to our development, so we omit them for ease of implementation and presentation.
PulseCore. The closest system to ours is PulseCore [14], an impredicative concurrent separation logic embedded in F★. It also uses Indirection Theory as a foundation for reasons of simplicity, and arrives at a very similar “base logic” of hereditary predicates, with two main differences.
The first is in the construction of the knot. PulseCore recursively defines the resources rather than the propositions, and a stored proposition is a dependent function over knots of lower level rather than a sequence of approximations. They report that F★’s extensional type theory makes this a shorter construction; the advantage does not carry over to Lean’s intensional type theory, so we follow the classic approach of defining propositions recursively.
A second difference is in what the knot is instantiated with. PulseCore fixes the higher-order ghost state to a heap whose cells hold only either an invariant or a stored predicate. First-order ghost state is contained in a separate heap and other higher-order ghost state is obtained by encoding. Its authors note that they could “make the construction parametric in the supported higher-order ghost state cells and their associated functors”, but decided against “the API complexity of extra parameters”. This is the generalisation we make, in parameterising the knot by an arbitrary resource algebra functor, so higher-order ghost state is user-definable, like in Iris.
Other practical differences in PulseCore outside of its model construction are that it is meant for intrinsic proofs about F★ programs, so the step index is decreased by ghost code rather than by steps of the reduction relation, and a Löb induction principle is not exposed at all, since F★’s native well-founded recursion suffices.
VST. VST [3] is a program logic for C, and the most substantial system built on Indirection Theory. VST’s resource model is closely tied to CompCert [22]’s memory model, so that the program logic can be proven sound against CompCert’s operational semantics. Verification in VST then combines with CompCert’s compiler correctness to give guarantees about compiled code. In particular, VST’s resource is a heap, in which a location holds either a value with a permission, or a predicate, such as a function’s specification or a lock’s invariant.
Mansky [23] brought some of Iris’s ghost state into VST to increase its expressiveness, while keeping its resource model tied to CompCert. Ghost state was added as a second
component of the resource
and invariants were derived from it in the same work. However, this approach still could not fully support higher-order ghost state, due to universe inconsistencies.
This limitation motivated Mansky and Du [24] to rebuild VST’s program logic on top of Iris, from which higher-order ghost state is then inherited. Both works left open the question of whether Indirection Theory can be made as expressive as Iris. Our work addresses this question.
Iris and Iris-Lean. Iris [17] is the frontier of higher-order concurrent separation logic, with a large body of features and applications built on it, and is mechanised in Rocq. Iris-Lean [18, 12] is a faithful port of Iris to Lean, and, to our knowledge, the only other mechanised step-indexed logic in Lean. It follows Iris’s construction directly, up to minor differences between the two proof assistants, so the comparison to Iris’s base logic in §2 and §3 applies to it unchanged.
7 Conclusion
Our aim in this work was to clarify and generalise the foundations of a higher-order separation logic, thereby making the construction of higher-order semantic models and program logics accessible to a wider audience, and spurring the development of more expressive verification tools. To this end, we presented a Lean implementation of Indirection Theory, generalised to support Iris-style higher-order ghost state. Its construction is elementary and uses only dependent types, without domain theory or category theory. It should thus serve as a recipe for implementing similar models. We demonstrated the expressiveness of the resulting separation logic for constructing both logical relations and an Iris-style program logic, and also clarified the relationship between Indirection Theory and Iris’s model.
Some parts of Iris remain to be reconstructed. The most immediate direction for future work is to reconstruct the recent work on discharging ▷ on these foundations: later credits [28], and the physical-step modality [27].
References
[1] Amal J. Ahmed, Andrew W. Appel, and Roberto Virga. 2002. A stratified semantics of general references. In 17th IEEE Symposium on Logic in Computer Science (LICS 2002), 22-25 July 2002, Copenhagen, Denmark, Proceedings. IEEE Computer Society, 75. doi:10.1109/LICS.2002.1029818. [2] Pierre America and Jan J. M. M. Rutten. 1989. Solving reflexive domain equations in a category of complete metric spaces. J. Comput. Syst. Sci., 39, 3, 343–375. doi:10.1016/0022-0000(89)90027-5. [3] Andrew W. Appel. 2012. Verified software toolchain. In NFM (LNCS). Alwyn Goodloe and Suzette Person, (Eds.) Vol. 7226. Springer, 2. doi:10.1007/978-3-642-28891-3_2. [4] Andrew W. Appel, Robert Dockins, and Aquinas Hobor. 2010. Mechanized semantic library. https://vst.cs.princeton.edu/msl/. (2010).
Foo et al.
[5] Andrew W. Appel and David A. McAllester. 2001. An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst., 23, 5, 657–683. doi:10.1145/504709.504712.
[6] Andrew W. Appel, Paul-André Melliès, Christopher D. Richards, and Jérôme Vouillon. 2007. A very modal model of a modern, major, general type system. In POPL. Martin Hofmann and Matthias Felleisen, (Eds.) ACM, 109–122. doi:10.1145/1190216.1190235.
[7] Patrycja Balik, Dariusz Biernacki, and Piotr Polesiuk. 2025. Untyped logical relations at work: control operators, contextual equivalence and full abstraction. In Proceedings of the Workshop Dedicated to Olivier Danvy on the Occasion of His 64th Birthday (OLIVIERFEST '25). Association for Computing Machinery, Singapore, Singapore, 128–141. doi:10.1145/3759427.3760374.
[8] Lars Birkedal and Ales Bizjak. 2023. Lecture notes on Iris: higher-order concurrent separation logic. Lectures notes, September. https://iris-project.org/tutorial-material.html.
[9] Lars Birkedal, Kristian Støvring, and Jacob Thamsborg. 2010. The category-theoretic solution of recursive metric-space equations. Theor. Comput. Sci., 411, 47, 4102–4122. doi:10.1016/J.TCS.2010.07.010.
[10] Arthur Charguéraud. 2024. Separation Logic Foundations.
[11] Leonardo de Moura and Sebastian Ullrich. 2021. The lean 4 theorem prover and programming language. In Automated Deduction - CADE 28 - 28th International Conference on Automated Deduction, Virtual Event, July 12-15, 2021, Proceedings (Lecture Notes in Computer Science). André Platzer and Geoff Sutcliffe, (Eds.) Vol. 12699. Springer, 625–635. doi:10.1007/978-3-030-79876-5\37.
[12] Iris-Lean developers. 2026. Iris-lean. https://github.com/leanprover-community/iris-lean. (2026).
[13] Derek Dreyer, Amal Ahmed, and Lars Birkedal. 2009. Logical step-indexed logical relations. In LICS. IEEE Computer Society, 71–80. doi:10.1109/LICS.2009.34.
[14] Gabriel Ebner, Guido Martínez, Aseem Rastogi, Thibault Dardinier, Megan Frisella, Tahina Ramananandro, and Nikhil Swamy. 2025. Pulsecore: an impredicative concurrent separation logic for dependently typed programs. In PLDI. ACM. https://www.microsoft.com/en-us/research/publication/pulsecore-an-impredicative-concurrent-separation-logic-for-dependently-typed-programs/.
[15] Aquinas Hobor, Andrew W. Appel, and Francesco Zappa Nardelli. 2008. Oracle semantics for concurrent separation logic. In Programming Languages and Systems, 17th European Symposium on Programming, ESOP 2008, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2008, Budapest, Hungary, March 29-April 6, 2008. Proceedings (Lecture Notes in Computer Science). Sophia Drossopoulou, (Ed.) Vol. 4960. Springer, 353–367. doi:10.1007/978-3-540-78739-6\27.
[16] Aquinas Hobor, Robert Dockins, and Andrew W. Appel. 2010. A theory of indirection via approximation. In POPL. Manuel V. Hermenegildo and Jens Palsberg, (Eds.) ACM, 171–184. doi:10.1145/1706299.1706322.
[17] Ralf Jung, Robbert Krebbers, Jacques-Henri Jourdan, Ales Bizjak, Lars Birkedal, and Derek Dreyer. 2018. Iris from the ground up: A modular foundation for higher-order concurrent separation logic. J. Funct. Program., 28, e20. doi:10.1017/S0956796818000151.
[18] Lars König. 2022. An Improved Interface for Interactive Proofs in Separation Logic. Ph.D. Dissertation. Karlsruher Institut für Technologie (KIT).
[19] Robbert Krebbers, Jacques-Henri Jourdan, Ralf Jung, Joseph Tassarotti, Jan-Oliver Kaiser, Amin Timany, Arthur Charguéraud, and Derek Dreyer. 2018. Mosel: A general, extensible modal framework for interactive proofs in separation logic. Proc. ACM Program. Lang., 2, ICFP, 77:1–77:30. doi:10.1145/3236772.
[20] Robbert Krebbers, Ralf Jung, Ales Bizjak, Jacques-Henri Jourdan, Derek Dreyer, and Lars Birkedal. 2017. The essence of higher-order concurrent separation logic. In Programming Languages and Systems
- 26th European Symposium on Programming, ESOP 2017, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2017, Uppsala, Sweden, April 22-29, 2017, Proceedings (Lecture Notes in Computer Science). Hongseok Yang, (Ed.) Vol. 10201. Springer, 696–723. doi:10.1007/978-3-662-54434-1\26.
[21] P. J. Landin. 1964. The mechanical evaluation of expressions. Comput. J., 6, 4, 308–320. doi:10.1093/COMJNL/6.4.308.
[22] Xavier Leroy, Sandrine Blazy, Daniel Kästner, Bernhard Schommer, Markus Pister, and Christian Ferdinand. 2016. CompCert – a formally verified optimizing compiler. In ERTS 2016: Embedded Real Time Software and Systems. SEE.
[23] William Mansky. 2022. Bringing iris into the verified software toolchain. CoRR, abs/2207.06574. arXiv: 2207.06574. doi:10.48550/ARXIV.2207.06574.
[24] William Mansky and Ke Du. 2024. An iris instance for verifying compcert C programs. Proc. ACM Program. Lang., 8, POPL, 148–174. doi:10.1145/3632848.
[25] Peter W. O'Hearn. 2007. Resources, concurrency, and local reasoning. Theor. Comput. Sci., 375, 1-3, 271–307. doi:10.1016/J.TCS.2006.12.035.
[26] Piotr Polesiuk. 2017. Ixfree: step-indexed logical relations in coq. In CoqPL.
[27] Thomas Somers, Jonas Kastberg Hinrichsen, Lennard Gäher, and Robert Krebbers. 2026. Building blocks for step-indexed program logics. In Proceedings of the 15th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2026, Rennes, France, January 12-13, 2026. Kathrin Stark, Yannick Zakowski, Nikhil Swamy, and Nicolas Tabareau, (Eds.) ACM, 248–263. doi:10.1145/3779031.3779095.
[28] Simon Spies, Lennard Gäher, Joseph Tassarotti, Ralf Jung, Robbert Krebbers, Lars Birkedal, and Derek Dreyer. 2022. Later credits: resourceful reasoning for the later modality. Proc. ACM Program. Lang., 6, ICFP, 283–311. doi:10.1145/3547631.
[29] Wouter Swierstra. 2008. Data types à la carte. J. Funct. Program., 18, 4, 423–436. doi:10.1017/S0956796808006758.