Skip to main content
Erschienen in:

Open Access 2025 | OriginalPaper | Buchkapitel

Two-sorted algebraic decompositions of Brookes’s shared-state denotational semantics

verfasst von : Yotam Dvir, Ohad Kammar, Ori Lahav, Gordon Plotkin

Erschienen in: Foundations of Software Science and Computation Structures

Verlag: Springer Nature Switzerland

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

Dieses Kapitel präsentiert eine umfassende Analyse von Brookes denotationaler Semantik des gemeinsamen Staates, wobei der Schwerpunkt auf seiner Zersetzung mittels algebraischer Effekte liegt. Das Modell zeichnet sich durch seine Kompositionalität, Vielseitigkeit und ein hohes Maß an Abstraktion aus, was es zu einem Eckpfeiler der denotationalen Semantik für Sprachen mit Nebenwirkungen macht. Die Autoren stellen eine zweisortierte algebraische Theorie vor, die das Modell in Schichten zerlegt, die unterschiedliche Arten der Interaktion zwischen einem Programmfragment und seiner gleichzeitigen Umgebung repräsentieren. Diese Zersetzung ermöglicht einen modulareren und prinzipienbasierteren Ansatz, um über den gleichzeitigen gemeinsamen Zustand nachzudenken, und adressiert die Beschränkungen früherer Modelle. Das Kapitel untersucht auch die Darstellung des Brookes-Modells anhand von Spurensätzen und bietet einen detaillierten Vergleich mit anderen Ansätzen, wobei die einzigartigen Vorteile der vorgeschlagenen Methode hervorgehoben werden. Darüber hinaus wird in dem Text das Potenzial diskutiert, dieses Rahmenwerk zu erweitern, um fortschrittlichere Features und Effekte bei gleichzeitiger Programmierung zu modellieren, was eine vielversprechende Richtung für zukünftige Forschungen bietet.

1 Introduction

We decompose Brooke’s pioneering denotational model of concurrent shared state under preemptive interleaving [6] using algebraic effects [30]. This model possesses several desirable features in the area of denotational models for programming languages with concurrent features. (I) It is based on traces, an elementary sequential gadget. (II) It is fully compositional, as in traditional denotational semantics for shared-state [e.g. 15, 17]. Each syntactic programming construct, including parallel composition, has a corresponding semantic operation combining the meanings of its constituents. Such full compositionality contrasts with some recent models in this area that require additional ‘semantic post-processing’: some form of quotient, pruning of auxiliary mathematical constructs, reasoning up/to behavioural equivalence; or capture only sequential blocks, reasoning about the parallel composition on a separate layer [e.g. 7, 8, 19, 21]. (III) Subsequent variations and extensions [4, 38, 39], as well as adaptations to relaxed memory models [12, 13, 21], attest to its versatility, making it a cornerstone in the denotational semantics for concurrent languages with side-effects. (IV) It achieves a high level of abstraction, evident in the many compiler transformations that the model supports, including the most common memory access introductions and eliminations, and the laws of parallel programming. Moreover, Brookes showed the model to be fully abstract in a language extended with the await construct, which blocks execution until all memory locations contain a given tuple of values, and then atomically updates them to contain another tuple of values. This construct is not a natural programming construct, but is clearly suggested by Brookes’s semantics.
Plotkin and Power’s modern theory of algebraic effects [30] refines Moggi’s monadic approach [26] with algebraic theories. The algebraic approach informs the monadic structure by identifying semantic counterparts to syntactic constructs and axiomatising their semantics equationally. The monadic structure emerges through the well-established connection between algebraic theories and monads [23] via representation theorems. For example: global state emerges by axiomatising memory lookup and update [30] and a representation theorem involving the state monad; non-determinism emerges by axiomatising semi-lattices and a representation theorem involving the powerdomains [15, 28]; and so on. The algebraic perspective may offer insights into the making of the denotational semantics. It can suggest methods for combining different effects and modularly augment a semantics with a given computational effect [17].
The connection between algebraic effects and concurrency has long been emphasised. For example, the ability to use algebraic effects, without any axioms, and their effect handlers [3, 32, 33] to allow users to define their own schedulers was the original motivation for their implementation in the OCaml programming language [9, 10, 35]. Nonetheless, exhibiting abstract models such as Brookes’s algebraically via equational axiomatisation of syntactic constructs has proved challenging. Our own previous algebraic model [11] invalidates a key transformation, reflecting a fundamental limitation.
To overcome this limitation, we use multi-sorted algebraic theories, a direction that was raised in personal discussions since the earliest work on algebraic effects [30]. A multi-sorted algebraic term decomposes into layers. Our two sorts represent two modes of interaction between a program fragment and its concurrent environment. A “hold” sort (\(\bullet \)) provides a reasoning layer in which the environment may not interfere, whereas in the “cede” sort ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figa_HTML.gif ) it may. We provide two operators that switch between these sorts. Our core idea is to axiomatise these operators as a closure pair, an established order-theoretic special Galois-connection, the dual to the domain-theoretic embedding-projection pairs [1]. Additionally, we axiomatise strict distributivity of the closure pair over non-determinism. The remaining axioms, all in the hold sort, are strikingly independent from these axioms. In our shared-state theory https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figb_HTML.gif , the remaining axioms are precisely those of non-deterministic global state.
We prove, twice over, that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figc_HTML.gif recovers Brookes’s model in the cede sort. First, using sets of traces akin to Brookes’s, we define a representation of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figd_HTML.gif . The representation recovers Brookes’s model via the adjunction that forgets the hold sort. Second, we define three algebraic theories for Brookes’s await and its sequential variant, relating them to global-state, shared-state, and each other via embeddings and equivalences. The theory for concurrent await is straightforwardly represented by Brookes’s model, and embeds in the cede sort of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fige_HTML.gif .
Caveats In our development, we opt for mathematical simplicity whenever possible. For example, we use countable-join semilattices instead of finite-join semilattices to represent non-determinism. This choice streamlines the development leading up to the representation theorem, allowing us to use countable sets instead of finitely generated ones. We also do not treat recursion to avoid the complexity that a domain-theoretic account incurs. The resulting model—identical to Brookes’s—coincides with the elided domain-theoretic model over discrete pre-domains. This model also supports iteration (i.e. while-loops) without change thanks to countable-joins. It also supports first-order recursion without change by equipping it with a domain-theoretic structure. These compromises let us focus on the core concepts, and provide a relatively elementary exposition and a clear presentation of the underlying idea, motivating future inquiry.

2 Overview

