Skip to main content
Erschienen in:

Open Access 2025 | OriginalPaper | Buchkapitel

A Diagrammatic Algebra for Program Logics

verfasst von : Filippo Bonchi, Alessandro Di Giorgio, Elena Di Lavore

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 untersucht die historischen und theoretischen Grundlagen der Relationsrechnung und zeichnet ihre Entwicklung vom 19. Jahrhundert bis zu ihren modernen Anwendungen in der Programmlogik nach. Es beginnt mit einem Überblick über das Beziehungskalkül und betont seine Rolle bei der Entwicklung der Logik erster Ordnung und seine Ausweitung mit transitivem Abschluss. Das Kapitel vertieft sich dann in die Pionierarbeit Lawveres zur kategorischen Logik, indem es das Konzept der funktionalen Semantik und seine Anwendung auf die Beziehungstheorie einführt. Ein wesentlicher Beitrag ist die Einführung von Kleene-Bikategorien, die die Struktur der typisierten Kleene-Algebren erweitern und das Wesen des Kontrollflusses in der Programmlogik erfassen. Das Kapitel entwickelt das Konzept der Kleene-Kartesischen Rigg-Kategorien weiter, die sowohl Daten- als auch Kontrollfluss innerhalb eines einheitlichen kategorialen Rahmens integrieren. Tonbanddiagramme werden als visuelle und kompositorische Notation für diese Kategorien eingeführt und bieten eine intuitive Möglichkeit, Programmlogiken darzustellen und zu begründen. Das Kapitel veranschaulicht die Ausdruckskraft von Tonbanddiagrammen anhand von Beispielen, einschließlich der Axiomatisierung von Peanos natürlichen Zahlen und der Kodierung von Imperativprogrammen. Abschließend wird gezeigt, wie sich die Regeln der Hoare-Logik aus den Gesetzen der Kleene-Kartesischen Rigg-Kategorien ableiten lassen, wobei das Potenzial dieses Ansatzes für die Verifikation von Programmen und die logische Interpretation hervorgehoben wird.

1 Introduction

The calculus of relations, originally introduced by De Morgan and Peirce in the late 19th century, is an ancestor of first order logic that has been revitalised by Tarski in 1941. With the dawn of program logics, the calculus of relations – extended with transitive closure – was early recognised [53] to play a key role.
Around the same time, Lawvere was pioneering categorical logic by introducing the concept of functorial semantics [47]. Given an algebraic theory T (in the sense of universal algebra, i.e., a signature \(\Sigma \) and a set of equations E), one can freely generate a Cartesian category \(\mathcal {L}_T\). Models, in the standard algebraic sense, correspond one-to-one with Cartesian functors F from \(\mathcal {L}_T\) to \(\textbf{Set}\), the category of sets and functions. More generally, models of the theory in any Cartesian category \(\textbf{C}\) are represented by Cartesian functors \(F: \mathcal {L}_T \rightarrow \textbf{C}\). However this approach fails if one tries to apply it to relational theories by choosing \(\textbf{C}\) as \(\textbf{Rel}\), the category of sets and relations, because the Cartesian product of sets is not the categorical product in \(\textbf{Rel}\).
A refinement of Lawvere’s method for relational structures has been recently proposed in [13, 15, 26]. Starting from a monoidal signature, one can freely generate a Cartesian bicategory [40] and define models as morphisms into \((\textbf{Rel}, \otimes , 1)\), the monoidal category of relations, where the monoidal product \(\otimes \) is the Cartesian product of sets. This framework captures regular theories, i.e., those involving the \(\{\exists , \wedge , \top \}\)-fragment of first order logic. More recently [10], this approach was extended to full first order logic by deriving negation from the interaction of Cartesian and linear bicategories [21].
In this paper, we extend the Cartesian bicategory framework in a different direction: program logics. In the last decades, there has been an explosion of program logics and many researchers felt the need for more systematic approaches. Our proposal is based on relational and categorical algebra. We propose tape diagrams as an “assembly language” for interpreting various program logics (Remark 3). While the inference rules for each of these logics are usually defined by the ingenuity of the researchers, in our approach such rules follow from the laws of Kleene-Cartesian rig categories. These laws arise from the interaction of canonical categorical structures on the category of sets and relations. Crucially, the same approach has lead to identify various categorical structures corresponding to various well-known logics (Figure 1).
Fig. 1.
Categorical structures correspond to logics.
An idea, originating at least from Bainbridge [4], is to model data flow using the Cartesian product of relations, \((\textbf{Rel}, \otimes , 1)\), and control flow using a different monoidal structure on relations: \((\textbf{Rel}, \oplus , 0)\). In this second structure, the monoidal product \(\oplus \) is the disjoint union of sets, which acts both as a coproduct and a product, hence, a biproduct. Both monoidal categories are traced [39]: the trace in \((\textbf{Rel}, \otimes , 1)\) represents feedback, while in \((\textbf{Rel}, \oplus , 0)\) –the focus of our work– it provides iteration [54].
Our first step is to extract from \((\textbf{Rel}, \oplus , 0)\) the categorical structures essential for modelling control flow, which we term Kleene bicategories. Essentially, a Kleene bicategory is a poset-enriched traced monoidal category where the monoidal product \(\oplus \) is a biproduct, and the induced natural comonoid [27] is right adjoint to the natural monoid. The trace must satisfy a posetal variant of the so-called uniformity condition [20, 33]. The term “Kleene” is justified because every Kleene bicategory forms a (typed) Kleene algebra in Kozen’s sense [41, 43] (Corollary 1), while any Kleene algebra canonically gives rise, through the biproduct completion [48], to a Kleene bicategory.
To model control and data flow within a unified categorical structure, we employ rig categories [46], categories equipped with two monoidal products, \(\oplus \) and \(\otimes \), where \(\otimes \) distributes over \(\oplus \). We define Kleene-Cartesian rig (kc rig) categories, where \(\oplus \) and \(\otimes \) exhibit the structures of Kleene and Cartesian bicategories, respectively. To construct the freely generated kc rig category (Theorem 2), we extend tape diagrams [11], a diagrammatic notation recently introduced for rig categories. Intuitively, tape diagrams are string diagrams [38] in which other string diagrams are nested: the inner diagrams model data flow, and the outer ones model control flow. On one hand, this offers an intuitive unified picture of Bainbridge’s idea; on the other it allows for visualising the laws of kc rig categories (Figures 2, 3 and 4) in a way that enlights several monoidal algebras occurring in different types of systems [3, 12, 14, 16, 18, 22, 28, 29, 36, 51, 56].
We then introduce Kleene-Cartesian theories and their models that, like in Lawvere’s approach, coincide with functors (Proposition 3). We illustrate an example of a Kleene-Cartesian theory which is not first order: Peano’s axiomatisation of natural numbers. We demonstrate how imperative programs and their logics [2, 24, 35, 44, 50] – even more sophisticated ones, like [7], where the interaction of data and control flow play a key role – can be encoded within Kleene-Cartesian tape diagrams. In particular, we show that the rules of Hoare logic follow from the laws of kc rig categories (Proposition 4). Finally, the framework is expressive enough to capture the positive fragment of the calculus of relations with transitive closure, which is the departure of our journey.
The full version of the paper is found in [9] which contains the missing proofs.

2 The calculus of relations

We commence by recalling the positive fragment of the calculus of relations with
reflexive and transitive closure (\(\textsf{CR}\)). Its syntax is given by the grammar on the left, where R is taken from a given set \(\Sigma \) of generating symbols. Beyond the usual relational composition ; , union \(\cup \), intersection \(\cap \) and their units \({id} \), \(\bot \) and \(\top \), the calculus features two unary operations:
$$\begin{aligned} E :\,\!:= \ & R \mid {id} \mid E;E \;\;\mid \end{aligned}$$
(1)
$$\begin{aligned} & E^{\dagger } \mid \top \mid E \cap E \mid \end{aligned}$$
(2)
$$\begin{aligned} & E^{*} \mid \bot \mid E \cup E \end{aligned}$$
(3)
the opposite \((\cdot )^{\dagger }\) and the reflexive and transitive closure \((\cdot )^{*}\). Composition and identities are defined, for sets XYZ, and relations \(R\subseteq X \times Y\), \(S\subseteq Y\times Z\), as
$$\begin{aligned} R;S{\mathop {=}\limits ^{\tiny \text {def}}}\{(x,z) \mid \exists y.\in Y. \, (x,y)\in R \wedge (y,z)\in S\} \; \text { and } \; {id}_{X} {\mathop {=}\limits ^{\tiny \text {def}}}\{(x,x)\mid x\in X\} \text {,} \end{aligned}$$
the opposite as \(R^{\dagger }{\mathop {=}\limits ^{\tiny \text {def}}}\{(y,x)\mid (x,y)\in R\}\), while for \(R\subseteq X \times X\), its reflexive and transitive closure is \(R^{*}{\mathop {=}\limits ^{\tiny \text {def}}}\bigcup _{n\in \mathbb {N}}R^n\) where \(R^0{\mathop {=}\limits ^{\tiny \text {def}}}{id}_{X}\) and \(R^{n+1}{\mathop {=}\limits ^{\tiny \text {def}}}R;R^n\).
Its semantics, illustrated below, is defined wrt a relational interpretation \(\mathcal {I}\), that is, a set X together with a binary relation \(\rho (R)\subseteq X \times X\) for each \(R\in \Sigma \).
Two expressions \(E_1\), \(E_2\) are said to be equivalent, written \(E_1 \equiv _{\textsf{CR}} E_2\), iff \(\langle E_1\rangle _\mathcal {I}=\langle E_2\rangle _\mathcal {I}\) for all interpretations \(\mathcal {I}\). For instance, \((R^{*})^{\dagger } \equiv _{\textsf{CR}} (R^{\dagger })^{*}\). Inclusion, denoted by \(\le _{\textsf{CR}}\), is defined analogously by replacing \(=\) with \(\subseteq \). Axiomatisations and decidability of \(\equiv _{\textsf{CR}}\) have been studied focusing on several different fragments: see [52] and the references therein. Particularly interesting are the allegorical fragment, consisting of (1) and (2), and the Kleene fragment consisting of (1) and (3).
Our starting observation is that these two fragments arise from two different traced monoidal structures on \(\textbf{Rel}\), the category of sets and relations: \((\textbf{Rel}, \otimes , 1)\) and \((\textbf{Rel}, \oplus , 0)\). In the former, the monoidal product \(\otimes \) is given by the cartesian product of sets and, for relations \(R:X_1\rightarrow Y_1 \), \(S :X_2 \rightarrow Y_2\), \(R\otimes S :X_1 \otimes X_2 \rightarrow Y_1 \otimes Y_2\) is defined as
$$\begin{aligned} R \otimes S {\mathop {=}\limits ^{\tiny \text {def}}}\{(\,(x_1,x_2),\, (y_1,y_2)\,) \mid (x_1,y_1)\in R \text { and } (x_2,y_2)\in S \} \text { with unit }1{\mathop {=}\limits ^{\tiny \text {def}}}\{\bullet \}\text {.} \end{aligned}$$
In \((\textbf{Rel}, \oplus , 0)\), \(0{\mathop {=}\limits ^{\tiny \text {def}}}\{\}\), \(\oplus \) on sets is their disjoint union and \(R \oplus S :X_1\oplus X_2 \rightarrow Y_1\oplus Y_2\) is
$$\begin{aligned} R \oplus S {\mathop {=}\limits ^{\tiny \text {def}}}\{(\,(x_1,1),\,(y_1,1)\,) \mid (x_1,y_1)\in R \} \cup \{(\,(x_2,2),\,(y_2,2)\,) \mid (x_2,y_2)\in S \}\text {.} \end{aligned}$$
Here, we tag with 1 and 2 the elements of the disjoint union of two arbitrary sets.
For all sets X, the unique function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figb_HTML.gif and the pairing \(\langle {id}_{X},{id}_{X}\rangle {\mathop {=}\limits ^{\tiny \text {def}}}\blacktriangleleft _{X} :X \rightarrow X \otimes X\) form a comonoid in \((\textbf{Rel}, \otimes , 1)\). Similarly the unique function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figc_HTML.gif and the copairing \([{id}_{X},{id}_{X}]{\mathop {=}\limits ^{\tiny \text {def}}}\rhd _{X} :X\oplus X \rightarrow X\) form a monoid in \((\textbf{Rel}, \oplus , 0)\). By taking their opposite relations, we obtain in total the two (co)monoid structures illustrated below.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Equ4_HTML.png
(4)
The black (co)monoids give to \((\textbf{Rel}, \otimes , 1)\) the structure of a Cartesian bicategory [19], while the white ones give to \((\textbf{Rel}, \oplus , 0)\) the structure of, what we named, a Kleene bicategory. These are illustrated in the next two sections.

