Papers
Topics
Authors
Recent
Search
2000 character limit reached

Finitary Semantics for Full Ground Local State

Published 21 Aug 2026 in cs.PL | (2608.21271v1)

Abstract: 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.

Summary

  • The paper demonstrates that FGLS monad is not finitary but constructs a finitary submonad providing adequate semantics for a higher-order $\lambda$-calculus.
  • The finitariness question for the FGLS monad is resolved by making explicit heap properties and leveraging categorical machinery of templates, unifications, and cover.
  • The finitary submonad adheres to monad laws with finite decision trees representing computations, ensuring semantic test between world views and heap manipulation.

Overview

This paper, by van Rooij, Kammar, Lindley and Matache (University of Edinburgh and University of Birmingham), studies the denotational semantics of full ground local state (FGLS) — dynamically allocated mutable cells that may store ground values or references, but not functions. The central object of study is the possible-worlds FGLS monad of Kammar et al. [kammar2017monad], defined on sets indexed over worlds (finite sort-respecting partial functions on locations), with heaps equipped with a covariant structure via a category of instantiations. The paper resolves an open question about this monad negatively: the FGLS monad is not finitary. It then constructs a finitary submonad, gives it a concrete combinatorial description via two-kinded worlds ("templates"), heap unification, and finite covers of the heap space, proves it is indeed finitary, and shows that it yields an adequate denotational semantics for a higher-order λ-calculus with full ground references.

The motivation for finitariness is programmatic: frameworks such as parameterized algebraic theories [staton2013instances] and enriched Lawvere theories [power1999enriched] require finitary monads, so an equational axiomatization of FGLS suitable for reasoning about programs was blocked until this question was settled.

The language and the monad

The programming language λref\lambda_{ref} is a coarse-grained call-by-value λ-calculus over full ground types: reference types ref(C)\mathsf{ref}(C) for sorts CC, sums, products, and function types, where each sort CC has an interpretation ctype(C)ctype(C) as a full ground type closed under reference types only. This stratification permits cyclic data structures (e.g., boxed linked lists) while excluding Landin's-knot-style general recursion through the store. Typing judgments are parameterised by a world ww listing allocated locations; allocation (letref) performs simultaneous recursive allocation, making newly allocated references available in their own initialisation data.

Semantically, heaps cannot be contravariant as in ground local state [moggi1990abstract, plotkin2002notions], because projecting a smaller heap may leave dangling references stored in surviving cells. Instead, morphisms in the instantiation category I\mathcal{I} pair a sort-preserving injection www \to w' with a heaplet defining values for all locations in ww' not hit by the injection. The heap functor HH is then covariant, and the FGLS monad is the state-transformer construction ref(C)\mathsf{ref}(C)0, equivalently given by an end over the comma category ref(C)\mathsf{ref}(C)1. A computation at world ref(C)\mathsf{ref}(C)2 assigns a stateful value to every injection out of ref(C)\mathsf{ref}(C)3 and heap, subject to a naturality condition: only the reachable portion of the heap may be observed. The model supports effect masking, adequacy, and standard program equivalences such as commuting writes to distinct references.

Non-finitariness

A monad on ref(C)\mathsf{ref}(C)4-indexed categories is finitary when it preserves filtered colimits; for global state ref(C)\mathsf{ref}(C)5, finitariness holds exactly when ref(C)\mathsf{ref}(C)6 is finite. The authors exhibit a computation ref(C)\mathsf{ref}(C)7 that traverses the heap reachable from location ref(C)\mathsf{ref}(C)8 and returns the number of distinct encountered locations. Since ref(C)\mathsf{ref}(C)9 returns countably many values depending on the input heap, no finite presentation can express it. Formally, they consider the filtered diagram CC0 mapping CC1 to the down-set functor CC2 and show that the canonical map CC3 fails surjectivity because no finite stage determines CC4. Hence:

The FGLS monad does not preserve filtered colimits — i.e., it is non-finitary.

An important caveat stated in the paper: not every choice of interpretation function CC5 yields a non-finitary monad, but any interpretation supporting cyclic data structures will be non-finitary. The consequence is sharp: these computations are not definable in CC6, so the full monad carries information that can distinguish terms observationally indistinguishable by the language — precisely the obstruction to full abstraction. The authors also note the converse concern: adding a primitive like CC7 would expose runtime-level detail or force garbage collection, and they expect it would not materially change higher-order metatheory.

Templates, unification, and covers

To isolate the finitary fragment, the paper develops substantial categorical machinery.

Templates are two-kinded worlds: concrete locations (defined cells) and location variables (extension points). Morphisms are sort-preserving injections preserving concrete locations; concrete locations can never be mapped to variables. Two classes of morphisms matter: variable-preserving morphisms (which do not instantiate variables; these are exactly the regular monos) and variable-reflecting morphisms (which introduce no new variables). Their intersection defines allocation morphisms, modelling pure allocation. Spans admit local independent coproducts, characterised universally via independence structures [simpson2018category].