Equational theories study terms constructed from algebraic operators (§3.1). In Plotkin and Power’s algebraic theory of effects, the operators represent fundamental program effects, and their arguments represent continuations. Equational axioms reflect fundamental relationships between the operators. The equations that hold in the theory, reflecting the semantics as a whole, are those that follow from its axiomatic presentation by equational logic (§3.2).
In the global-state theory, a theory for sequential stateful computation, the operators https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figf_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figg_HTML.gif represent updating and looking up bits in memory. For example, consider the global-state term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figh_HTML.gif . After updating \(\texttt {y}\) to \(0\), the computation looks \(\texttt {y}\) up: if it finds \(0\), it returns 3; if it finds \(1\), it updates \(\texttt {x}\) and \(\texttt {y}\) to \(1\) in succession, then returns 7. Between the update and the lookup, the value at \(\texttt {y}\) cannot change. Therefore, the computation finds the value \(0\), and takes the left-hand continuation. The global-state axiom () https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figi_HTML.gif reflects this fact. By (), \({\textsf {U}}_{\texttt {y},0}{\textsf {L}}_{\texttt {y}}( 3,{\textsf {U}}_{\texttt {x},1}{\textsf {U}}_{\texttt {y},1}7 ) = {\textsf {U}}_{\texttt {y},0} 3\) holds in global state.
A representing monadic model for an equational theory (§3.3) interprets the algebraic operators as corresponding operations over the model’s domain; such that each term, up-to equality in the theory, is represented uniquely in the domain. Interpretations respect the theory; that is, applying an operation to representations of terms results in the representation of the corresponding operator applied to said terms: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figj_HTML.gif . For example, global-state terms are represented by memory-manipulating functions in the state-monad model. This model interprets update by precomposing a state update https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figk_HTML.gif ; and interprets lookup by passing the input memory state https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figl_HTML.gif along to the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figm_HTML.gif -continuation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fign_HTML.gif . In this way, global state recovers the (historically precedent) state monad.
The state monad does not account for concurrent interference. The monad underlying Brookes’s denotational semantics does, by using sequences of transitions to denote potential behaviours (§6.1). Each transition https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figo_HTML.gif in sequence means that the computation, by relying on exclusive access to the memory at state https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figp_HTML.gif , can guarantee to provide the state https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figq_HTML.gif and yield to the environment.
Following the tradition of algebraic effects, we wish to recover Brookes’s model using an equational theory for shared state. This is rather straightforward using a single-sorted theory \(\textsf {B}\)6.3) in which transitions appear as operators. However, this theory is dissatisfying, for two reasons. (I) Transitions do not correspond to familiar programming constructs, but to Brookes artificial await construct. (II) Conceptualising shared state as global state with concurrent interference, we expect the global-state effects to be present in a theory of shared state, and the equations between them to hold when interference is prohibited.
A more appropriate approach adds an operator \({\textsf {Y}}\) to global state for yielding control to the environment. Otherwise, the computation has exclusive access to memory. This direction lead to a Brookes-like model [11]. However, unlike Brookes’s model, it does not validate the Irrelevant Read Introduction (IRI) program transformation, which introduces a read instruction that possibly yields to the environment and discards the value it read. The IRI transformation is useful as a stepping stone to other practical transformations, such as common-subexpression elimination from conditionals, and consequently loops. Invalidating IRI seems to be a fundamental limitation of the yield-operator approach, as we show in the extended manuscript [14, §A]. In retrospect, we can pinpoint the issue to \({\textsf {Y}}\) both releasing exclusive access to memory, and acquiring it back. Our key insight is that the mode of computation that cedes access to memory needs to be explicit, decomposing \({\textsf {Y}}\) into a pair of mode-switching operators.
The remaining structure falls into place straightforwardly and naturally, in our proposed two-sorted theory for shared state https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figr_HTML.gif4). Each sort represents a computation mode: hold \((\bullet )\) represents the computation’s exclusive access to memory; cede https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figs_HTML.gif represents positions in which the environment may interfere. Each operator has a sort and expects each continuation to have a specific sort. In https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figt_HTML.gif , update https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figu_HTML.gif and lookup https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figv_HTML.gif are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figw_HTML.gif -sorted continuations, allowing us to reason about interference-free stateful interactions.
The theory https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figx_HTML.gif also supports non-deterministic choice in both sorts. For example, the term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figy_HTML.gif either updates \(\texttt {x}\) to \(1\) and returns 2, or updates \(\texttt {x}\) to \(1\) and returns 5. We axiomatise https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figz_HTML.gif such that each operator distributes over non-deterministic choice, e.g. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figaa_HTML.gif . We order terms by potential behaviours \((l \ge r) :==(l = l \vee r)\), a partial-order for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figab_HTML.gif -equality (§3.2).
The mode-switching operators of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figac_HTML.gif are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figad_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figae_HTML.gif . That is, \(\mathop {\lhd }\) is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figaf_HTML.gif -sorted and expects a \(\bullet \)-sorted continuation, and vice versa for \(\mathop {\rhd }\). We think of them as delimiting atomic blocks, or acquiring and releasing an abstract global lock. We axiomatise them in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figag_HTML.gif by strict distributivity over countable joins, i.e. () https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figah_HTML.gif and () https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figai_HTML.gif ; and:
  • (\( {\mathop {\lhd }\mathop {\rhd }y} = {y} \)). An empty atomic block has no observable effect.
  • (\( {\mathop {\rhd }\mathop {\lhd }x} \ge {x} \)). Fusing atomic blocks eliminates potential interference.
These axiomatise \(\mathop {\lhd }\) and \(\mathop {\rhd }\) as an (insertion)-closure pair [e.g. 1].
Each https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figaj_HTML.gif -term denotes a set of sort-delimited traces (§5.1), which generalise Brookes’s traces. For example, \(t:=={\textsf {U}}_{\texttt {y},0}\mathop {\rhd }\mathop {\lhd }{\textsf {L}}_{\texttt {y}}( 3,{\textsf {U}}_{\texttt {x},1}{\textsf {U}}_{\texttt {y},1}\mathop {\rhd }7 )\) denotes a set that includes https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figak_HTML.gif . Indeed, we can read off a corresponding computation from \(t\), initially holding the lock in the state \(\left( {\begin{smallmatrix}\texttt {x}\mapsto 1 \\ \texttt {y}\mapsto 1 \end{smallmatrix}}\right) \) of both bits \(1\): the computation updates \(\texttt {y}\) to \(0\), then yields to the environment before looking \(\texttt {y}\) up; finding \(1\), it updates \(\texttt {x}\) and \(\texttt {y}\) to \(1\), then releases the lock and returns 7. Brookes’s original traces correspond to those delimited by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figal_HTML.gif on both ends.
With these traces we define our two-sorted generalisation of Brookes’s model, and prove that it represents https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figam_HTML.gif5.2). The https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figan_HTML.gif -sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figao_HTML.gif -valued fragment (§6.2), which represents the “block-closed” terms, is Brookes’s original model (§6.1).
We also provide an algebraic perspective on the representation, by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figap_HTML.gif -embedding (§6.4) the transitions-theory \(\textsf {B}\) into https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figaq_HTML.gif6.5). This embedding maps https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figar_HTML.gif to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figas_HTML.gif , where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figat_HTML.gif is defined by global-state operators (§5.2).

3 Preliminaries

We present a standard treatment of countably-infinitary multi-sorted equational theories and their free models [e.g. 2, 37], straightforwardly generalising the single-sorted case by assigning sorts to functions and their arguments. The reader may choose to skim/skip this section, consulting it as necessary.

3.1 Terms