3 Cartesian Bicategories

All bicategories considered in this paper are poset enriched symmetric monoidal categories: every homset carries a partial order \(\le \), and composition ;  and monoidal product \(\odot \) are monotone. A poset enriched symmetric monoidal functor is a symmetric monoidal functor that preserves the order \(\le \). The notion of adjoint arrows, which will play a key role, amounts to the following: for \(f :X \rightarrow Y\) and \(g :Y \rightarrow X\), f is left adjoint to g, or g is right adjoint to f, written \(f \dashv g\), if \({id}_{X} \le f ; g\) and \(g ; f \le {id}_{Y}\). We extend such terminology to pairs of arrows: (ab) is left adjoint to (cd) iff \(a \dashv c\) and \(b \dashv b\).
All monoidal categories and functors considered throughout this paper are tacitly assumed to be strict [48], i.e. \((X\odot Y)\odot Z = X \odot (Y \odot Z)\) and \(I\odot X = X =X \odot I\) for all objects XYZ. This is harmless: strictification [48] allows to transform any monoidal category into a strict one, enabling the sound use of string diagrams. In this and in the next section we will use the string diagrammatic notation for traced monoidal categories from [55]. The unfamiliar reader may check e.g. [9, Sec. 2]. In particular multiplication, unit, comultiplication and counit of the various (co)monoids, always tacitly assumed to be (co)commutative, will be drawn hereafter respectively, as
Definition 1
A Cartesian bicategory is a poset enriched symmetric monoidal category \((\textbf{C}, \otimes , 1)\) and, for every object X in \(\textbf{C}\), a monoid https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Fige_HTML.gif and a comonoid https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figf_HTML.gif satisfying the usual coherence conditions (see e.g. [55, Table 4.7]) such that
1. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figg_HTML.gif is left adjoint to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figh_HTML.gif ;
2. arrows \(f :X \rightarrow Y\) are lax comonoid morphisms: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figi_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figj_HTML.gif ;
3. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figk_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figl_HTML.gif form special Frobenius algebras (see e.g. [45]);
A morphism of Cartesian bicategories is a poset enriched symmetric monoidal functor preserving monoids and comonoids.
The archetypal example of a Cartesian bicategory is \((\textbf{Rel},\otimes ,1)\) with https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figm_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Fign_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figo_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figp_HTML.gif defined as in (4). Simple computations confirm that all the laws of Definition 1 are satisfied. The operations of \(\textsf{CR}\) in (2) can be defined in any Cartesian bicategory, as
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Equ5_HTML.png
(5)
for all objects XY and arrows \(f,g:X \rightarrow Y\). The reader can easily check that, in \(\textbf{Rel}\), these correspond to the intersection \(f\sqcap g\), the top relation \(X\times Y\) and the opposite relation \(f^{\dagger }\), respectively. From now on, we will depict a morphism \(f :X \rightarrow Y\) as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figq_HTML.gif , and use https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figr_HTML.gif as syntactic sugar for \(f^{\dagger }\).
Proposition 1
In any Cartesian bicategory, the laws in Table 1 hold.
Table 1.
Derived laws in Cartesian bicategories.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Tab1_HTML.png
Dummy
An arrow \(f :X \rightarrow Y\) is said to be single valued iff satisfies (SV) below, total iff satisfies (TOT), injective iff satisfies (INJ) and surjective iff satisfies (SUR).
Lemma 1
In a Cartesian bicategory, an arrow \(f :X \rightarrow Y\) is single valued iff (6), it is total iff (7), it is injective iff (8) and it is surjective iff (9).
Any Cartesian bicategory is self-dual compact closed and thus traced. Later on, to deal with tests in imperative programs we will use coreflexives, namely arrows \(f:X \rightarrow X\) such that \(f\le {id}_{X}\). In Cartesian bicategories, they enjoy several useful properties:
Lemma 2
In a Cartesian bicategory, the following hold:
1.
f is a coreflexive iff f is transitive (\(f;f\le f\)), symmetric (\(f^{\dagger }\le f\)) and single valued.
 
2.
Coreflexives \(X \rightarrow X\) are in bijective correspondece with arrows \(1\rightarrow X\).
 
3.
For all coreflexives \(f,g :X \rightarrow X\), \(f ; g = f \sqcap g\); Moreover, for \(f':1\rightarrow X\) corresponding to f and \(i:1\rightarrow X\), \(i\sqcap f'= i;f\).
 

4 Kleene Bicategories

Table 2.
Axioms of (Typed) Kleene Algebras
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Tab2_HTML.png
Dummy
Now, we introduce Kleene bicategories and show that their laws capture the complete axiomatisation of Kleene algebras from [41]. Recall that a category \(\textbf{C}\) is enriched over join-semilattices if every homset carries a join \(\sqcup \) semilattice with bottom \(\bot \) and composition ;  distributes over it (see (10) and 11 in Table 2). A (typed) Kleene algebra [41, 43] is a category enriched over join-semilattices equipped with a Kleene star operator, namely a family of operations \((\cdot )^{*} :\textbf{C}[X,X] \rightarrow \textbf{C}[X,X]\) such that for all \(f:X\rightarrow X\), \(r:X \rightarrow Y\) and \(l:Y \rightarrow X\) the four laws in (12) hold.
Definition 2
A finite biproduct (shortly, fb) category with idempotent convolution is a poset enriched symmetric monoidal category \((\textbf{C}, \oplus , 0)\) and, for every object X in \(\textbf{C}\), a monoid https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figv_HTML.gif and a comonoid https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figw_HTML.gif satisfying the usual coherence conditions s.t.:
1. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figx_HTML.gif is right adjoint to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figy_HTML.gif ;
2. arrows \(f :X \rightarrow Y\) are both monoid and comonoid morphisms: \(f;\lhd _{Y}= \lhd _{X};(f \oplus f)\), https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figz_HTML.gif , \(\rhd _{Y}; f= (f \oplus f); \rhd _{X}\) and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figaa_HTML.gif .
Remark 1
A finite biproduct category is defined as above but without the poset enrichment and the adjointness condition: \(0\) is both final and initial object and \(\oplus \) is both a categorical product and coproduct, i.e., a biproduct [27]. While any finite biproduct category is enriched over commutative monoids, the additional conditions in Definition 2 guarantee that this is enriched over join semilattices where \(\sqcup \) and \(\bot \) are defined for all objects XY and arrows \(f,g:X \rightarrow Y\) as on the left below.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Equ6_HTML.png
(13)
The reader can easily check that \((\textbf{Rel},\oplus ,0)\) with \(\lhd _{X}\), https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figab_HTML.gif , \(\rhd _{X}\), https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figac_HTML.gif defined as in (4) is a finite biproduct category with idempotent convolution and that \(\sqcup \) and \(\bot \) give union and empty relation. Unfortunately, finite biproduct categories with idempotent convolution do not have enough structure to deal with \((\cdot )^{*}\): differently from Cartesian bicategories they are not necessarily traced. Such structure has to be explicitely added:
Definition 3
A Kleene bicategory \(\textbf{C}\) is both a finite biproduct category with idempotent convolution and a poset enriched traced monoidal category such that
1.
for all objects X, the trace https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figad_HTML.gif satisfies the axiom https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figae_HTML.gif ;
 
2.
the trace is posetal uniform: for all \(f:S\oplus X \rightarrow S \oplus Y\) and \(g :T\oplus X \rightarrow T \oplus Y\),
 