Adding instantiation data to templates yields a category CC8, on which the paper develops unification: spans of template-instantiations may fail to unify (e.g., conflicting cell contents), least unifiers need not exist — the paper gives an explicit counterexample of two incomparable general unifiers — but general unifiers (jointly surjective ones) exist and are finite up to isomorphism. Local independent coproducts, when well-defined, are themselves local independent general unifiers. Connectivity is captured by reachability from public locations, giving an orthogonal factorisation system into connected epis and disconnected regular monos; this lifts pointwise to the free finite product completion CC9, whose pushouts exist precisely because general unifiers do.

Stencils are morphisms CC0 in CC1 representing collections of heaps sharing public locations CC2; covers are finite families of stencils. Complete covers — which factor every heap assignment uniquely — constitute finite partitions of the heap space. Sorts whose full ground interpretation exists are finitely enumerable: e.g., boolList admits a complete cover enumerating its three cell shapes (nil, singleton cons, cons-with-variable-tail).

Resultlets generalise stateful values to templates with variables: a resultlet consists of an allocation morphism, a return value possibly mentioning variables, and a template heap. An evaluation is a finite family of resultlets indexed by templates. A complete cover together with an evaluation forms a finite decision tree over the heap, and realises a computation CC3 if applying it agrees with the evaluation under the unique factoring supplied by completeness.

The finitary submonad

The finitary FGLS monad CC4 is defined by restricting CC5 to those computations realisable by some complete cover and evaluation. Three results establish its structure:

  • Functoriality: the actions on return types and on world extensions preserve finitariness, using resultlet re-indexing and cover rebasing (via pushouts in CC6).
  • Monad laws: unit uses the identity cover; join requires unifying each intermediate template's allocation data with the inner computation's cover via pushouts in CC7, selecting compatible components through the connected/disconnected factorisation system, and using the hiding algebras of the original monad to prove realisation.
  • Finitarity: CC8 preserves filtered colimits. Given a finitary element of the colimit, its realising data involves only finitely many objects of the filtered diagram, which have an upper bound by filteredness; the extension map is invariant under the chosen cover/evaluation pair and inverse to the cocone.

Thus there is a strong monad morphism CC9. Because the existential quantification over covers and evaluations is non-unique, the representation is not canonical — a mild limitation of the concrete description, though harmless for semantic purposes.

Semantics and metatheory

Types are interpreted as covariant functors ctype(C)ctype(C)0, with reference types as representables. Crucially, the generic effects ctype(C)ctype(C)1, ctype(C)ctype(C)2, and recursive ctype(C)ctype(C)3 are all shown to be finitary computations: read and write exploit sort enumerations to build complete covers case-splitting on cell contents, while alloc uses the identity cover with an appropriately shaped resultlet. This means the entire term language interprets in ctype(C)ctype(C)4.

The main metatheoretic link is that at full-ground types, denotations under ctype(C)ctype(C)5 and ctype(C)ctype(C)6 coincide, and consequently for every first-order term ctype(C)ctype(C)7,

ctype(C)ctype(C)8

so adequacy of the original semantics transfers to the finitary one, along with soundness and compositionality proven by induction on derivations. At higher types the two interpretations differ, since exponentials involving the monad distinguish them.

The paper situates itself against relational logical-relations models over nominal cpos [benton2005relational], step-indexed syntactic relations [ahmed2004semantics, birkedal2011step] and Iris-style frameworks [jung2018iris], noting that such models build garbage collection reasoning into auxiliary logical relations rather than the base semantics, whereas the possible-worlds approach bakes unobservable-allocation equivalence into the model directly. Game-semantics models [abramsky1998fully, laird2008game, murawski2012algorithmic] achieve full abstraction but represent heaps implicitly and are structurally unrelated. The work also complements Polzer et al.'s hyperdoctrine-based logic over the FGLS monad.

Limitations and open questions

Several caveats bear directly on the results. First, non-finitariness depends on the interpretation ctype(C)ctype(C)9: the negative result applies to interpretations admitting cyclic structures, and the paper does not fully classify which interpretations give finitary monads. Second, the finitary monad's concrete description is non-canonical, since realising covers/evaluations are neither unique nor observable; whether an intrinsic, presentation-independent characterisation exists remains open. Third, adequacy transfers but full abstraction does not follow: the authors explicitly conjecture, without proof, that the FGLS monad is fully abstract at first-order types and suggest game-semantic techniques might establish it, with transfer to ww0 and resulting decidability of observational equivalence left as open problems. Fourth, the equational goal motivating the paper — a parameterized algebraic theory or enriched Lawvere theory presenting FGLS — is enabled but not delivered here; generalising ground-local-state equations [plotkin2002notions, staton2010completeness] to the full-ground setting must handle first-class heap values and block symmetries, both identified as non-trivial obstacles. Finally, extending the monad to cpo-valued functors to support general recursion and higher-order store is proposed but not carried out.

Conclusion

This paper settles the finitariness question for the FGLS monad negatively, identifies ww1-style traversals as the source of non-finitary behaviour, and isolates a finitary submonad through a detailed theory of two-kinded worlds, unification, and finite heap-space partitions. The submonad interprets the reference operations finitarily and agrees with the full monad on first-order terms, inheriting adequacy. Its principal significance is foundational rather than immediate: it supplies the finitary object required by parameterized algebraic theories and enriched Lawvere theories, thereby opening the route to an equational axiomatization of full ground local state — a goal the paper frames as future work rather than achieving outright.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.