We define the logical language of multi-sorted equational logic. The basic vocabulary of multi-sorted algebra is parameterised by a set \({{\textbf {sort}}} \) whose elements https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figau_HTML.gif we call sorts. We will mostly focus on the single-sorted case ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figav_HTML.gif ) and the two-sorted case ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figaw_HTML.gif ). A \({{\textbf {sort}}} \)-scheme https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figax_HTML.gif is a countable sequence of sorts from \({{\textbf {sort}}} \), i.e. a finite sequence https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figay_HTML.gif of length n, or countably infinite sequence https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figaz_HTML.gif of length \(\omega \), where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figba_HTML.gif for all i. For example: the empty scheme https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbb_HTML.gif of length 0; and the constant schemes https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbc_HTML.gif of length https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbd_HTML.gif . We write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbe_HTML.gif for the scheme https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbf_HTML.gif .
A \({{\textbf {sort}}} \)-sorted signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbg_HTML.gif consists of a set of operators https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbh_HTML.gif and an arity assignment https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbi_HTML.gif . For https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbj_HTML.gif with https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbk_HTML.gif , we write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbl_HTML.gif . The operator \(O\) will allow us to construct a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbm_HTML.gif -sort term with a tuple of terms, with the \(i^{\text {th}}\) subterm having sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbn_HTML.gif . For single-sorted arities ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbo_HTML.gif ), we write \(O: \alpha \) for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbp_HTML.gif . A signature is a set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbq_HTML.gif and a \({{\textbf {sort}}}_{\Sigma }\)-sorted signature we also denote by \(\Sigma \).
We will use the following signature to model non-deterministic choice:
Example 1
The join semilattice single-sorted signature \(\texttt {J}\) consists of two operators: join \(\vee : 2\), i.e. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbr_HTML.gif ; and bottom \(\bot : 0\) , i.e. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbs_HTML.gif .    \(\square \)
To simplify the formulation of our representation theorem later, we generalise the signature to countable non-deterministic choice operators:
Example 2
The countable-join semilattice single-sorted signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbt_HTML.gif consists of an https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbu_HTML.gif -ary choice operator https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbv_HTML.gif for every https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbw_HTML.gif . In particular, the signature \(\texttt {J}\) is included with \(\alpha = 2\) (join) and \(\alpha = 0\) (bottom).    \(\square \)
The final example demonstrates the treatment for multiple sorts:
Example 3
The finite dimensional transformations signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbx_HTML.gif consists of a sort for each pair of natural numbers https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figby_HTML.gif , an identity operator https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figbz_HTML.gif for each https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figca_HTML.gif , and, for each triple \(m,n,k\in \mathbb {N}\), a composition operator https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcb_HTML.gif .    \(\square \)
A signature generates a language of algebraic terms as follows. A \({{\textbf {sort}}} \)-family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcc_HTML.gif is an assignment of a set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcd_HTML.gif , to each sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figce_HTML.gif . We identify https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcf_HTML.gif , and use a set-like notation to specify families, e.g. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcg_HTML.gif is the two-sorted family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figch_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figci_HTML.gif . We can turn every \({{\textbf {sort}}} \)-family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcj_HTML.gif into the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figck_HTML.gif equipped with the injections https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcl_HTML.gif . This construction is a special case of the Grothendieck construction, and lets us track the distinction between sets and families.
For a signature \(\Sigma \) and \({{\textbf {sort}}}_{\Sigma }\)-family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcm_HTML.gif , define the \({{\textbf {sort}}}_{\Sigma }\)-family of \(\Sigma \)-terms over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcn_HTML.gif : https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figco_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcp_HTML.gif inductively:
Here, the elements https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcr_HTML.gif , written https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcs_HTML.gif , represent variables of sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figct_HTML.gif  . We may drop the set-brackets left of a trunstile, e.g. write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcu_HTML.gif ; and omit the sorts, especially in the single-sorted case, e.g. write \(x, y \vdash _{\texttt {J}} x \vee \bot \). For https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcv_HTML.gif , we write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcw_HTML.gif to define \(\psi \) as \(t\), e.g. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcx_HTML.gif .
A \({{\textbf {sort}}} \)-sorted map https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcy_HTML.gif is a \({{\textbf {sort}}} \)-indexed tuple of functions between the corresponding sets: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figcz_HTML.gif , for every https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figda_HTML.gif . Our development utilises sorted maps extensively. A (simultaneous) substitution https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdb_HTML.gif is a sorted function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdc_HTML.gif , specifying which https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdd_HTML.gif -term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figde_HTML.gif to substitute for each variable https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdf_HTML.gif . Each such substitution determines a sorted map https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdg_HTML.gif inductively, which we write in post-fix notation:

3.2 Equational logic

A https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdi_HTML.gif -sorted \(\Sigma \)-equation in context https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdj_HTML.gif is a pair https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdk_HTML.gif of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdl_HTML.gif -sorted \(\Sigma \)-terms over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdm_HTML.gif . We write this situation as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdn_HTML.gif  , or just \(l = r\), and call l the left-hand side (LHS) and r the right-hand side (RHS) of the equation. A presentation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdo_HTML.gif consists of a signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdp_HTML.gif and axioms: a set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdq_HTML.gif of \(\Sigma \)-equations.
Example 4
The join semilattice presentation \(\textsf {J}\) consists of the signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdr_HTML.gif of example 1, and the axioms \(\text {Ax}_{\textsf {J}}\) below:
Example 5
The countable-join semilattice presentation \(\textsf {V}\) consists of the signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdt_HTML.gif of example 2, and the axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdu_HTML.gif :
Example 6
The finite dimensional transformations presentation \(\textsf {M}\) consists of the signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdw_HTML.gif of example 3 and the axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdx_HTML.gif below, suppressing the sort indices (each axiom scheme includes every possible instantiation):
Figure 1 presents the deductive system called equational logic. We say that a presentation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figdz_HTML.gif proves an equation, writing https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figea_HTML.gif  , when it is derivable from https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figeb_HTML.gif using these standard equational reasoning rules, namely: reflexivity, symmetry, transitivity, use of an axiom, substitution, and congruence. This logic is monotone: assuming more axioms allows us to prove more equations. The algebraic theory of a presentation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figec_HTML.gif is the smallest derivation-closed set of equations containing the axioms. We denote the theory of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figed_HTML.gif by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figee_HTML.gif as well.
Fig. 1.
Multi-sorted equational logic with countable arities
Example 7
We can prove https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figef_HTML.gif using an instance of and reflexivity with the following instance of congruence:
When a presentation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figeh_HTML.gif proves the semi-lattice axioms in one of its sorts https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figei_HTML.gif  , then the encoding https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figej_HTML.gif of inequations as equations in this sort is a preorder that is a partial order w.r.t. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figek_HTML.gif -equality, i.e. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figel_HTML.gif .
We encode \((\ge )\) similarly. Due to the monotonicity property of equational logic, once we have included an axiomatisation of semi-lattices through a subset of the axioms, we may proceed to postulate inequations.
We also use a generalisation of distributivity axioms [18], reproducing familiar arithmetic distributivity equations such as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figem_HTML.gif , the distributivity of \((\cdot )\) over \(\max \) in the right-hand-side position. The extended manuscript [14, §B] details the straightforward, but technical generalisation. The main message is as follows. In a given presentation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figen_HTML.gif , if all operators distribute over binary joins in every position, the congruence rule is valid for inequations:
If a presentation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figep_HTML.gif supports semi-lattices in every sort and they distribute over binary joins in every positions, then we say that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figeq_HTML.gif supports inequational reasoning. The theory of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figer_HTML.gif then admits Bloom’s logic for ordered algebraic theories [5]. We let future work determine the most appropriate variety of inequational logic [29].
Going forward, all of our presentations support inequational reasoning in this sense, and all operators distribute over arbitrary non-empty joins, not just the binary ones. Moreover, they are all strict: \(O( \bot , \dots , \bot ) = \bot \) for every operator https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figes_HTML.gif . Such theories ‘absorb’ side-effects when their continuations diverge, an inherent ‘partial correctness’ property of Brookes’s model.

3.3 Algebras and models

