arXiv:2608.21271cs.PLAug 2026

Manuscript Offprint

arXiv:2608.21271

Finitary Semantics for Full Ground Local State

Orpheas van Rooij, Ohad Kammar, Sam Lindley, Cristina Matache

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ORPHEAS VAN ROOIJ, University of Edinburgh, UK

OHAD KAMMAR, University of Edinburgh, UK

SAM LINDLEY, University of Edinburgh, UK

CRISTINA MATACHE, University of Birmingham, UK

Full ground local state (FGLS) refers to dynamically allocated mutable state that allows storing ground values and references. It is a key ingredient in many imperative algorithms as it enables (cyclic) data structures. In this work, we treat full ground local state as a computational effect, focusing on one particular denotational model: Kammar et al.'s possible worlds monad on sets indexed over sets of locations.

We resolve an outstanding question regarding this FGLS monad: is it finitary? We show that the FGLS monad is not finitary by showing the existence of non-finitary computations in the monad. We then introduce a finitary submonad of Kammar et al.'s monad, give it a concrete description and show that it provides an adequate semantics for FGLS. The submonad we construct paves the way to understanding FGLS in the future via an equational axiomatization suitable for program reasoning.

CCS Concepts: • Theory of computation → Denotational semantics; Abstraction.

Additional Key Words and Phrases: local state, monads, observational equivalence, denotational semantics, computational effects, categorical semantics

1 Introduction

A ubiquitous feature of imperative programs is access to dynamically allocated mutable state: reference-based memory that permits allocation of new memory cells, as well as reading and writing from existing ones. Dynamic allocation of mutable memory is often called local state since allocated memory can only be accessed from those parts of the program that were passed the reference. In the case of full ground local state (FGLS), cells may store ground values (e.g., booleans, integers) and references, enabling us to represent imperative data structures such as cyclic linked lists. Crucially, full ground local state forbids storing functions which introduce general recursion through Landin's knot [20].

Various models for local state exist in the literature which include among others relational models built via logical relations on nominal-cpos [7, 11], step-indexed syntactic logical relations [3, 9], game semantic models [1, 19, 25], as well as monad semantics based on possible worlds [15, 24, 26].

We are concerned with possible worlds semantics that model heaps and types as sets indexed over sets of locations, together with a suitable state-like monad on the appropriate category. For the ground local state case where only ground values can be stored, heaps are of a contravariant nature: we can select smaller segments of the heap by projecting out some of the cells [24, 26]. In the full ground setting this is no longer the case: projecting out a smaller heap may result in an invalid one since the references stored in the cells may now point to undefined data, i.e., they may be dangling. Kammar et al. [15] address this by equipping heaps with a covariant structure: heaps can be extended with new data modelled via a category of instantiations that carries the data. Their FGLS monad supports:

  • Effect masking: Computations that do not depend or return references are semantically equivalent to pure values.

  • Adequacy: Denotationally equal terms are observationally indistinguishable.

[M]=[N]  ⟹  M≅obsN[M]=[N]\implies M\cong_{\mathrm{o b s}}N

Authors' Contact Information: Orpheas van Rooij, University of Edinburgh, UK, orpheas.vanrooij@ed.ac.uk; Ohad Kammar, University of Edinburgh, UK, ohad.kammar@ed.ac.uk; Sam Lindley, University of Edinburgh, UK, sam.lindley@ed.ac.uk; Cristina Matache, University of Birmingham, UK, c.matache@bham.ac.uk.

0:2

Orpheas van Rooij, Ohad Kammar, Sam Lindley, and Cristina Matache

where M, N are λ\lambda-terms that manipulate full ground references.

  • Program Equivalences: Validates desired equations such as
letrefx:=VinxM≡Mx:=V;z:=xW;M≡z:=W;x:=zV;M(1)\text{letref}x:=V\text{in}^{x}M\equiv M\qquad\qquad x:=V;z:=^{x}W;M\equiv z:=W;x:=^{z}V;M \tag{1}

where letref x:=Nx := N in MM allocates a new reference xx in MM with value VV, X:=VX := V updates the contents of reference xx with VV and xMxM states that xx does not occur free in MM.

These properties make it a useful model for FGLS and justify using it as basis for more sophisticated stores. This paper extends the metatheory of this monad by resolving an outstanding question.

Finitary presentations of a monad. In seminal work, Moggi used monads to model computational effects such as mutable state, input/output and non-determinism. The theory of algebraic effects e.g. [4, 26] refines Moggi's programme by using algebraic theories in the sense of universal algebra to characterise computational effects equationally. In this setting, the effectful behaviour of programs is described by a set of effect operations and equations between these operations. For example, non-determinism can be described by an operation or (x,y)(x, y) that is commutative, associative and idempotent.

Moggi’s monads can be recovered via the well-known correspondence between monads and algebraic theories [13, 21, 29]: finitary algebraic theories correspond to finitary monads on the category of sets. An algebraic theory is finitary when it admits a presentation whose operations are of finite arity. There is no requirement that the set of operations or equations are finite.

However, when describing a computational effect, one often seeks a presentation of the algebraic theory with a small number of intuitive operations and equations, as in the non-determinism example above. The role of the presentation is to serve as a basis for programming with the effect, via the operations, and for reasoning about effectul programs via the equations.

The goal of our line of research is to find such an algebraic presentation for the full ground local state monad of Kammar et al., for which none has been discovered yet. Roughly speaking, the FGLS monad is defined on indexed sets, rather than sets, so we would need to use a more sophisticated notion of algebraic theory, rather than the classic one, to maintain the monad-theory correspondence.

Such extensions of algebraic theories and their correspondence to monads have been developed, for example: monads with arities [8], enriched Lawvere theories [28] and parameterized algebraic theories [32]. Out of these extensions, only parametrized algebraic theories admit a syntax for specifying presentations of theories, which we are particularly interested in from a programming perspective. Moreover, both enriched Lawvere theories and parameterized algebraic theories require the monad in question to be at least finitary.

Until now, the question whether the full ground local state monad of Kammar et al. is finitary remained open. In this paper, we provide a negative answer. We then characterize a finitary submonad of the FGLS monad and give it a concrete description. Therefore, the submonad we introduce opens the way to characterizing FGLS as a parameterized algebraic theory, or as an enriched Lawvere theory, in future work. The main contributions of the paper are as follows:

(i) Non-finitarity. We show that the FGLS monad is non-finitary by showing the existence of certain non-finitary computations ( §\S 2.3). Such computations cannot be represented as terms in the programming language, and so the model has extra information which allows denotations to detect observationally undetectable differences.

(ii) Worlds, Heaps with variables and Unification. We develop the machinery needed to describe finitary FGLS computations. We introduce two-kinded worlds, heaps with variables, heap unification and matching and identify the relevant structures ( §\S 3).

0:3

(iii) Finitary FGLS monad. Using this machinery we define a finitary FGLS submonad and show that its functor and monad structure lifts from the full monad (§ 4.3). Due to its finitary nature, this monad is more amenable to equational axiomatisations. It further enjoys adequacy of the denotational semantics with respect to the operational semantics, inherited from the non-finitary monad (§ 5).

References (23)