(AU1)
if \(\exists r:S \rightarrow T\) such that \(f ; (r \oplus {id}_{Y}) \le (r \oplus {id}_{X}) ; g\), then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figaf_HTML.gif ;
(AU2)
if \(\exists r:T \rightarrow S\) such that \((r \oplus {id}_{X}) ; f \le g ; (r \oplus {id}_{Y})\), then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figag_HTML.gif .
A morphism of Kleene bicategory is a poset enriched symmetric monoidal functor preserving monoids, comonoids and traces.
The laws in (AU1) and (AU2) are the posetal extension of the uniformity condition for traces (see e.g. [33]). To the best of our knowledge, they have never been studied. Instead, the axioms in 1 already appeared in the literature (see e.g. [51]). Like in any finite biproduct category with trace (see e.g. [20]), in a Kleene bicategory one can define for each endomorphism \(f:X \rightarrow X\), a morphism \(f^{*}:X \rightarrow X\) as in (13). The distinguishing property of Kleene bicategories is that \((\cdot )^{*}\) is a Kleene star operator: see (12). Viceversa, any Kleene star operation gives rise to a trace satisfying the laws of Kleene bicategories.
Theorem 1
Let \(\textbf{C}\) be a fb category with idempotent convolution. \(\textbf{C}\) is a Kleene bicategory iff \(\textbf{C}\) has a Kleene-star operator.
Corollary 1
All Kleene bicategories are typed Kleene algebras.
The opposite does not hold: not all Kleene algebras are monoidal categories. Nevertheless, from a Kleene algebra, one can canonically build a Kleene bicategory by means of the matrix construction, aka biproduct completion [23, 48]. See [9, Sec. 6.3]

5 Rig Categories