After presenting the proof theory—equational logic—let’s turn to the model theory of universal algebra. A \(\Sigma \)-algebra \({\textbf {A}}\) consists of a \({{\textbf {sort}}}_{\Sigma }\)-family \(\underline{{\textbf {A}}} \in {\textbf {Set}}^{{{\textbf {sort}}}_{\Sigma }}\), the carrier, and an assignment https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/648523_1_En_18_Figet_HTML.gif , for each operator https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figeu_HTML.gif , of an operation over this carrier: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figev_HTML.gif .
Example 8
For any set \(X\), define the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figew_HTML.gif -algebra https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figex_HTML.gif by taking the carrier to be the set of countable (finite or infinite) \(X\)-subsets \(\underline{{\textbf {V}}X} :==\mathcal {P}^{\aleph _0} ( X )\), and interpret choice as union https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figey_HTML.gif .    \(\square \)
Example 9
Define the \(\texttt {M}\)-algebra \({\textbf {M}}\) by taking the carrier to be the set of real-valued matrices of the corresponding dimensions, \(\underline{{\textbf {M}}}_{{\textbf {Hom}}\left( m,n \right) } :==\mathbb {M}^{\mathbb {R}}_{m\times n}\), interpret the identity https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figez_HTML.gif as the identity matrix, and composition https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfa_HTML.gif as matrix multiplication.
Let \({\textbf {A}}\) be an \(\texttt {M}\)-algebra. Define the opposite algebra \({{\textbf {A}}}^\textsf{op}\) by exchanging dimensions. So \(\underline{{{\textbf {A}}}^\textsf{op}_{{\textbf {Hom}}\left( m,n \right) }} :==\underline{{\textbf {A}}}_{{\textbf {Hom}}\left( n,m \right) }\), the same identity https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfb_HTML.gif , and reversing composition https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfc_HTML.gif .    \(\square \)
Example 10
(term algebra). The \(\Sigma \)-terms with variables from https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfd_HTML.gif carry a canonical algebra structure https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfe_HTML.gif , given by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figff_HTML.gif , with each \(O\)-term constructor as the corresponding \(O\)-operation: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfg_HTML.gif .    \(\square \)
A \(\Sigma \)-algebra homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfh_HTML.gif is a sorted-function \(\varphi : \underline{{\textbf {A}}} \rightarrow \underline{{\textbf {B}}}\) that preserves the operations: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfi_HTML.gif .
Example 11
Transposing real-valued matrices \(( - )^\intercal : \mathbb {M}^{\mathbb {R}}_{m\times n} \rightarrow \mathbb {M}^{\mathbb {R}}_{n\times m}\) is a homomorphism \(( - )^\intercal : {\textbf {M}}\rightarrow {{\textbf {M}}}^\textsf{op}\), by the well-known identity \(( A\cdot B )^\intercal = B^\intercal \cdot A^\intercal \).    \(\square \)
A \(\Sigma \)-algebra allows us to interpret every \(\Sigma \)-term, by assigning values to its variables. Formally, let \({\textbf {A}}\) be a \(\Sigma \)-algebra. An https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfj_HTML.gif -environment in \({\textbf {A}}\) is a sorted function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfk_HTML.gif . Given such an environment, interpret terms by induction:
Example 12
(substitution). An https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfm_HTML.gif -environment in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfn_HTML.gif amounts to a substitution, and interpreting terms in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfo_HTML.gif amounts to substitution.    \(\square \)
Example 13
(evaluation homomorphism). Evaluation using an https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfp_HTML.gif -environment https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfq_HTML.gif in a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfr_HTML.gif is a homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfs_HTML.gif .    \(\square \)
A \(\Sigma \)-algebra \({\textbf {A}}\) validates the equation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figft_HTML.gif when evaluation in all environments equates its sides: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfu_HTML.gif for all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfv_HTML.gif . We then write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfw_HTML.gif . A https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfx_HTML.gif -model is an algebra validating all of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfy_HTML.gif . The soundness theorem of equational logic states that every https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figfz_HTML.gif -model validates all the equations in the algebraic theory of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figga_HTML.gif .
Example 14
Referring to previous examples, the algebras \({\textbf {V}}X\) are \(\textsf {V}\)-models, the algebras \({\textbf {M}}\) and \({{\textbf {M}}}^\textsf{op}\) are \(\textsf {M}\)-models, and algebras of terms are \(\emptyset \)-models.    \(\square \)
Example 15
Consider the \(\Sigma _{\textsf {J}}\)-algebra \({\textbf {A}}\) for which the carrier is the set of natural numbers \(\underline{{\textbf {A}}} :==\mathbb {N}\), join interprets as addition https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgb_HTML.gif , and bottom as zero https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgc_HTML.gif . This is not a \(\textsf {J}\)-model, since, taking https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgd_HTML.gif with \(ex= 1\), we get https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figge_HTML.gif ; and so https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgf_HTML.gif .    \(\square \)
We end this section with representations of free models. These are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgg_HTML.gif -models whose elements represent the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgh_HTML.gif -terms up-to provable equality in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgi_HTML.gif .
A https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgj_HTML.gif -model https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgk_HTML.gif over a family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgl_HTML.gif consists of a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgm_HTML.gif -model \({\textbf {A}}\) and an https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgn_HTML.gif -environment in it https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgo_HTML.gif . A free https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgp_HTML.gif -model https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgq_HTML.gif over a family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgr_HTML.gif is then a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgs_HTML.gif -model over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgt_HTML.gif such that every environment in every https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgu_HTML.gif -model https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgv_HTML.gif extends uniquely along \(\operatorname {return }\) to a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgw_HTML.gif -homomorphism \(e^{\#}: {\textbf {A}}\rightarrow {\textbf {B}}\), i.e., for all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgx_HTML.gif , we have: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgy_HTML.gif . We then say that the algebra https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figgz_HTML.gif represents https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figha_HTML.gif -environments via the assignment https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighb_HTML.gif , the corresponding representation.
The algebraic theory of effects [30] emphasises the role free models play in denotational semantics for programming languages with effects. In particular, given a free https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighc_HTML.gif -model over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighd_HTML.gif for every family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighe_HTML.gif , one standardly obtains a monad suitable for the denotational semantics of a language with computational effects conforming to the operators in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighf_HTML.gif .
Example 16
For any set \(X\), the \(\texttt {V}\)-algebra \({\textbf {V}}X\) given by the countable powerset in example 8 represents \(X\)-environments; together with https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighg_HTML.gif it forms a free \(\textsf {V}\)-model over \(X\). The representation assigns https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighh_HTML.gif to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighi_HTML.gif , defined https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighj_HTML.gif ; how it enumerates \(D\) doesn’t matter since https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighk_HTML.gif is a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighl_HTML.gif -model. The data https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighm_HTML.gif is a monad.    \(\square \)

4 Shared state

To define the equational theory of shared state, we first recall the standard, single sorted (non-deterministic) global state theory \(\textsf {G}\) [17, 25, 30]. The variant we present here has countable non-determinism, and the global state operators manipulate a common memory store https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighn_HTML.gif with a finite set of locations https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figho_HTML.gif each storing a bit https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighp_HTML.gif . A larger finite set of storable-values would not be conceptually different. Infinite sets of storable-values or locations work similarly with more involved representation theorems. In concrete examples, we let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighq_HTML.gif and use non-bracketed vectors for stores, e.g. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighr_HTML.gif denotes https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighs_HTML.gif .
The signature \(\Sigma _{\textsf {G}}\) consists of the countable-join semilattice operators (example 2), as well as two kinds of memory-access operators: lookup operators \({\textsf {L}}_{\ell } : 2\), to look a location https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fight_HTML.gif up and branch according to the value found; and update operators \({\textsf {U}}_{\ell ,b} : 1\), to update a location \(\ell \in \mathbb {L}\) to the value https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighu_HTML.gif . The global state axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighv_HTML.gif consists of the countable-join semilattice axioms (example 5), as well as the following:
The induced algebraic theory \(\textsf {G}\) includes axioms of less succinct presentations of the same theory [25]. For example, lookup also distributes over binary join, so the theory admits inequational reasoning; consecutively looking the same location up can be merged, e.g. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighx_HTML.gif ; and other combinations of looking-up and updating different locations commute, e.g. for any https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighy_HTML.gif we have https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fighz_HTML.gif .
Our two-sorted presentation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figia_HTML.gif of shared state extends global state. Its sorts are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figib_HTML.gif . The hold sort \((\bullet )\) represents an uninterrupted sequence of memory accesses, whereas the cede sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figic_HTML.gif allows control to pass to the environment. The operators and the arities of the signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figid_HTML.gif consist of a copy of \(\Sigma _{\textsf {G}}\) at \(\bullet \), a copy of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figie_HTML.gif at https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figif_HTML.gif , and new operators https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figig_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figih_HTML.gif .
The intuitive reading for algebraic effects is from the outside in. With this intuition, one interpretation of the operators \(\mathop {\lhd }\) and \(\mathop {\rhd }\) is to acquire and release a global lock. The hold sort (\(\bullet \)) represents the lock being held by one of the threads in the program. The cede sort ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figii_HTML.gif ) represents points in the execution in which one of the threads in the concurrent environment may acquire the lock. The sorts ensure exclusive access to the lock, and therefore to the store. In an alternative interpretation, these operators delimit atomic blocks; their sorts prevent nesting.
The shared state axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figij_HTML.gif include a copy of the (non-deterministic) global state axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figik_HTML.gif at \(\bullet \) and a copy of the countable-join semilattice axioms \(\text {Ax}_{\textsf {V}}\) at https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figil_HTML.gif . In particular, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figim_HTML.gif proves the semi-lattice axioms in both sorts. It further includes standard strict distributivity axioms for the new unary operators:
With these axioms, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figio_HTML.gif supports inequational reasoning, which represents the semantic refinement relation used to validate program transformations [e.g. 11].
Finally, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figip_HTML.gif axiomatises \(\mathop {\lhd }\) and \(\mathop {\rhd }\) as an (insertion)-closure pair [e.g. 1]:
They are compatible with the global-lock interpretation:
  • ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figir_HTML.gif ). Acquiring and immediately releasing the lock has no effect on the sequence of effects that can occur as a result of arbitrary interleavings.
  • (\( {\mathop {\rhd }\mathop {\lhd }x} \ge {x} \)). Releasing and immediately acquiring the lock only allows more behaviours. The environment may or may not interleave there.
To summerise, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figis_HTML.gif .
Example 17
The \(\Sigma _{\textsf {S}\!\!\textsf {S}}\)-equations appearing below are named after corresponding transformations that may or may not be valid, depending on the setting (e.g. is there concurrency, and under what assumptions), all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figit_HTML.gif -sorted over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figiu_HTML.gif :
Intuitively, Irrelevant Read Intro & Elim should be valid in our setting, as looking a value up is not observable by the environment, and the computation itself disregards the value. Write Elim should be valid too, because it is possible that the environment does not look \(\ell \) up at the interference point between the updates on the LHS, covering the behaviour denoted by the RHS. On the other hand, Write Intro should be invalid in our setting because only on the LHS can a concurrently running thread look \(\ell \) up and find \(b_1\). Formally, we will show https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figiw_HTML.gif does not prove Write Intro in example 25. Here we show https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figix_HTML.gif proves the other two:

5 Representation

We now establish the representation theorem describing a free https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figiz_HTML.gif -model over any https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figja_HTML.gif . Following Brookes [6], we use sets of traces to denote behaviours.

5.1 Sorted traces

A sorted trace starts with a sort ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjb_HTML.gif or https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjc_HTML.gif ) followed by a non-empty sequence of state transitions, and ending in a sorted value. The initial sort in the trace and the initial store in each transition represent assumptions the trace relies on from its concurrent and sequential environment. The final sort and value and the final store in each transition represent guarantees the trace makes to its environment.
Formally, a (state) transition is a pair https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjd_HTML.gif . Let \(\xi ^?\in ( \mathbb {S}\times \mathbb {S} )^*\) range over possibly empty sequences of transitions, and \(\xi \in ( \mathbb {S}\times \mathbb {S} )^+\) range over non-empty ones. For any set \(X\), define the set of X-valued Brookes traces \(\textsf {T}X:==( \mathbb {S}\times \mathbb {S} )^+ \times X\), also used in Brookes’s model (§6). For any family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figje_HTML.gif define the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjf_HTML.gif -sorted family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjg_HTML.gif of traces https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjh_HTML.gif . Then, for any sorted family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figji_HTML.gif , we define the set of sorted traces over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjj_HTML.gif by:
A https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjl_HTML.gif -sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjm_HTML.gif -valued trace is one of the form https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjn_HTML.gif in the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjo_HTML.gif .
Example 18
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjp_HTML.gif , with https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjq_HTML.gif , is \(\bullet \)-sorted and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjr_HTML.gif -valued.    \(\square \)
Intuitively, the trace https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjs_HTML.gif models a potential behaviour, or protocol, that a shared-state program phrase under preemptive interleaving concurrency can exhibit, or adhere to, given as a rely/guarantee sequence.
Example 19
The behaviour denoted by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjt_HTML.gif relies on the preceding environment for \({\begin{smallmatrix}1 \\ 1 \end{smallmatrix}}\) and for the sequential environment to hold access to the store; then guarantees \({\begin{smallmatrix}1 \\ 0 \end{smallmatrix}}\); then relies on \({\begin{smallmatrix}1 \\ 1 \end{smallmatrix}}\); and finally guarantees \({\begin{smallmatrix}0 \\ 0 \end{smallmatrix}}\), and returns 7 to the succeeding sequential environment, ceding exclusive store access.    \(\square \)
One can make these trace-semantic concepts more formal, for example, when formulating an adequacy proof w.r.t. an operational semantics. We will not define these concepts formally since we will not need the additional level of rigour, for example, because we appeal to the well-established adequacy of Brookes’s model.
We implicitly understand the exclusive access to the store is ceded ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figju_HTML.gif ) between transitions. For example, for the trace https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjv_HTML.gif , we could write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjw_HTML.gif for emphasis. A hypothetical https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjx_HTML.gif would denote an impossible behaviour, making intermediate sorts redundant.
One of Brookes’s innovations is that sets of traces should be closed under what we now call (trace) deductions. Specifically, Brookes identified two such deductions, given as binary relations called stutter( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjy_HTML.gif ) and mumble( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figjz_HTML.gif ), defined in such a way that if the program phrase can adhere to the source protocol (left of arrow), then it can adhere to the target protocol (right of arrow).
We define these deductions in our two-sorted setting. For convenience, we write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figka_HTML.gif for the trace https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkb_HTML.gif in which, intuitively, the lock is ceded ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkc_HTML.gif ) at the marked spot. Formally, we require that both (a) if \(\xi ^?_1\) is empty, then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkd_HTML.gif ; and (b) if \(\xi ^?_2\) is empty, then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figke_HTML.gif . In particular, the requirement holds when both \(\xi ^?_1\) and \(\xi ^?_2\) are non-empty, where we implicitly assume the ceded sort between them; and in the case of a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkf_HTML.gif -sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkg_HTML.gif -valued trace, i.e. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkh_HTML.gif .
Example 20
We have the following valid/invalid notations for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figki_HTML.gif :
We define the following sorted stutter and mumble deductions:
The condition on stutter’s source rules out deductions which implicitly cede access to the store to the concurrent environment at the ends of the trace. We will compare these deductions to Brookes’s in §6.
Example 21
These deductions are valid, highlighting the change to the trace:
However, thanks to the condition on stutter’s source, this deduction is invalid:
The source protocol relies on the preceding sequential environment for \({\begin{smallmatrix}1 \\ 1 \end{smallmatrix}}\). We prohibit relaxing the protocol to rely on the concurrent environment for it.
The stutterand mumbledeductions follow the rely/guarantee intuition:
  • Stuttering ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkn_HTML.gif ) means a thread-pool also obeys the protocol that guarantees a state \(\sigma \) by relying on its environment for \(\sigma \).
  • Mumbling ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figko_HTML.gif ) means a thread-pool that guarantees the store https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkp_HTML.gif it later relies on also obeys the protocol in which we exclude the environment’s access to the store https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkq_HTML.gif at that point.