We have seen that \(\textbf{Rel}\) carries two monoidal categories \((\textbf{Rel}, \otimes , 1)\) and \((\textbf{Rel}, \oplus , 0)\). The appropriate setting for studying their interaction is given by rig categories [37, 46].
Definition 4
A rig category is a category \(\textbf{C}\) with two symmetric monoidal structures \((\textbf{C}, \otimes , 1)\) and \((\textbf{C}, \oplus , 0)\) and natural isomorphisms
$$\begin{aligned} \delta ^l_{X,Y,Z} :X \otimes (Y \oplus Z) \rightarrow (X \otimes Y) \oplus (X \otimes Z) \qquad \lambda ^\bullet _{X} :0\otimes X \rightarrow 0\end{aligned}$$
$$\begin{aligned} \delta ^r_{X,Y,Z} :(X \oplus Y) \otimes Z \rightarrow (X \otimes Z) \oplus (Y \otimes Z) \qquad \rho ^\bullet _{X} :X \otimes 0\rightarrow 0\end{aligned}$$
satisfying certain coherence axioms [46]. A rig category is said to be right strict when \(\lambda ^\bullet , \rho ^\bullet \) and \(\delta ^r\) are all identity natural isomorphisms. A right strict rig functor is a strict symmetric monoidal functor for both \(\otimes \) and \(\oplus \) preserving \(\delta ^l\).
A sesquistrict rig category is a functor \(H :\textbf{S} \rightarrow \textbf{C}\), where \(\textbf{S}\) is a discrete category and \(\textbf{C}\) is a right strict rig category, such that for all \(A \in \textbf{S}\)
$$ \delta ^l_{H(A),X,Y} :H(A) \otimes (X \oplus Y) \rightarrow (H(A) \otimes X) \oplus (H(A) \otimes Y) $$
is an identity morphism. Given \(H \!:\! \textbf{S} \!\rightarrow \! \textbf{C}\) and \(H' \!:\! \textbf{S}' \!\rightarrow \! \textbf{C}'\) two sesquistrict rig categories, a sesquistrict rig functor from H to \(H'\) is a pair \((\alpha \!:\! \textbf{S} \!\rightarrow \! \textbf{S}', \beta \!:\! \textbf{C} \!\rightarrow \! \textbf{C}')\), with \(\alpha \) a functor and \(\beta \) a strict rig functor, such that \(\alpha ; H' = H; \beta \).
Intuitively, a sesquistrict rig category is right strict and, partially (just for the selected class of objects \(\textbf{S}\)), left strict. For more details, we refer the reader to [11, Sec. 4].
From any rig category \(\textbf{C}\), one can construct its (right) strictification \(\overline{\textbf{C}}\) [37] and then embed \(ob(\textbf{C})\), the discrete category of the objects of \(\textbf{C}\), into \(\overline{\textbf{C}}\). The embedding \(ob(\textbf{C}) \rightarrow \overline{\textbf{C}}\) forms a sesquistrict category and it is equivalent (as a rig category) to the original \(\textbf{C}\) [11, Corollary 4.5]. Through the paper, when dealing with a rig category \(\textbf{C}\), we will often implicitly refer to the equivalent sesquistrict \(ob(\textbf{C}) \rightarrow \overline{\textbf{C}}\).
Hereafter, we write \(A,B,\dots \) for the elements of a fixed set \(\mathcal {S}\) and \(U,V, \dots \) for the words in \(\mathcal {S}^\star \). Given two words \(U,V\in \mathcal {S}^\star \), we write \(U \otimes V\), shortly UV, for their concatenation and 1 for the empty word. We use \(P,Q, \dots \) for words of words in \((\mathcal {S}^\star )^\star \) and we write \(P \oplus Q\) for their concatenation and 0 for the empty word of words. Beyond \(\oplus \), one can define \(\otimes \) on \((\mathcal {S}^\star )^\star \): for all \(P =U_0 \oplus \dots \oplus U_n\) and \(Q = V_0 \oplus \dots \oplus V_m\)
$$\begin{aligned} P \otimes Q {\mathop {=}\limits ^{\tiny \text {def}}}U_0V_0 \oplus \dots \oplus U_0V_n \oplus \dots \oplus U_nV_0 \oplus \dots \oplus U_nV_m \end{aligned}$$
(14)
For instance, \((A\oplus B) \otimes (C \oplus D)\) is \((A \otimes C) \oplus (A \otimes D) \oplus (B \otimes C) \oplus (B \otimes D)\). One can readily see that elements in \((\mathcal {S}^\star )^\star \) are in bijective correspondence with non-commutative polynomials with variables in \(\mathcal {S}\). Consequently, we will call monomials the words in \(\mathcal {S}^\star \).
Given a set of sorts \(\mathcal {S}\), a monoidal signature is a tuple \((\mathcal {S},\Sigma , ar , coar )\) where \( ar \) and \( coar \) assign to each symbol \(s\in \Sigma \) an arity and a coarity in \(\mathcal {S}^\star \). A rig signature is the same but with arity and coarity in \((\mathcal {S}^\star )^\star \). An interpretation \(\mathcal {I}\) of a rig signature \((\mathcal {S},\Sigma , ar , coar )\) in a sesquistrict rig category \(H :\textbf{M} \rightarrow \textbf{D}\) is a pair of functions \((\alpha _{\mathcal {S}} :\mathcal {S}\rightarrow Ob(\textbf{M}), \alpha _\Sigma :\Sigma \rightarrow Ar(\textbf{D}))\) such that, for all \(s\in \Sigma \), \(\alpha _{\Sigma }(s)\) is an arrow having as domain and codomain \((\alpha _{\mathcal {S}};H)^\sharp ( ar (s))\) and \((\alpha _{\mathcal {S}};H)^\sharp ( coar (s))\). Here, \((\alpha _{\mathcal {S}};H)^\sharp \) stands for inductive extension of \(\alpha _{\mathcal {S}};H :\mathcal {S}\rightarrow Ob(\textbf{D})\) to \((\mathcal {S}^\star )^\star \).
Definition 5
Let \((\mathcal {S},\Sigma , ar , coar )\) (simply \(\Sigma \) for short) be a rig signature. A sesquistrict rig category \(H :\textbf{M} \rightarrow \textbf{D}\) is said to be freely generated by \(\Sigma \) if there is an interpretation \((\alpha _S,\alpha _\Sigma )\) of \(\Sigma \) in H such that for every sesquistrict rig category \(H' :\textbf{M}' \rightarrow \textbf{D}'\) and every interpretation \((\alpha _\mathcal {S}' :\mathcal {S}\rightarrow Ob(\textbf{M}'), \alpha _\Sigma ' :\Sigma \rightarrow Ar(\textbf{D}'))\) there exists a unique sesquistrict rig functor \((\alpha :\textbf{M} \rightarrow \textbf{M}', \beta :\textbf{D} \rightarrow \textbf{D}')\) such that \(\alpha _\mathcal {S}; \alpha = \alpha _\mathcal {S}'\) and \(\alpha _\Sigma ; \beta = \alpha _{\Sigma }'\).

6 Kleene-Cartesian Bicategories

We have seen that Cartesian bicategories provide enough structure for the allegorical fragment of \(\textsf{CR}\), while Kleene bicategories for its Kleene fragment. For the whole \(\textsf{CR}\), we make the Cartesian and Kleene bicategory structures interact as rig categories.
Definition 6
A Kleene-Cartesian rig category (shortly kc rig) is a poset enriched rig category \(\textbf{C}\) such that
1.
\((\textbf{C}, \oplus , 0)\) is a Kleene bicategory;
 
2.
\((\textbf{C}, \otimes , 1)\) is a Cartesian bicategory;
 
3.
the (co)monoids satisfy the following coherence conditions:
 
A morphism of kc rig-categories is a poset enriched rig functor that is a morphism of both Kleene and Cartesian bicategories.
The axioms in (15) rule the interaction of black and white (co)monoids. Recall that in Cartesian and Kleene bicategories, homsets carry respectively meet and join semilattices. In any kc rig category, they carry distributive lattices; also \((\cdot )^{\dagger }\) distributes over \(\oplus \), while \((\cdot )^{*}\) only distributes laxly over \(\otimes \). As expected \((\cdot ^{*})^{\dagger }= (\cdot ^{\dagger })^{*}\).
Table 3.
Derived laws in kc rig categories.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Tab3_HTML.png
Dummy
Proposition 2
The laws in Table 3 hold in any kc rig category.
Corollary 2
Any kc rig category is a typed Kleene algebra with converse [8, 17].
We have already seen that \((\textbf{Rel},\oplus , 0)\) is a Kleene bicategory and \((\textbf{Rel},\otimes , 1)\) is a Cartesian bicategory. To conclude that \(\textbf{Rel}\) is a kc rig category, it is enough to check the coherence conditions of the two (co)monoids defined in (4).

6.1 Kleene-Cartesian Tape Diagrams

We identify the kc rig category freely generated by a rig signature \((\mathcal {S},\Sigma )\). This is described as Kleene-Cartesian tape diagrams, which provide a syntax for kc rig categories. These are strictly more expressive than the calculus of relations: thanks to the monoidal product \(\otimes \), they can deal with \(n\)-ary function symbols, e.g. “add” in Equation 22, data flow and relational Hoare logic (Remark 3).
Thanks to Theorem 4.9 in [11], we can restrict, without loss of generality, to the simpler case where \(\Sigma \) is just a monoidal signature. Our work extends [11, Section 7] that identifies a freely generated fb-cb rig category, shortly a kc rig category without traces (\(\oplus \) is just a fb category with idempotent convolution).
As explained in Section 5, we can consider the sesquistrict rig categories having as sets of objects \((\mathcal {S}^\star )^\star \). For arrows, consider the following two-layer grammar
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Equ8_HTML.png
(16)
where \(s \in \Sigma \), \(A,B \in \mathcal {S}\) and \(U,V \in \mathcal {S}^\star \). The terms of the first row, called circuits, intuitively represent arrows of a Cartesian bicategory. The terms of the second row, called tapes, represent arrows of a Kleene bicategory. As expected, we only consider those terms to which is possible to associate source and target objects: the reader may check the simple type system in [9, Table 1]. Constants and operations in (16) can be extended to arbitrary polynomials in \((\mathcal {S}^\star )^\star \). For instance, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figaj_HTML.gif is inductively defined as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figak_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figal_HTML.gif . For the other definitions see [11].
Particularly interesting is the fact that one can define \(\otimes \) on tapes: for \(\mathfrak {t}_1 :P \rightarrow Q\), \(\mathfrak {t}_2 :R \rightarrow S\), \(\mathfrak {t}_1 \otimes \mathfrak {t}_2 {\mathop {=}\limits ^{\tiny \text {def}}}\textsf{L}_{P}({\mathfrak {t}_2}) ; \textsf{R}_{S}({\mathfrak {t}_1}) \) where \(\textsf{L}_{P}({\cdot })\), \(\textsf{R}_{S}({\cdot })\) are the left and right whiskerings that can be defined by extending [11, Def 5.7] with an extra case for the trace: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figam_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figan_HTML.gif . Left distributors \(\delta ^l_{P,Q,R} :P \otimes (Q\oplus R) \rightarrow (P \otimes Q) \oplus (P\otimes R)\) and \(\otimes \)-symmetries https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figao_HTML.gif are defined as in [11, Table 4]. The (co)monoids of \(\otimes \) as in [11, (20),(21)].
Next, we impose the laws of kc rig categories on tapes. However, this should be done carefully, in order to properly tackle the two uniformity laws (AU1) and (AU2) which are implications and not (in)equalities. Let \(\mathbb {I}\) be a a set of pairs https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figap_HTML.gif of tapes with the same domain and codomain. We define \(\,{\le }_{{\mathbb {I}}}\,\) to be the set generated by the following inference system (where \(\mathfrak {t}\,{\le }_{{\mathbb {I}}}\,\mathfrak {s}\) is a shorthand for \((\mathfrak {t},\mathfrak {s})\in \,{\le }_{{\mathbb {I}}}\,\)).
The first six laws ensure that \(\,{\le }_{{\mathbb {I}}}\,\) is a precongruence (w.r.t. ; , \(\oplus \) and \(\otimes \)) containing \(\mathbb {I}\). The last two rules force the uniformity laws: observe that, while in (AU1) and (AU2) the same arrow r occurs in both the left and the right- hand-side of the premises, here r is replaced by two different but related tapes \(\mathfrak {s}_1\) and \(\mathfrak {s}_2\). This technicality is needed to guarantee uniformity in the category resulting from the following construction.
We take \(\mathbb{K}\mathbb{C}\) to be the set of all pairs of tapes containing the axioms in Table 71 and define \(\le _{\mathbb{K}\mathbb{C}}\) according to (17). We fix \(\sim _{\mathbb{K}\mathbb{C}} {\mathop {=}\limits ^{\tiny \text {def}}}\le _{\mathbb{K}\mathbb{C}} \cap \ge _{\mathbb{K}\mathbb{C}}\). With these definitions we can construct the category of Kleene-Cartesian tapes \(\textbf{KCT}_{\Sigma }\): objects are polynomials in \((\mathcal {S}^\star )^\star \) with \(\oplus \) and \(\otimes \) defined as in (14); arrows are \(\sim _\mathbb{K}\mathbb{C}\)-equivalence classes of tapes; every homset \(\textbf{KCT}_{\Sigma }[P,Q]\) is ordered by \(\,{\le }_{{\mathbb{K}\mathbb{C}}}\,\). The construction of \(\textbf{KCT}_{\Sigma }\) gives rise to a sesquistrict kc rig category. More importantly, \(\textbf{KCT}_{\Sigma }\) is the freely generated one.
Theorem 2
\(\textbf{KCT}_{\Sigma }\) is the free sesquistrict kc rig category generated by \((\mathcal {S}, \Sigma )\).
In [11], it is shown that a key feature of tapes is that they can be drawn nicely in 2 dimensions despite representing arrows of rig categories. Indeed, both circuits and tapes can be drawn as string diagrams. Note however that inside tapes, there are string diagrams. Thus, the grammar in (16) can be graphically rendered as follows.
The identity \({id}_{0}\) is rendered as the empty tape https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figas_HTML.gif , while \({id}_{1}\) is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figat_HTML.gif : a tape filled with the empty circuit. For a monomial \(U \!=\! A_1\dots A_n\), \({id}_{U}\) is depicted as a tape containing n wires labelled by \(A_i\). For instance, \({id}_{AB}\) is rendered as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figau_HTML.gif . When clear from the context, we will simply represent it as a single wire https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figav_HTML.gif with the appropriate label. Similarly, for a polynomial https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figaw_HTML.gif , \({id}_{P}\) is obtained as a vertical composition of tapes, as illustrated below on the left.
The diagonal \(\lhd _{U} :U \!\rightarrow \! U \oplus U\) is represented as a splitting of tapes, while the bang https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figay_HTML.gif is a tape closed on its right boundary. Codiagonals and cobangs are represented in the same way but mirrored along the y-axis. Exploiting the usual coherence conditions e.g. in [55, Table 4.7], we can construct (co)diagonals and (co)bangs for arbitrary polynomials. For example, \(\rhd _{A\oplus B \oplus C}\) and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figaz_HTML.gif are depicted as the second and third diagrams above.
The copier https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figba_HTML.gif is represented as a splitting of wires, while the discharger https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbb_HTML.gif is a wire closed on the right. From the coherence laws in (15), one can build (co)copiers and (co)dischargers for arbitrary polynomials. For instance, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbc_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbd_HTML.gif are drawn as the last two diagrams above. For an arbitrary tape diagram \(\mathfrak {t}:P \rightarrow Q\) we write https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbe_HTML.gif .
The graphical representation embodies several axioms such as those of monoidal categories and several axioms for traces. Those axioms which are not implicit in the graphical representation are illustrated in Figures 2 and 3. Figure 4 illustrates the uniformity laws in the form of tape diagrams.
Fig. 2.
Tape axioms for Kleene bicategory
Fig. 3.
Axioms of Cartesian bicategories
Fig. 4.
Posetal uniformity axioms in tape diagrams.

6.2 Kleene-Cartesian Theories and Functorial Semantics

A Kleene-Cartesian theory, shortly kc theory, is a pair \((\Sigma , \mathbb {I})\) where \(\Sigma \) is a monoidal signature and \(\mathbb {I}\) is a set of pairs \((\mathfrak {t}_1, \mathfrak {t}_2)\) of tapes with same domain and codomain. Hereafter, we think of each pair \((\mathfrak {t}_1, \mathfrak {t}_2)\) as an inequation \(\mathfrak {t}_1 \le \mathfrak {t}_2\), but the results that we develop in this section trivially hold also for equations: it is enough to add in \(\mathbb {I}\) a pair \((\mathfrak {t}_2, \mathfrak {t}_1)\) for each \((\mathfrak {t}_1, \mathfrak {t}_2) \in \mathbb {I}\). Hereafter we always keep implicit \(\mathbb{K}\mathbb{C}\) and we write \(\,{\le }_{{\mathbb {I}}}\,\) for \(\,{\le }_{\mathbb{K}\mathbb{C}\cup \mathbb {I}}\,\) where the latter is defined as in (17). We fix \(\sim _{\mathbb {I}}{\mathop {=}\limits ^{\tiny \text {def}}}\le _{\mathbb {I}}\cap \ge _{\mathbb {I}}\).
Recall that an interpretation \(\mathcal {I}=(\alpha _{\mathcal {S}}, \alpha _{\Sigma })\) of a monoidal signature \((\mathcal {S},\Sigma )\) in a sesquistrict rig category \(\textbf{C}\) consists of \(\alpha _{\mathcal {S}}:\mathcal {S}\rightarrow Ob(\textbf{C})\) and \(\alpha _{\Sigma }:\Sigma \rightarrow Ar(\textbf{C})\). Whenever \(\textbf{C}\) is a kc rig category, \(\mathcal {I}\) gives rises uniquely, by freeness of \(\textbf{KCT}_{\Sigma }\), to a morphism of kc rig categories \( \llbracket \cdot \rrbracket _{\mathcal {I}} :\textbf{KCT}_{\Sigma }\rightarrow \textbf{C}\) defined as:
We say that an intepretation \(\mathcal {I}\) of \(\Sigma \) is a model of the theory \((\Sigma , \mathbb {I})\) whenever \( \llbracket \cdot \rrbracket _{\mathcal {I}}\) preserves \(\,{\le }_{{\mathbb {I}}}\,\): if \(\mathfrak {t}_1 \,{\le }_{{\mathbb {I}}}\,\mathfrak {t}_2\), then \( \llbracket \mathfrak {t}_1 \rrbracket _{\mathcal {I}} \) is below \( \llbracket \mathfrak {t}_2 \rrbracket _{\mathcal {I}}\) in \(\textbf{C}\). Models enjoy a beautiful characterisation provided by Proposition 3 below. Let \(\textbf{KCT}_{\Sigma ,\mathbb {I}}\) be the category having the same objects as \(\textbf{KCT}_{\Sigma }\) and arrows \(\sim _{\mathbb {I}}\)-equivalence classes of arrows of \(\textbf{KCT}_{\Sigma }\) ordered by \(\,{\le }_{{\mathbb {I}}}\,\). Since \(\textbf{KCT}_{\Sigma }\) is a kc rig category, then also \(\textbf{KCT}_{\Sigma ,\mathbb {I}}\) is so.
Proposition 3
Let \((\Sigma , \mathbb {I})\) be a kc tape theory and \(\textbf{C}\) a sesquistrict kc rig category. Models of \((\Sigma , \mathbb {I})\) are in bijective correspondence with morphisms of sesquistrict kc rig categories from \(\textbf{KCT}_{\Sigma ,\mathbb {I}}\) to \(\textbf{C}\).
Example 1 (Functions)
[Functions] Let \(\mathcal {S}\) be a set of sorts and \(\Sigma {\mathop {=}\limits ^{\tiny \text {def}}}\{f:U \rightarrow A\}\) for some \(A\in \mathcal {S}\) and \(U\in S^\star \). Let \(\mathbb {I}\) be the set of the two equalities in (18). An interpretation \(\mathcal {I}\) of \((\mathcal {S},\Sigma )\) in \(\textbf{Rel}\), consists of a set \(\alpha _\mathcal {S}(A_i)\) for each \(A_i\in \mathcal {S}\) and a relation \(\alpha _\Sigma (f) \subseteq \alpha _{\mathcal {S}}^\sharp (U) \times \alpha _{\mathcal {S}}(A)\). \(\mathcal {I}\) is a model of \((\Sigma ,\mathbb {I})\) iff \(\alpha _\Sigma (f)\) is single valued (SV) and total (TOT), i.e., a function.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Equ9_HTML.png
(18)
Example 2 (KAT)
Let \(\mathcal {P}\) be a set of predicate symbols \(R:U \rightarrow 1\) for \(U\in \mathcal {S}^\star \). Take \(\bar{\mathcal {P}}{\mathop {=}\limits ^{\tiny \text {def}}}\{\bar{R}:U \rightarrow 1\mid R\in \mathcal {P}\}\) and \(\Sigma {\mathop {=}\limits ^{\tiny \text {def}}}\mathcal {P}\cup \bar{\mathcal {P}}\). Let \(\mathbb {I}\) be the set of equalities below.
An interpretation \(\mathcal {I}\) of \((\mathcal {S},\Sigma )\) in \(\textbf{Rel}\) is a set \(\alpha _\mathcal {S}(A_i)\) for each \(A_i\in \mathcal {S}\) together with predicates \(R \subseteq X\times 1\) and \(\bar{R} \subseteq X\times 1\) for \(X{\mathop {=}\limits ^{\tiny \text {def}}}\alpha _\mathcal {S}^\sharp (U)\). \(\mathcal {I}\) is a model iff, for all \(R\), \(\bar{R}\) is its set-theoretic complement: by (13) and (5), the equalities above asserts that \(R \cup \bar{R}=X\) and \(R \cap \bar{R}=\{\}\). By Proposition 2, \(\textbf{KCT}_{\Sigma ,\mathbb {I}}[U,1]\) carries a distributive lattice and even a Boolean algebra when defining \(\lnot P\), for all \(P:U \rightarrow 1\) as follows.
Consider the set \(C\) that contains, for each \(P :U \rightarrow 1\), the associated coreflexive:
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Equ10_HTML.png
(21)
Again coreflexives form a Boolean algebra \((C,\sqcup , \mathbin {;}, \lnot , \bot , {id} )\) where composition \(\mathbin {;}\) acts as \(\sqcap \): see Lemma 2.3. Moreover, by Corollary 1, \(\textbf{KCT}_{\Sigma ,\mathbb {I}}[U,U]\) is a Kleene algebra. Thus \((\textbf{KCT}_{\Sigma ,\mathbb {I}}[U,U], C, \sqcup , \mathbin {;}, (\cdot )^{*}, \bot , {id} , \lnot )\) is a Kleene algebra with tests [42].
Remark 2
Recall \(\textsf{CR}\) from Section 2. The set \(\Sigma \) of generating symbols corresponds to a monoidal signature where \(\mathcal {S}=\{A\}\) and each symbol has both arity and coarity A. A relational interpretation of \(\textsf{CR}\) is exactly an interpretation \(\mathcal {I}\) of the monoidal signature \((\mathcal {S},\Sigma )\) into \(\textbf{Rel}\). One can define an inductive encoding \(\mathcal {E}(\cdot )\) from \(\textsf{CR}\) to \(\textbf{KCT}_{\Sigma }\) by using (5) and (13). A simple inductive argument confirms that, for all interpretations \(\mathcal {I}\) and expressions \(E\in \textsf{CR}\), \(\langle E\rangle _\mathcal {I} = \llbracket \mathcal {E}(E) \rrbracket _{\mathcal {I}}\). Thus, if \(\mathcal {E}(E_1)\le _{\mathbb{K}\mathbb{C}}\mathcal {E}(E_2)\), then \(E_1 \le _{\textsf{CR}} E_2\).

7 The Kleene-Cartesian Theory of Peano

In this section we illustrate a further example of kc theory: Peano’s axiomatisation of natural numbers. Recall that such axiomatisation is not a first order theory [32].
We commence by fixing the signature: \(\mathcal {S}{\mathop {=}\limits ^{\tiny \text {def}}}\{A\}\) and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbi_HTML.gif . An interpretation of \(\Sigma \) in \(\textbf{Rel}\) consists of a set X (i.e., \(\alpha _\mathcal {S}(A)\)), a relation \(0 \subseteq 1 \times X\) (i.e., https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbj_HTML.gif ) and a relation \(s\subseteq X \times X\) (i.e., https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbk_HTML.gif ).
Fig. 5.
The Kleene-Cartesian theory of Peano.
The set of axioms \(\mathbb {P}\) consists of those in Figure 5.
From a universal-algebraic perspective, natural numbers are the smallest set X such that X is isomorphic to \(X \oplus 1\). The two leftmost axioms in Figure 5 force \([s,0] {\mathop {=}\limits ^{\tiny \text {def}}}(s \oplus 0) ; \rhd _{X}\) to be an isomorphism of type \(X \oplus 1\rightarrow X\): (iso-1) states that \([s,0]^{\dagger }\mathbin {;}[s,0] = {id}_{X}\); (iso-2) that \([s,0]\mathbin {;}[s,0]^{\dagger }= {id}_{X \oplus 1}\); the rightmost the fact that it is the smallest: i.e. \(X \subseteq 0 \mathbin {;}s^* :1\rightarrow X\). One can similarly obtain any algebraic data type.
We illustrate that \((\Sigma , \mathbb {P})\) is equivalent to Peano’s axiomatisation of natural numbers. Possibly, the most interesting axiom is the principle of induction: (ind-princ) in Figure 6. This follows easily from posetal uniformity and (ind).
Theorem 3 (Principle of Induction)
Let \((\Pi , \mathbb {Q})\) be a kc theory, such that \(\Sigma \subseteq \Pi \) and \(\mathbb {P}\subseteq \mathbb {Q}\). For all \(P:1\rightarrow A\) in \(\textbf{KCT}_{\Pi ,\mathbb {Q}}\), (ind-princ) in Figure 6 holds
Proof
Observe that the following holds:
Thus, by (AU2) the inclusion below holds and the derivation concludes the proof.
The other Peano’s axioms state that 0 is a natural number, s is an injective function and that 0 is not the successor of any natural number. These are illustrated by means of tapes in Figure 6, where we use the characterisation of total, single valued and injective relations provided by Lemma 1. Observe that (\(\bot \)) states that \(\{x\in X \mid (x,0)\in s \} \subseteq \emptyset \).
Lemma 3
The laws in Figures 5 and 6 are equivalent.
In [25], Dedekind showed that any two models of Peano’s axioms are isomorphic, and thus any model of \((\Sigma , \mathbb {P})\) is isomorphic to the one on natural numbers.
Fig. 6.
Peano’s theory of the natural numbers.
To give to the reader a taste of how one can program with tapes, we now illustrate how to start to encode arithmetic within \((\Sigma , \mathbb {P})\). The tape for addition is illustrated on the right. Such tape can be thought as a simple imperative program:
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Equ11_HTML.png
(22)
add(x,y) = while (x>0) { x:=x-1; y:=y+1 }; return y
The variable x corresponds to the top wire in (22), while y to the bottom one. At any iteration, the program checks whether x is 0, in which case it returns y, or the successor of some number, in which case x takes such number, while y takes its own successor.
In [9, Lemma 10.3] we show that (22) satisfies the usual inductive definition of addition, namely:
While, it is straightforward that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbo_HTML.gif terminates on all possible inputs, it is interesting to see how this can be proved within the kc theory \((\Sigma ,\mathbb {P})\).
Lemma 4
The tape https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbp_HTML.gif is total, i.e. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbq_HTML.gif .
Proof
First observe that the following holds:
Then, by (AU1), the inequality below holds and the derivation concludes the proof.

8 Diagrammatic Hoare Logic

We now illustrate how tape diagrams can provide a comfortable setting to reason about imperative programs. For the sake of generality, we avoid to fix basic types and operations and, rather, we work parametrically with respect to a triple \((\mathcal {S},\mathcal {F},\mathcal {P})\): \(\mathcal {S}\) is a set of sorts, representing basic types; \(\mathcal {F}\) is a set of function symbols, equipped with an arity in \(\mathcal {S}^*\) and a coarity in \(\mathcal {S}\); \(\mathcal {P}\) is a set of predicate symbols equipped just with an arity in \(\mathcal {S}^*\). The coarity of predicates is fixed to be 1.
We take the signature \(\Sigma {\mathop {=}\limits ^{\tiny \text {def}}}\mathcal {F} \cup \mathcal {P} \cup \bar{\mathcal {P}}\) where \(\bar{\mathcal {P}}\) is as in Example 2. The set \(\mathbb {I}\) contains, for all \(f:U \rightarrow A\) in \(\mathcal {F}\), the axioms in (18) and, for each \(R:U \rightarrow 1\) in \(\mathcal {P}\), those in (19). One may add to \(\mathbb {I}\) other axioms, e.g., those of \(\mathbb {P}\) in Section 7.
We consider terms generated by the following grammar
$$ \begin{array}{rcl} e & ::=& x \mid f(e_{1}, \ldots , e_{n})\\ P & ::=& R(e_1, \dots , e_n) \mid \bar{R}(e_1, \dots , e_n) \mid \top \mid \bot \mid P \vee P \mid P \wedge P \\ C & ::=& \textsf{abort} \mid \textsf{skip} \mid \mathop {\textsf{if}} P \mathop {\textsf{then}} C \mathop {\textsf{else}} D \mid \mathop {\textsf{while}} P \mathop {\textsf{do}} C \mid C ; D \mid x :==e \end{array} $$
where \(f\in \mathcal {F}\), \(R\in \mathcal {P}\) and x is taken from a fixed set of variables. As usual, e are expressions, P predicates and C commands. Negation of predicates can be expressed as in (20). In order to encode terms into diagrams, we need to make copying and discarding of variables explicit; we thus define a simple type systems with judgement of the form
$$\begin{aligned} \Gamma \vdash e :A \qquad \Gamma \vdash P :1 \qquad \Gamma \vdash C \end{aligned}$$
where A is a sort in \(\mathcal {S}\) and \(\Gamma \) is a typing context, i.e., an ordered sequence \(x_1:A_1, \dots x_n :A_n\), where all the \(x_i\) are distinct variables and \(A_i \in \mathcal {S}\). The type system is in Table 4.
Table 4.
Type system for expressions, predicates and commands.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Tab4_HTML.png
Dummy
Table 5.
Encoding of expressions, predicates and commands into diagrams.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Tab5_HTML.png
Dummy
The encoding of terms into diagrams, presented in Table 5, is defined inductively on the typing rules. For instance, in the encoding of the assignment \(\Gamma \vdash x :==e\), the context is \(\Gamma = \Gamma ', x :A, \Delta '\), according to the typing rule (Assn).
The encoding \(\mathcal {E}(\cdot )\) maps well typed expressions \(\Gamma \vdash e :A\), predicates \(\Gamma \vdash P :1\) and commands \(\Gamma \vdash C \) into, respectively, diagrams of the following types
$$\begin{aligned} \mathcal {E}(\Gamma ) \rightarrow A \qquad \mathcal {E}(\Gamma ) \rightarrow 1 \qquad \mathcal {E}(\Gamma ) \rightarrow \mathcal {E}(\Gamma ) \end{aligned}$$
where for \(\Gamma =x_1:A_1, \dots , x_n :A_n\), we fix \(\mathcal {E}(\Gamma ) {\mathop {=}\limits ^{\tiny \text {def}}}A_1 \otimes \dots \otimes A_n\). In the encoding of expressions and predicates, we use https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbv_HTML.gif to copy n times the content of variables in \(\Gamma \). Formally, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbw_HTML.gif is defined as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figbx_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Figby_HTML.gif . Guards in commands are encoded using c(P), defined in (21). The encoding of commands is pretty standard, see e.g. [42], with the only exception of assignment that is depicted as the diagram on the right where, for the sake of readability, we label wires directly with the typing contexts rather than their encodings. Note that, in this case, \(\mathcal {E}(\cdot )\) exploits the structure of Cartesian bicategories to properly take into account data flow. For instance, for \(\Gamma =x:A,y:A,z:A\), the encoding maps \(\Gamma \vdash x :==z ; y:==z\) and \(\Gamma \vdash y :==z ; x :==z\) into the same tape.
The following lemma illustrates the interaction of substitutions with the encoding.
Lemma 5
Let \(\Gamma ' = \Gamma , x:A, \Delta \). If \(\Gamma ' \vdash P:1\) and \(\Gamma ' \vdash t:A\), then
Hoare logic [35] is one of the most influential languages to reason about imperative programs. Its rules –in the version appearing in [57]– are in Figure 6. In partial correctness, a triple \(\{P\}C\{Q\}\) asserts that if, starting from a state satisfying the precondition P, the execution of C terminates, then the resulting state satisfies the postcondition Q.
The following result shows that
Table 6.
Rules of Hoare logic
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Tab6_HTML.png
Dummy
Proposition 4
If \(\{P\}C\{Q\}\) is derivable as in Figure 6, then \(\mathcal {E}(P)^{\dagger } \mathbin {;}\mathcal {E}(C) \le _{\mathbb {I}} \mathcal {E}(Q)^{\dagger }\).
Proof
By induction on the rules in Table 6. We illustrate only two cases: the others can be found in the proof of [9, Proposition 11.5]. For (\(\textsf{assn}\)), observe that by Lemma 5, \(\mathcal {E}(P[e/x])^{\dagger } \mathbin {;}\mathcal {E}(x :==e)\) is the leftmost diagram below. Thus:
For (\(\textsf{while}\)), observe that the following holds:
Then, by (AU2), the inequality below holds and the derivation concludes the proof.
Remark 3 (Other Program Logics)
The above result proves a syntactic correspondence amongst the deduction systems in Table 6 and \(\le _{\mathbb {I}}\). To prove such result we did not need to explicitly give the semantics of command or prove that our encoding preserves the semantics. However, assuming that, for a fixed interpretation \(\mathcal {I}\), \( \llbracket \mathcal {E}(\Gamma \vdash C) \rrbracket _{\mathcal {I}} \) is the intended relational semantics of a command C, one can immediately see that the correspondence at the semantic level –illustrated below on the top-left corner– holds.
$$\begin{array}{rclcrcl} \{P\}C\{Q\} & \text { iff }& \llbracket \mathcal {E}(P)^{\dagger } \mathbin {;}\mathcal {E}(C) \rrbracket _{\mathcal {I}} \subseteq \llbracket \mathcal {E}(Q)^{\dagger } \rrbracket _{\mathcal {I}} & \quad & \langle \!\langle P \rangle \!\rangle C \langle \!\langle Q \rangle \!\rangle & \text { iff } & \llbracket \mathcal {E}(P) \rrbracket _{\mathcal {I}} \subseteq \llbracket \mathcal {E}(C)\mathbin {;}\mathcal {E}(Q) \rrbracket _{\mathcal {I}} \\ \text {[}P\text {]} C \text {[}Q\text {]} & \text { iff }& \llbracket \mathcal {E}(P)^{\dagger } \mathbin {;}\mathcal {E}(C) \rrbracket _{\mathcal {I}} \supseteq \llbracket \mathcal {E}(Q)^{\dagger } \rrbracket _{\mathcal {I}} & \quad & (P)C(Q) & \text { iff } & \llbracket \mathcal {E}(P) \rrbracket _{\mathcal {I}} \supseteq \llbracket \mathcal {E}(C)\mathbin {;}\mathcal {E}(Q) \rrbracket _{\mathcal {I}} \\ \end{array} $$
The other correspondences concern other logics: \(\text {[}P\text {]} C \text {[}Q\text {]}\) are triples of incorrectness logic [50], \(\langle \!\langle P \rangle \!\rangle C \langle \!\langle Q \rangle \!\rangle \) of sufficient incorrectness [2] and \((P)C(Q)\) of necessary [24]. Interestingly, quadruples of relational Hoare logics [7] can be characterised as
$$\begin{aligned} \llbracket \mathcal {E}(\Gamma _1, \Gamma _2 \vdash P:1)^{\dagger } \mathbin {;}\mathcal {E}(\Gamma _1 \vdash C_1) \otimes \mathcal {E}(\Gamma _2 \vdash C_2) \rrbracket _{\mathcal {I}} \subseteq \llbracket \mathcal {E}(\Gamma _1, \Gamma _2 \vdash Q:1)^{\dagger } \rrbracket \end{aligned}$$
(23)

9 Concluding remarks

We introduced Kleene bicategories and proved that they form Kleene algebras in Kozen’s sense (Corollary 1). By examining their interaction with Cartesian bicategories, we developed Kleene-Cartesian rig categories and characterised the free one as tape diagrams (Theorem 2). Furthermore, we showed that tape diagrams can express Kleene algebra with tests [42], Peano’s natural numbers, and various program logics. We proved that the rules of Hoare logic follow from the structure of kc rig categories (Proposition 4).
Regarding Kleene bicategories, while we are not the first to explore uniform traces over biproduct categories (see, e.g., [20]), the use of posetal uniformity and the correspondence with Kozen’s axioms are, to the best of our knowledge, novel contributions.
Computer scientists usually find control flow and data flow graphs intuitive. Tapes diagram combine the two in a single diagrammatic representation equipped with compositional semantics. Another key distinction of tape diagrams, compared to other relational or categorical approaches to program logics (e.g., [1, 5, 31, 34, 44, 49]), lies in the \(\otimes \) monoidal and rig structures, which enable direct representation of product programs [6]. Through tape (in)equalities and \(\otimes \), it becomes easy to express complex properties like non-interference [30]. Exploring how such properties can be proved by the laws of kc rig categories remains a promising direction for future research.
Table 7.
Axioms for Kleene-Cartesian Tapes. For each axiom \(l=r\) in top-left corner, the set \(\mathbb{K}\mathbb{C}\) contains the pairs (lr) and (rl) where \(\odot \) and \(I\) are replaced by \(\oplus \) and \(0\) and the pairs \((\overline{\underline{\; l \;}},\overline{\underline{\; r \;}})\) and \((\overline{\underline{\; r \;}},\overline{\underline{\; l \;}})\) where \(\odot \) and \(I\) are replaced by \(\otimes \) and \(1\). In the rest, for each \(l\le r\) \(\mathbb{K}\mathbb{C}\) contains a pair (lr) and, additionally, the pair (rl) in case of an axiom \(l=r\).
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-031-90897-2_15/MediaObjects/648523_1_En_15_Tab7_HTML.png
Dummy

Acknowledgements

The authors would like to acknowledge Alessio Santamaria, Chad Nester and the students of the ACT school 2022 for several useful discussions at early stage of this project. Gheorghe Stefanescu and Dexter Kozen provided some wise feedback and offered some guidance through the rather wide literature. This research was partly funded by the Advanced Research + Invention Agency (ARIA) Safeguarded AI Programme and carried out within the National Centre on HPC, Big Data and Quantum Computing - SPOKE 10 (Quantum Computing) and by the EU Next-GenerationEU - National Recovery and Resilience Plan (NRRP) - MISSION 4 COMPONENT 2, INVESTMENT N. 1.4 - CUP N. I53C22000690001 and by the EPSRC grant No. EP/V002376/1. Bonchi is supported by the Ministero dell’Università e della Ricerca of Italy grant PRIN 2022 PNRR No. P2022HXNSC - RAP (Resource Awareness in Programming). Di Giorgio is supported by the EU grant No. 101087529.
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.
Fußnoten
1
These rules are at the end of the paper, since we will soon draw them as diagrams.
 
Literatur
1.
Zurück zum Zitat Aguirre, A., Katsumata, S.y.: Weakest preconditions in fibrations. Electronic Notes in Theoretical Computer Science 352, 5–27 (2020) Aguirre, A., Katsumata, S.y.: Weakest preconditions in fibrations. Electronic Notes in Theoretical Computer Science 352, 5–27 (2020)
2.
Zurück zum Zitat Ascari, F., Bruni, R., Gori, R., Logozzo, F.: Sufficient incorrectness logic: SIL and separation SIL (2023) Ascari, F., Bruni, R., Gori, R., Logozzo, F.: Sufficient incorrectness logic: SIL and separation SIL (2023)
3.
Zurück zum Zitat Backens, M.: The zx-calculus is complete for stabilizer quantum mechanics. New Journal of Physics 16(9), 093021 (2014) Backens, M.: The zx-calculus is complete for stabilizer quantum mechanics. New Journal of Physics 16(9), 093021 (2014)
4.
Zurück zum Zitat Bainbridge, E.S.: Feedback and generalized logic. Information and Control 31(1), 75–96 (1976) Bainbridge, E.S.: Feedback and generalized logic. Information and Control 31(1), 75–96 (1976)
5.
Zurück zum Zitat Barrett, C., Castle, D., Heijltjes, W.: The relational machine calculus. In: Sobocinski, P., Lago, U.D., Esparza, J. (eds.) Proceedings of the 39th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2024, Tallinn, Estonia, July 8-11, 2024. pp. 9:1–9:15. ACM (2024). https://doi.org/10.1145/3661814.3662091 Barrett, C., Castle, D., Heijltjes, W.: The relational machine calculus. In: Sobocinski, P., Lago, U.D., Esparza, J. (eds.) Proceedings of the 39th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2024, Tallinn, Estonia, July 8-11, 2024. pp. 9:1–9:15. ACM (2024). https://​doi.​org/​10.​1145/​3661814.​3662091
6.
Zurück zum Zitat Barthe, G., Crespo, J.M., Kunz, C.: Relational verification using product programs. In: International Symposium on Formal Methods. pp. 200–214. Springer (2011) Barthe, G., Crespo, J.M., Kunz, C.: Relational verification using product programs. In: International Symposium on Formal Methods. pp. 200–214. Springer (2011)
7.
Zurück zum Zitat Benton, N.: Simple relational correctness proofs for static analyses and program transformations. ACM SIGPLAN Notices 39(1), 14–25 (2004) Benton, N.: Simple relational correctness proofs for static analyses and program transformations. ACM SIGPLAN Notices 39(1), 14–25 (2004)
8.
Zurück zum Zitat Bloom, S.L., Ésik, Z., Stefanescu, G.: Notes on equational theories of relations. Algebra Universalis 33(1), 98–126 (1995) Bloom, S.L., Ésik, Z., Stefanescu, G.: Notes on equational theories of relations. Algebra Universalis 33(1), 98–126 (1995)
10.
Zurück zum Zitat Bonchi, F., Di Giorgio, A., Haydon, N., Sobocinski, P.: Diagrammatic algebra of first order logic. In: Sobocinski, P., Lago, U.D., Esparza, J. (eds.) Proceedings of the 39th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2024, Tallinn, Estonia, July 8-11, 2024. pp. 16:1–16:15. ACM (2024). https://doi.org/10.1145/3661814.3662078 Bonchi, F., Di Giorgio, A., Haydon, N., Sobocinski, P.: Diagrammatic algebra of first order logic. In: Sobocinski, P., Lago, U.D., Esparza, J. (eds.) Proceedings of the 39th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2024, Tallinn, Estonia, July 8-11, 2024. pp. 16:1–16:15. ACM (2024). https://​doi.​org/​10.​1145/​3661814.​3662078
11.
Zurück zum Zitat Bonchi, F., Di Giorgio, A., Santamaria, A.: Deconstructing the calculus of relations with tape diagrams. Proceedings of the ACM on Programming Languages 7(POPL), 1864–1894 (2023) Bonchi, F., Di Giorgio, A., Santamaria, A.: Deconstructing the calculus of relations with tape diagrams. Proceedings of the ACM on Programming Languages 7(POPL), 1864–1894 (2023)
12.
Zurück zum Zitat Bonchi, F., Holland, J., Piedeleu, R., Sobociński, P., Zanasi, F.: Diagrammatic algebra: From linear to concurrent systems. Proceedings of the ACM on Programming Languages 3(POPL), 25:1–25:28 (Jan 2019). https://doi.org/10.1145/3290338 Bonchi, F., Holland, J., Piedeleu, R., Sobociński, P., Zanasi, F.: Diagrammatic algebra: From linear to concurrent systems. Proceedings of the ACM on Programming Languages 3(POPL), 25:1–25:28 (Jan 2019). https://​doi.​org/​10.​1145/​3290338
13.
14.
Zurück zum Zitat Bonchi, F., Piedeleu, R., Sobociński, P., Zanasi, F.: Graphical affine algebra. In: Proceedings of the 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). pp. 1–12 (2019) Bonchi, F., Piedeleu, R., Sobociński, P., Zanasi, F.: Graphical affine algebra. In: Proceedings of the 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). pp. 1–12 (2019)
15.
Zurück zum Zitat Bonchi, F., Seeber, J., Sobocinski, P.: Graphical Conjunctive Queries. In: Ghica, D., Jung, A. (eds.) 27th EACSL Annual Conference on Computer Science Logic (CSL 2018). Leibniz International Proceedings in Informatics (LIPIcs), vol. 119, pp. 13:1–13:23. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany (2018). https://doi.org/10.4230/LIPIcs.CSL.2018.13 Bonchi, F., Seeber, J., Sobocinski, P.: Graphical Conjunctive Queries. In: Ghica, D., Jung, A. (eds.) 27th EACSL Annual Conference on Computer Science Logic (CSL 2018). Leibniz International Proceedings in Informatics (LIPIcs), vol. 119, pp. 13:1–13:23. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany (2018). https://​doi.​org/​10.​4230/​LIPIcs.​CSL.​2018.​13
16.
Zurück zum Zitat Bonchi, F., Sobocinski, P., Zanasi, F.: Full abstraction for signal flow graphs. ACM SIGPLAN Notices 50(1), 515–526 (2015) Bonchi, F., Sobocinski, P., Zanasi, F.: Full abstraction for signal flow graphs. ACM SIGPLAN Notices 50(1), 515–526 (2015)
17.
Zurück zum Zitat Brunet, P., Pous, D.: Kleene algebra with converse. In: Relational and Algebraic Methods in Computer Science: 14th International Conference, RAMiCS 2014, Marienstatt, Germany, April 28–May 1, 2014. Proceedings 14. pp. 101–118. Springer (2014) Brunet, P., Pous, D.: Kleene algebra with converse. In: Relational and Algebraic Methods in Computer Science: 14th International Conference, RAMiCS 2014, Marienstatt, Germany, April 28–May 1, 2014. Proceedings 14. pp. 101–118. Springer (2014)
18.
Zurück zum Zitat Bruni, R., Melgratti, H., Montanari, U.: Connector algebras, Petri nets, and BIP. In: International Andrei Ershov Memorial Conference on Perspectives of System Informatics. pp. 19–38. Springer (2011) Bruni, R., Melgratti, H., Montanari, U.: Connector algebras, Petri nets, and BIP. In: International Andrei Ershov Memorial Conference on Perspectives of System Informatics. pp. 19–38. Springer (2011)
19.
Zurück zum Zitat Carboni, A., Walters, R.F.C.: Cartesian bicategories I. Journal of Pure and Applied Algebra 49, 11–32 (1987) Carboni, A., Walters, R.F.C.: Cartesian bicategories I. Journal of Pure and Applied Algebra 49, 11–32 (1987)
20.
Zurück zum Zitat Căzănescu, V.E., Ştefănescu, G.: Feedback, iteration, and repetition. In: Mathematical aspects of natural and formal languages, pp. 43–61. World Scientific (1994) Căzănescu, V.E., Ştefănescu, G.: Feedback, iteration, and repetition. In: Mathematical aspects of natural and formal languages, pp. 43–61. World Scientific (1994)
21.
Zurück zum Zitat Cockett, J.R.B., Koslowski, J., Seely, R.A.: Introduction to linear bicategories. Mathematical Structures in Computer Science 10(2), 165–203 (2000) Cockett, J.R.B., Koslowski, J., Seely, R.A.: Introduction to linear bicategories. Mathematical Structures in Computer Science 10(2), 165–203 (2000)
22.
Zurück zum Zitat Coecke, B., Duncan, R.: Interacting quantum observables: categorical algebra and diagrammatics. New Journal of Physics 13(4), 043016 (2011) Coecke, B., Duncan, R.: Interacting quantum observables: categorical algebra and diagrammatics. New Journal of Physics 13(4), 043016 (2011)
24.
Zurück zum Zitat Cousot, P., Cousot, R., Fähndrich, M., Logozzo, F.: Automatic inference of necessary preconditions. In: Giacobazzi, R., Berdine, J., Mastroeni, I. (eds.) Verification, Model Checking, and Abstract Interpretation, 14th International Conference, VMCAI 2013, Rome, Italy, January 20-22, 2013. Proceedings. Lecture Notes in Computer Science, vol. 7737, pp. 128–148. Springer (2013). https://doi.org/10.1007/978-3-642-35873-9_10 Cousot, P., Cousot, R., Fähndrich, M., Logozzo, F.: Automatic inference of necessary preconditions. In: Giacobazzi, R., Berdine, J., Mastroeni, I. (eds.) Verification, Model Checking, and Abstract Interpretation, 14th International Conference, VMCAI 2013, Rome, Italy, January 20-22, 2013. Proceedings. Lecture Notes in Computer Science, vol. 7737, pp. 128–148. Springer (2013). https://​doi.​org/​10.​1007/​978-3-642-35873-9_​10
25.
Zurück zum Zitat Dedekind, R.: The nature and meaning of numbers (1888) Dedekind, R.: The nature and meaning of numbers (1888)
26.
Zurück zum Zitat Fong, B., Spivak, D.: String diagrams for regular logic (extended abstract). In: Baez, J., Coecke, B. (eds.) Applied Category Theory 2019. Electronic Proceedings in Theoretical Computer Science, vol. 323, p. 196-229. Open Publishing Association (Sep 2020). https://doi.org/10.4204/eptcs.323.14 Fong, B., Spivak, D.: String diagrams for regular logic (extended abstract). In: Baez, J., Coecke, B. (eds.) Applied Category Theory 2019. Electronic Proceedings in Theoretical Computer Science, vol. 323, p. 196-229. Open Publishing Association (Sep 2020). https://​doi.​org/​10.​4204/​eptcs.​323.​14
28.
Zurück zum Zitat Fritz, T.: A presentation of the category of stochastic matrices. CoRR abs/0902.2554 (2009) Fritz, T.: A presentation of the category of stochastic matrices. CoRR abs/0902.2554 (2009)
30.
Zurück zum Zitat Goguen, J.A., Meseguer, J.: Unwinding and inference control. In: 1984 IEEE Symposium on Security and Privacy. pp. 75–75. IEEE (1984) Goguen, J.A., Meseguer, J.: Unwinding and inference control. In: 1984 IEEE Symposium on Security and Privacy. pp. 75–75. IEEE (1984)
31.
Zurück zum Zitat Goncharov, S., Schröder, L.: A relatively complete generic hoare logic for order-enriched effects. In: 2013 28th Annual ACM/IEEE Symposium on Logic in Computer Science. pp. 273–282. IEEE (2013) Goncharov, S., Schröder, L.: A relatively complete generic hoare logic for order-enriched effects. In: 2013 28th Annual ACM/IEEE Symposium on Logic in Computer Science. pp. 273–282. IEEE (2013)
32.
Zurück zum Zitat Harsanyi, J.C.: Mathematics, the empirical facts, and logical necessity. Erkenntnis 19(1), 167–192 (1983) Harsanyi, J.C.: Mathematics, the empirical facts, and logical necessity. Erkenntnis 19(1), 167–192 (1983)
33.
Zurück zum Zitat Hasegawa, M.: The uniformity principle on traced monoidal categories. Electronic Notes in Theoretical Computer Science 69, 137–155 (2003) Hasegawa, M.: The uniformity principle on traced monoidal categories. Electronic Notes in Theoretical Computer Science 69, 137–155 (2003)
34.
Zurück zum Zitat Hasuo, I.: Generic weakest precondition semantics from monads enriched with order. Theoretical Computer Science 604, 2–29 (2015) Hasuo, I.: Generic weakest precondition semantics from monads enriched with order. Theoretical Computer Science 604, 2–29 (2015)
35.
Zurück zum Zitat Hoare, C.A.R.: An axiomatic basis for computer programming. Communications of the ACM 12(10), 576–580 (1969) Hoare, C.A.R.: An axiomatic basis for computer programming. Communications of the ACM 12(10), 576–580 (1969)
39.
Zurück zum Zitat Joyal, A., Street, R., Verity, D.: Traced monoidal categories. Math Procs Cambridge Philosophical Society 119(3), 447–468 (4 1996) Joyal, A., Street, R., Verity, D.: Traced monoidal categories. Math Procs Cambridge Philosophical Society 119(3), 447–468 (4 1996)
40.
Zurück zum Zitat Katis, P., Sabadini, N., Walters, R.F.: Bicategories of processes. Journal of Pure and Applied Algebra 115(2), 141–178 (1997) Katis, P., Sabadini, N., Walters, R.F.: Bicategories of processes. Journal of Pure and Applied Algebra 115(2), 141–178 (1997)
41.
Zurück zum Zitat Kozen, D.: A completeness theorem for kleene algebras and the algebra of regular events. Information and Computation 110, 366–390 (1994) Kozen, D.: A completeness theorem for kleene algebras and the algebra of regular events. Information and Computation 110, 366–390 (1994)
42.
Zurück zum Zitat Kozen, D.: Kleene algebra with tests. ACM Transactions on Programming Languages and Systems (TOPLAS) 19(3), 427–443 (1997) Kozen, D.: Kleene algebra with tests. ACM Transactions on Programming Languages and Systems (TOPLAS) 19(3), 427–443 (1997)
43.
Zurück zum Zitat Kozen, D.: Typed Kleene algebra. Tech. Rep. TR98-1669, Computer Science Department, Cornell University (March 1998) Kozen, D.: Typed Kleene algebra. Tech. Rep. TR98-1669, Computer Science Department, Cornell University (March 1998)
44.
Zurück zum Zitat Kozen, D.: On Hoare logic and Kleene algebra with tests. Trans. Computational Logic 1(1), 60–76 (July 2000) Kozen, D.: On Hoare logic and Kleene algebra with tests. Trans. Computational Logic 1(1), 60–76 (July 2000)
45.
Zurück zum Zitat Lack, S.: Composing PROPs. Theory and Application of Categories 13(9), 147–163 (2004) Lack, S.: Composing PROPs. Theory and Application of Categories 13(9), 147–163 (2004)
46.
Zurück zum Zitat Laplaza, M.L.: Coherence for distributivity. In: Kelly, G.M., Laplaza, M., Lewis, G., Mac Lane, S. (eds.) Coherence in Categories. pp. 29–65. Lecture Notes in Mathematics, Springer, Berlin, Heidelberg (1972). https://doi.org/10.1007/BFb0059555 Laplaza, M.L.: Coherence for distributivity. In: Kelly, G.M., Laplaza, M., Lewis, G., Mac Lane, S. (eds.) Coherence in Categories. pp. 29–65. Lecture Notes in Mathematics, Springer, Berlin, Heidelberg (1972). https://​doi.​org/​10.​1007/​BFb0059555
47.
Zurück zum Zitat Lawvere, F.W.: Functorial Semantics of Algebraic Theories. Ph.D. thesis, Columbia University, New York, NY, USA (1963) Lawvere, F.W.: Functorial Semantics of Algebraic Theories. Ph.D. thesis, Columbia University, New York, NY, USA (1963)
48.
Zurück zum Zitat Mac Lane, S.: Categories for the Working Mathematician, Graduate Texts in Mathematics, vol. 5. Springer-Verlag, New York, second edn. (1978) Mac Lane, S.: Categories for the Working Mathematician, Graduate Texts in Mathematics, vol. 5. Springer-Verlag, New York, second edn. (1978)
49.
Zurück zum Zitat Martin, U., Mathiesen, E.A., Oliva, P.: Hoare logic in the abstract. In: International Workshop on Computer Science Logic. pp. 501–515. Springer (2006) Martin, U., Mathiesen, E.A., Oliva, P.: Hoare logic in the abstract. In: International Workshop on Computer Science Logic. pp. 501–515. Springer (2006)
50.
Zurück zum Zitat O’Hearn, P.W.: Incorrectness logic. Proceedings of the ACM on Programming Languages 4(POPL), 1–32 (2019) O’Hearn, P.W.: Incorrectness logic. Proceedings of the ACM on Programming Languages 4(POPL), 1–32 (2019)
52.
Zurück zum Zitat Pous, D.: On the positive calculus of relations with transitive closure. In: Niedermeier, R., Vallée, B. (eds.) 35th Symposium on Theoretical Aspects of Computer Science, STACS 2018, February 28 to March 3, 2018, Caen, France. LIPIcs, vol. 96, pp. 3:1–3:16. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2018). https://doi.org/10.4230/LIPIcs.STACS.2018.3 Pous, D.: On the positive calculus of relations with transitive closure. In: Niedermeier, R., Vallée, B. (eds.) 35th Symposium on Theoretical Aspects of Computer Science, STACS 2018, February 28 to March 3, 2018, Caen, France. LIPIcs, vol. 96, pp. 3:1–3:16. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2018). https://​doi.​org/​10.​4230/​LIPIcs.​STACS.​2018.​3
53.
Zurück zum Zitat Pratt, V.R.: Semantical considerations on floyd-hoare logic. In: 17th Annual Symposium on Foundations of Computer Science (sfcs 1976). pp. 109–121. IEEE (1976) Pratt, V.R.: Semantical considerations on floyd-hoare logic. In: 17th Annual Symposium on Foundations of Computer Science (sfcs 1976). pp. 109–121. IEEE (1976)
54.
Zurück zum Zitat Selinger, P.: A note on Bainbridge’s power set construction. Ann Arbor 1001, 48109–1109 (1998) Selinger, P.: A note on Bainbridge’s power set construction. Ann Arbor 1001, 48109–1109 (1998)
55.
Zurück zum Zitat Selinger, P.: A survey of graphical languages for monoidal categories. In: New structures for physics, pp. 289–355. Springer (2010) Selinger, P.: A survey of graphical languages for monoidal categories. In: New structures for physics, pp. 289–355. Springer (2010)
56.
Zurück zum Zitat Stein, D., Staton, S.: Probabilistic programming with exact conditions. Journal of the ACM (2023) Stein, D., Staton, S.: Probabilistic programming with exact conditions. Journal of the ACM (2023)
57.
Zurück zum Zitat Winskel, G.: The formal semantics of programming languages: an introduction. MIT press (1993) Winskel, G.: The formal semantics of programming languages: an introduction. MIT press (1993)
Metadaten
Titel
A Diagrammatic Algebra for Program Logics
verfasst von
Filippo Bonchi
Alessandro Di Giorgio
Elena Di Lavore
Copyright-Jahr
2025
DOI
https://doi.org/10.1007/978-3-031-90897-2_15