Sets of traces represent a non-deterministic choice between the behaviours that a program phrase may exhibit. For such a set \(K\), define its closure under trace deduction \(K^{\dagger }\) as the least set \(K'\) such that: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkr_HTML.gif ; and if https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figks_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkt_HTML.gif for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figku_HTML.gif , then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkv_HTML.gif . According to the rely/guarantee intuition above, a program phrase that is compatible with a set of traces is also compatible with its closure. We therefore represent program phrases as closed sets, i.e. sets \(K\) such that \(K= K^{\dagger }\). The closure \(K^{\dagger }\) of a countable \(K\) is countably infinite—by stuttering indefinitely—unless \(K\) is a finite set of single-transition \(\bullet \)-sorted \(\bullet \)-valued traces, in which case \(K\) is already closed.
For a set of traces \(U\) and sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkw_HTML.gif , define a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkx_HTML.gif -sorted family \(\mathcal {P}^{\aleph _0} ( U )\) by taking its https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figky_HTML.gif component to be the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figkz_HTML.gif of countable subsets of \(U\) whose elements are all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figla_HTML.gif -sorted. Similarly, define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlb_HTML.gif to be the set of closed countable subsets of \(U\) whose elements are all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlc_HTML.gif -sorted.
The prefixing function adds the given transition to each \(\bullet \)-sorted trace:
It lifts to closed sets, i.e. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figle_HTML.gif implies that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlf_HTML.gif .

5.2 Representation theorem

For https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlg_HTML.gif , define the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlh_HTML.gif -algebra of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figli_HTML.gif -valued closed trace-sets https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlj_HTML.gif as:
Additionally, define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figll_HTML.gif by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlm_HTML.gif .
The rest of this section establishes that the algebra https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figln_HTML.gif over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlo_HTML.gif is a free https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlp_HTML.gif -model over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlq_HTML.gif . A key ingredient is reification: for any https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlr_HTML.gif -sorted family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figls_HTML.gif , we define a sorted-function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlt_HTML.gif , choosing a representative term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlu_HTML.gif such that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlv_HTML.gif . This use of countable choice is inessential, the mere existence of the defining term \(t_2\) suffices.
First define for any https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlw_HTML.gif and \(b\in \mathbb {B}\) the cell assertion term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlx_HTML.gif that looks \(\ell \) up and only continues if it holds \(b\):
Next, for any https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figlz_HTML.gif we define the open transition https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figma_HTML.gif , as a term that asserts the state is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmb_HTML.gif , then updates the state to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmc_HTML.gif , and returns \(x\):
Now we can represent traces as terms. Define the \(\Sigma _{\textsf {S}\!\!\textsf {S}}\)-term reifying a trace https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figme_HTML.gif by sequencing open transition as they are in \(\xi \), separated by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmf_HTML.gif ; and delimited by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmg_HTML.gif on the left if https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmh_HTML.gif and by \(\mathop {\rhd }\) on the right if https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmi_HTML.gif .
Example 22
  https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmj_HTML.gif    \(\square \)
Trace deductions are sound w.r.t. this encoding, in the following sense:
Proposition 23
Assume that \(\tau _1\) and \(\tau _2\) are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmk_HTML.gif -sorted traces over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figml_HTML.gif , such that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmm_HTML.gif for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmn_HTML.gif . Then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmo_HTML.gif .
Finally, we reify a trace set by reifying its traces in a chosen enumeration:
By proposition 23, closure preserves reification: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmq_HTML.gif .
Using reification, we state the representation theorem  [14, proof in,§C].
Theorem 24
( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmr_HTML.gif -representation). The pair https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figms_HTML.gif is a free https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmt_HTML.gif -model over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmu_HTML.gif . Its representation sends environments https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmv_HTML.gif to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmw_HTML.gif -homomorphisms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmx_HTML.gif by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmy_HTML.gif . Moreover, for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figmz_HTML.gif we have:
Example 25
The model https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignb_HTML.gif invalidates Write Intro:
Every trace in the right-hand set has at most one state-changing transition. The left-hand set has traces with two. Therefore, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignd_HTML.gif does not prove Write Intro.    \(\square \)

6 Recovering Brookes’s model

The theory https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figne_HTML.gif recovers Brookes’s model (§6.1). We recover it twice, using different strategies that offer different perspectives. The first transforms the monad induced by the representation of §5.2 along a right adjoint https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignf_HTML.gif sending each https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figng_HTML.gif -family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignh_HTML.gif to the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figni_HTML.gif6.2). In the second, we define a single-sorted theory of transitions \(\textsf {B}\) that recovers Brookes’s model straightforwardly (§6.3). In this theory, the transition operators correspond to Brookes’s await construct. After swiftly introducing embedding translations (§6.4), we show that \(\textsf {B}\) embeds into https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignj_HTML.gif . The embedding factors through another, two-sorted, theory of transitions \(\textsf {T\!r}\)6.5).

6.1 Brookes’s model

We designed our notions of traces, deduction, etc. from §5.1 based on the following model of Brookes [6], in which traces cannot hold exclusive memory access at their ends. In this model, ceding access is implicit.
For any set \(X\in {\textbf {Set}}\), recall the set of Brookes traces \(\textsf {T}X:==( \mathbb {S}\times \mathbb {S} )^+ \times X\) from §5.1. Writing https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignk_HTML.gif for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignl_HTML.gif , Brookes’s stutterand mumbledeductions are:
We reuse the notation \(( - )^{\dagger }\) for closure under these deductions.
The difference between Brookes’s deductions and our multi-sorted deductions is the maintenance of the sort on each end of the trace. In particular, Brookes’s stutterdoes not need to explicitly allow interleaving at the relevant position in the source, because the environment may always interleave on either end.
Brookes’s semantic domain \(BX:==\mathcal {P}^{\dagger } ( \textsf {T}X )\) forms a monad. The monadic unit is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignn_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figno_HTML.gif . The Kleisli extension https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignp_HTML.gif of every \(e: X\rightarrow BY\) is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignq_HTML.gif . It interprets memory accesses, dereferencing (\(\ell !\)) and mutation (\(\ell := b\)), as follows:
These generic effects [31] correspond to these monadic algebraic operations:

6.2 Recovery via an adjunction

In Brookes’s model, yielding to the concurrent environment is implicit, and always allowed. From our two-sorted point-of-view, we expect the traces in Brookes’s model to represent https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignt_HTML.gif -sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignu_HTML.gif -valued traces.
There is an abstract construction that recovers the monad and its operations in §6.2 from our https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignv_HTML.gif -sorted model. The functor https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignw_HTML.gif has a left-adjoint https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignx_HTML.gif . This functor sends each set \(X\) to the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figny_HTML.gif -family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Fignz_HTML.gif , using the set-like notation for families we introduced in §3.1. Monads transform along adjoints, and transforming the monad obtained standardly from the representation of §5.2 along the adjunction above results in Brookes’s model. Explicitly, denoting https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoa_HTML.gif , the resulting monad over \({\textbf {Set}}\) is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figob_HTML.gif . This monad is isomorphic to Brookes’s https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoc_HTML.gif above by way of removing https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figod_HTML.gif from both ends of every trace. Thus, the Brookes model amounts to the free https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoe_HTML.gif -model from §5.2 transformed along the adjunction https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figof_HTML.gif . The monad \({\textbf {R}}\) supports the following generic effects. The adjunction transforms them, via its natural bijection on homsets, into Brookes’s generic effects for memory access:

6.3 The single-sorted theory of transitions

There is a more direct, single-sorted presentation \(\textsf {B}\) for Brookes’s model. It uses transitions as operators rather than lookup and update operators. The signature \(\Sigma _{\textsf {B}}\) consists of countable-joins https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoh_HTML.gif and a unary transition operator https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoi_HTML.gif for every https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoj_HTML.gif . The axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figok_HTML.gif consist of the countable-join semilattice axioms \(\text {Ax}_{\textsf {V}}\), strict distributivity axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figol_HTML.gif , and:
Fig. 2.
The hushrule
The first two axiom schemes are algebraic counterparts to mumbleand stutter. These alone do not recover Brookes’s model—the representation theorem for the theory without the (H) axioms includes potentially-empty traces. The axiom (H) fails in this model, but holds in Brookes’s. In the representation theorem for \(\textsf {B}\) it is tempting to require, along with closure under Brookes’s mumbleand stuttertrace deductions, closure under hush: presented in fig. 2 for a set of traces \(K\). However, there is no need, due to the non-emptiness of the traces. Indeed, either \(\xi ^?_1\) or \(\xi ^?_2\) must be non-empty for the rule to apply. Take https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figon_HTML.gif to match an adjacent transition, and apply the mumbleclosure rule to obtain the required consequence. This nuanced observation exposing the hushrule would be hard to notice without this algebraic analysis.
To conclude, we formulate the representation theorem for \(\textsf {B}\). Let \(X\in {\textbf {Set}}\). Define the \(\Sigma _{\textsf {B}}\)-algebra \({\textbf {B}}X\) with carrier \(\underline{{\textbf {B}}X} :==\mathcal {P}^{\dagger } ( \textsf {T}X )\) and interpretations:
Additionally, define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figop_HTML.gif by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoq_HTML.gif .
To prove that this is a free \(\textsf {B}\)-model, we use reification as in §5.2, though here reification is more straightforward. A trace is reified as itself, and sets of traces use countable-joins as before: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figor_HTML.gif . The monad obtained from the next proposition is Brookes’s model:
Proposition 26
The pair https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figos_HTML.gif is a free \(\textsf {B}\)-model over \(X\), for which the representation sends https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figot_HTML.gif to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figou_HTML.gif by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figov_HTML.gif .

6.4 e

quivalences]Translations and equivalences
We will need the following notions for relating presentations. Consider a map between two sort sets https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figow_HTML.gif . It lifts to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figox_HTML.gif by precomposition: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoy_HTML.gif . It forms the object part of a geometric morphism between (pre)sheaf toposes, i.e., it has left and right adjoints. The left adjoint https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figoz_HTML.gif is in this case https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpa_HTML.gif . When \(\epsilon \) is injective, the left adjoint is given by the simpler formula https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpb_HTML.gif .
Example 27
The geometric morphism for the map https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpc_HTML.gif is the forgetful functor https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpd_HTML.gif . As we saw in §6.2, its left adjoint is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpe_HTML.gif .    \(\square \)
Let \(\Sigma _1\) and \(\Sigma _2\) be signatures and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpf_HTML.gif a map between their sort sets. A translation of signatures \({\textbf {E}}: \Sigma _1 \rightarrowtail \Sigma _2\) along \(\epsilon \) is an assignment, to each https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpg_HTML.gif , of a term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figph_HTML.gif . Such a translation yields a functor \({\textbf {E}}_\textrm{tln}: {\textbf {Alg}}\Sigma _2 \rightarrow {\textbf {Alg}}\Sigma _1\), mapping a \(\Sigma _2\)-algebra \({\textbf {B}}\) to:
For a given family https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpj_HTML.gif , such a translation therefore extends uniquely to a \(\Sigma _1\)-homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpk_HTML.gif .
Example 28
We have a translation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpl_HTML.gif along https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpm_HTML.gif that translates the \(\Sigma _{\textsf {G}}\)-operators using their respective copies in the \(\bullet \) sort:
A translation of presentations https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpo_HTML.gif along \(\epsilon \) is a translation of their signatures along \(\epsilon \) that, moreover, preserves the provability of axioms:
Example 29
The translation of global state into shared state from example 28 is a translation of presentations https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpq_HTML.gif .    \(\square \)
Translations along composable sort maps compose via substitution, and a translation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpr_HTML.gif along https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figps_HTML.gif is an identity translation when, for all terms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpt_HTML.gif , we have https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpu_HTML.gif . A translation https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpv_HTML.gif along \(\epsilon \) is an equivalence if \(\epsilon \) is a bijection, and there exists an embedding https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpw_HTML.gif along \(\epsilon ^{-1}\), such that \({\textbf {E}}\circ {\textbf {E}}^{-1}\) and \({\textbf {E}}^{-1}\circ {\textbf {E}}\) are identity translations. We then write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpx_HTML.gif and say that the presentations are equivalent. Two multi-sorted theories are equivalent iff their associated free-model monads are isomorphic.

6.5 Translation through the two-sorted theory of transitions

We define a two-sorted presentation \(\textsf {T\!gs}\) of the open transitions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpy_HTML.gif as sequential operators. The signature \(\Sigma _{\textsf {T\!gs}}\) consists of countable-joins \(\Sigma _{\textsf {V}}\) and a unary open transition operator https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figpz_HTML.gif for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqa_HTML.gif . The axioms \(\text {Ax}_{\textsf {T\!gs}}\) consist of the countable-join semilattice axioms \(\text {Ax}_{\textsf {V}}\), strict distributivity axioms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqb_HTML.gif , and:
Translate \({\textbf {E}}_{\textsf {G}} : \textsf {T\!gs}\rightarrowtail \textsf {G}\) by interpreting transitions as the open transitions from §5.2: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqd_HTML.gif . Conversely, translate \({\textbf {E}}_{\textsf {T\!gs}} : \textsf {G}\rightarrowtail \textsf {T\!gs}\) as follows, similar to the representation of update and lookup from §5.2:
Using the equivalence \(\textsf {T\!gs}\simeq \textsf {G}\) that these translations witness we can translate https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqf_HTML.gif along https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqg_HTML.gif . We define a two-sorted presentation \(\textsf {T\!r}\), mimicking the definition of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqh_HTML.gif but replacing the operators and axioms of \(\textsf {G}\) with those of \(\textsf {T\!gs}\) in the hold (\(\bullet \)) sort: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqi_HTML.gif . Extending the translations \({\textbf {E}}_{\textsf {T\!gs}}\) and \({\textbf {E}}_{\textsf {G}}\) to all of the operators gives an equivalence https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqj_HTML.gif . So \(\textsf {T\!r}\) induces the same monad as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqk_HTML.gif , recovering Brookes’s model.
Fig. 3.
Th. chart
Define the translation \({\textbf {E}}_{\textsf {T\!r}} : \textsf {B}\rightarrowtail \textsf {T\!r}\) along https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figql_HTML.gif by sending transitions to their delimited open counterparts: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqm_HTML.gif . Using https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqn_HTML.gif we get https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqo_HTML.gif (fig. 3). Brookes’s model, as a free \(\textsf {B}\)-model, is thus the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqp_HTML.gif -sorted fragment of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqq_HTML.gif over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqr_HTML.gif -variables, formally.

7 Conclusion and further work

We presented an equational theory for shared state ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqs_HTML.gif ). It separates reasoning into two layers. In the held layer (\(\bullet \)), we prohibit the concurrent environment from accessing memory, and we can reason about memory accesses by a pool of threads sequentially. In the ceded layer ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqt_HTML.gif ), the concurrent environment may interleave, and local memory access is forbidden. We also presented theories of transitions (\(\textsf {B}\), \(\textsf {T\!gs}\), & \(\textsf {T\!r}\)) and formally related them to (non-deterministic) global state (\(\textsf {G}\)) and shared state ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqu_HTML.gif ). The single-sorted theory \(\textsf {B}\) recovers Brookes’s model, but it does so by using Brookes’s await construct, which we find unnatural; and it does not admit global state explicitly as a component of the theory. We believe that admitting global state will inform modelling other effects in the concurrent setting. Our theory https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqv_HTML.gif addresses these concerns. It admits the global state theory as-is, and axiomatises the mode-switching operators ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqw_HTML.gif /\(\mathop {\rhd }\)) without explicit interaction with global state. This theory recovers Brookes’s model exactly, in a principled manner: by transforming a monad and its operations along an adjunction; and, independently, through algebraic translations.
Our theory uses countable-join semilattices to recover Brookes’s model. They can express iteration (i.e. while-loops). The same model admits first-order recursion, i.e. least-fixpoints of mutually-defined first-order functions, using the \(\omega \)-complete partial order structure of the refinement order and the Scott-continuity of the semantics. We can support higher-order recursion by recourse to domain-theory, generalising algebraic theories using order-enriched theories. There are several standard variants, each with subtle logical trade-offs [29]. We can also restrict the semantics to terminating languages by restricting to finite joins, and using finitely-generated closed subsets for the representation.
We want to analyse Brookes’s parallel composition operator algebraically. Brookes composed programs in parallel by interleaving traces from each thread. Initial results show we can define Brookes’s parallel composition by simultaneous induction over terms. However, we would like to provide a more abstract account, by recourse to the universal property of free models. This abstraction may expose special properties of global state, or lead to a general parallel composition operation satisfying the expected laws of concurrent programming [16, 27, 34].
We would like to model more effects within this modular multi-sorted algebraic framework. These effects include: more advanced notions of state, such as dynamic allocation [20], higher-order memory cells [24, 36], and weak memory [12, 13]; control-flow effects such as exceptions and effect handlers [3]; and probabilistic programming with shared state [22].
If the multi-sorted approach does indeed generalise to more sophisticated effects, then it will be instructive to review its assumptions. For example, the strictness axioms impose a partial-correctness discipline: the semantics says nothing about the effect a diverging program has on its memory. Relaxing or removing strictness may give a model that allows us to reason about diverging programs.
Our two sorts limit access to the whole store. We would like to explore finer granularity. For example, a theory with per-location access limitation, with sorts for every finite subset \(s \subseteq \mathbb {L}\) of locations, and operators https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqx_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_18/MediaObjects/648523_1_En_18_Figqy_HTML.gif . We expect the axiomatisation’s design to require subtlety.
It may be interesting to to expose the sort discipline in the surface language through typing judgements, explicating regions that rule out data-races with the environment. It seems such judgements would rule out deadlocks structurally, and so may limit expressiveness. Whether this idea is useful remains to be seen.
In conclusion, our two-sorted decomposition of Brookes’s seminal model provides new insights into its assumptions and components, and reveals new directions for modelling more advanced features involving concurrent shared state.

Acknowledgments

Supported by the Israel Science Foundation (grant number 814/22) and the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement no. 851811); and by a Royal Society University Research Fellowship and Enhancement Award. For the purpose of Open Access the authors have applied a CC BY public copyright licence to any Author Accepted Manuscript version arising from this submission. We thank Danel Ahman, Andrej Bauer, Martín Escardó, Justus Matthiesen, Sam Staton, and Rob van Glabbeek for interesting and useful discussions and suggestions.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://​creativecommons.​org/​licenses/​by/​4.​0/​), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Literatur
2.
Zurück zum Zitat Adámek, J., Rosický, J., Vitale, E.M.: Algebraic Theories: A Categorical Introduction to General Algebra. Cambridge Tracts in Mathematics, Cambridge University Press (2010) Adámek, J., Rosický, J., Vitale, E.M.: Algebraic Theories: A Categorical Introduction to General Algebra. Cambridge Tracts in Mathematics, Cambridge University Press (2010)
10.
Zurück zum Zitat Dolan, S., White, L., Sivaramakrishnan, K.C., Yallop, J., Madhavapeddy, A.: Effective concurrency with algebraic effects (2015), OCaml Workshop Dolan, S., White, L., Sivaramakrishnan, K.C., Yallop, J., Madhavapeddy, A.: Effective concurrency with algebraic effects (2015), OCaml Workshop
15.
Zurück zum Zitat Hennessy, M.C.B., Plotkin, G.D.: Full abstraction for a simple parallel programming language. In: Mathematical Foundations of Computer Science, Springer, Berlin, Heidelberg (1979), ISBN 978-3-540-35088-0 Hennessy, M.C.B., Plotkin, G.D.: Full abstraction for a simple parallel programming language. In: Mathematical Foundations of Computer Science, Springer, Berlin, Heidelberg (1979), ISBN 978-3-540-35088-0
16.
Zurück zum Zitat Hoare, T.: Laws of programming: The algebraic unification of theories of concurrency. In: CONCUR 2014 – Concurrency Theory, Springer, Berlin, Heidelberg (2014), ISBN 978-3-662-44584-6 Hoare, T.: Laws of programming: The algebraic unification of theories of concurrency. In: CONCUR 2014 – Concurrency Theory, Springer, Berlin, Heidelberg (2014), ISBN 978-3-662-44584-6
23.
Zurück zum Zitat Lawvere, F.W.: Functorial Semantics of Algebraic Theories and Some Algebraic Problems in the context of Functorial Semantics of Algebraic Theories. Ph.D. thesis, Department of Mathematics (1963) Lawvere, F.W.: Functorial Semantics of Algebraic Theories and Some Algebraic Problems in the context of Functorial Semantics of Algebraic Theories. Ph.D. thesis, Department of Mathematics (1963)
24.
Zurück zum Zitat Levy, P.B.: Possible world semantics for general storage in call-by-value. In: Computer Science Logic, Springer, Berlin, Heidelberg (2002), ISBN 978-3-540-45793-0 Levy, P.B.: Possible world semantics for general storage in call-by-value. In: Computer Science Logic, Springer, Berlin, Heidelberg (2002), ISBN 978-3-540-45793-0
28.
Zurück zum Zitat Plotkin, G.D.: A powerdomain for countable non-determinism. In: Automata, Languages and Programming, Springer, Berlin, Heidelberg (1982), ISBN 978-3-540-39308-5 Plotkin, G.D.: A powerdomain for countable non-determinism. In: Automata, Languages and Programming, Springer, Berlin, Heidelberg (1982), ISBN 978-3-540-39308-5
Metadaten
Titel
Two-sorted algebraic decompositions of Brookes’s shared-state denotational semantics
verfasst von
Yotam Dvir
Ohad Kammar
Ori Lahav
Gordon Plotkin
Copyright-Jahr
2025
DOI
https://doi.org/10.1007/978-3-031-90897-2_18