Log In Sign Up

Functorial Semantics for Relational Theories

by   Filippo Bonchi, et al.

We introduce the concept of Frobenius theory as a generalisation of Lawvere's functorial semantics approach to categorical universal algebra. Whereas the universe for models of Lawvere theories is the category of sets and functions, or more generally cartesian categories, Frobenius theories take their models in the category of sets and relations, or more generally in cartesian bicategories.


page 1

page 2

page 3

page 4


A Variety Theorem for Relational Universal Algebra

We develop an analogue of universal algebra in which generating symbols ...

Enriched Lawvere Theories for Operational Semantics

Enriched Lawvere theories are a generalization of Lawvere theories that ...

Knowledge Representation in Bicategories of Relations

We introduce the relational ontology log, or relational olog, a knowledg...

Follow the Flow: sets, relations, and categories as special cases of functions with no domain

We introduce, develop, and apply a new approach for dealing with the int...

Relational Theories with Null Values and Non-Herbrand Stable Models

Generalized relational theories with null values in the sense of Reiter ...

Cartesian bicategories with choice

Relational structures are emerging as ubiquitous mathematical machinery ...

Theory Presentation Combinators

To build a scalable library of mathematics, we need a method which takes...

1 Introduction and roadmap

There has been a recent explosion of interest in algebraic structures borne by objects of symmetric monoidal categories, with applications in quantum foundations, concurrency theory, control theory, linguistics and database theory, amongst others. In several cases these “resource-sensitive” algebraic theories are presented using generators and equations. Moreover, many contain Frobenius algebra as a sub-theory, which yields a self-dual compact closed structure and gives the theories a relational flavour (e.g. a dagger operation, which one can often think semantically as giving the opposite relation). In this paper we propose a categorical universal algebra for such monoidal theories, generalising functorial semantics, the classical approach due to Lawvere. A canonical notion of model clarifies the conceptual landscape, and is a useful tool for the study of the algebraic theories themselves. For example: how can one show that a particular equation does not hold in a theory? One way is to find a model where the equation does not hold.

1.1 Functorial semantics

Lawvere categories (a.k.a. finite product theories) are a standard setting for classical universal algebra. Syntactically speaking, terms are trees where some leaves are labelled with variables, and these can be copied and discarded arbitrarily. Categorically, this means a finite product structure, and (classical) models are product preserving functors. In particular, the classical notion of model as a set, together with appropriate -ary functions, satisfying the requisite equations, is captured by a product preserving functor from the corresponding Lawvere category to the category of sets and functions . This methodology is well-known as functorial semantics.

Specification algebraic theory
Syntax trees
Category Lawvere category (finite product category)
Models product preserving functors
Homomorphisms natural transformations

Thus commutative monoids are exactly the product preserving functors from the Lawvere category of commutative monoids, abelian groups the product preserving functors from the Lawvere category of abelian groups, etc. Moreover, the usual notion of homomorphism between models is given by natural transformations between models-as-functors.

In applications, classical algebraic theories are often not the right fit. Sometimes this is because an underlying data type is not classical, e.g. qubits, that cannot be copied. Other times it’s because one needs to be explicit about the actual copying and discarding being carried out

as (co)algebraic operations, instead of relying on an implicit cartesian structure. That is, we require a resource sensitive syntax. In practice, this means replacing algebraic theories with symmetric monoidal theories (SMTs), trees with string diagrams, cartesian product with symmetric monoidal product (Lawvere categories with props), and product preserving functors with monoidal functors. This suggests an updated table:

Specification symmetric monoidal theory (SMT)
Syntax string diagrams
Category prop
Models symmetric monoidal functors
Homomorphisms monoidal natural transformations

Props are symmetric strict monoidal categories with objects the natural numbers, such that . Of course, any Lawvere category is an example of a prop, since the cartesian structure induces a canonical symmetry. Arrows of (freely generated) props seem, therefore, to offer an attractive solution to the quest for resource sensitive syntax. Given that the underlying monoidal product is not assumed to be cartesian, props give the possibility of considering bona fide operations with co-arities other than one, e.g. the structure (comultiplication and counit) of a comonoid. In fact, comonoids are the bridge between the classical and the resource-sensitive.

Indeed, given an algebraic theory, we can consider it as a symmetric monoidal theory by encoding the cartesian structure. This amounts to introducing a commutative comonoid (copying) and equations making all other operations comonoid homomorphisms.


This means that, as props, the following are actually isomorphic:

Lawvere category of commutative monoids

prop of (co/commutative) bialgebras

Lawvere category of abelian groups

prop of (co/commutative) Hopf algebras

Thus, in effect, bialgebras are what one gets if by considering classical commutative monoids and taking resource sensitivity seriously. Similarly, Hopf algebras can be seen as abelian groups in a “resource sensitive” universe.

The structure of props suggests that, for models, we ought to look at symmetric monoidal functors. Indeed, considering the category of sets and functions with cartesian product as monoidal product as codomain, the symmetric monoidal functors from the prop SMT of commutative monoids are in bijective correspondence with ordinary commutative monoids. Here it is the cartesianity of that means that, although the theory is non-cartesian, the models are classic. Similarly, commutative monoids are captured by symmetric monoidal functors – it is not difficult to show that the only comonoid action on a set is given by the diagonal, so the “copying” comonoid structure is uniquely determined in any -model of .

1.2 Relations as a universe for models

Our goal is to study algebras of relations (e.g. relational algebra, allegories, Kleene algebra, automata, labelled transition systems, …), important in computer science. Thus, we are interested in developing a theory of functorial semantics that takes its classical models in (object = sets, arrows = relations, and the subscript indicates that we take cartesian product as monoidal product).

Here mere SMTs and monoidal functors are not enough to characterise commutative monoids. Considering the SMT of commutative monoids, monoidal functors to are not guaranteed to give a functional monoid action: e.g., one could map the monoid action to the opposite of the diagonal relation. Considering the SMT of bialgebras fails also: there is no guarantee that the comultiplication maps to the diagonal. For a concrete example, consider


here the structure of addition (i.e. the fact that is a rig–a ring without negatives) on ensures that the bialgebra equations are satisfied, in particular, if then .

We could require – for props that have a commutative comonoid structure that defines a product, that the product structure ought to be preserved, so that is mapped to the diagonal. Unfortunately, this would preclude considering as a universe of models, since the monoidal product in is not a cartesian product (recall that actually has as biproduct). Indeed, when interpreted in , the general form of equations (1)

tells us, respectively, that is single-valued and total, which is true only of those relations that are (the graphs of total) functions.

A crucial observation to make at this point is that products play two different roles in functorial semantics à la Lawvere. The first is resource insensitivity—i.e. an assumption about the classical nature of the underlying data— which we would like to discard. The second is preservation of arities – the idea that one should be able to specify algebraic operations and have that structure borne by a set (or more generally, an object in some category). We would like to keep this second role, and here we take advantage of the the notion of lax product, which Carboni and Walters [Carboni1987] identified as important for the algebra of categories of relations. Indeed, the monoidal product of satisfies a lax universal property. In practice this turns out to be, bureaucratically speaking, quite a tame notion of laxness: the 2-dimensional structure of is posetal (set inclusion), and indeed we will concentrate on the poset-enriched case. At specification level, this means that it’s natural to introduce inequations between terms.

In fact, the most we can say about relations , in general, is that they are lax comonoid homomorphisms:


If all arrows are lax homomorphisms in this sense then the monoidal product is a lax product. Crucially, (3) holds in , where -comultiplication is the diagonal relation , that is, the graph of the diagonal function. Notice that, in , the inequations (3) are strict exactly when, respectively, is not single valued and not total.

1.3 Lax product theories

By a lax product theory we mean a generalisation of SMT that replaces equations with inequations, and includes a chosen commutative comonoid structure. Moreover, we require inequations (3) that say that all other data is a lax comonoid homomorphism. We call the comonoid structure together with the aforementioned inequations a lax product structure. Every lax product theory leads to a free ordered prop (a prop enriched in the category or posets and monotone maps), where (3) ensure that the monoidal product is a lax product, in the bicategorical sense.

Specification lax product theory
Syntax string diagrams
Category lax product 2-prop
Models lax product structure preserving functors
Homomorphisms monoidal lax natural transformations

Note that both the SMT of bialgebras and Hopf algebras are lax product theories (each equation is replaced by two inequations). And we now obtain a satisfactory “resource sensitive” generalisation of Lawvere’s functorial semantics to -models. For example, the models of the SMT of bialgebras, given by lax product structure preserving functors to , are exactly commutative monoids. This may appear surprising, since we are mapping to , one could expect that may map to an arbitrary relation. Instead, the fact that we need to preserve lax products means, since is functional in the specification, it maps to a function in the model. Moreover, the categories of models (where morphisms between models are given by monoidal natural transformations) coincide: both are the category of commutative monoids and homomorphisms. Thus the mismatch of (2) is avoided.

Yet lax product theories are not quite expressive enough for our purposes. We have seen that, using the lax product structure, we can express equationally when a relation is a function. But we cannot, for instance, say when a relation is a “co-function”, that is, the opposite relation of a function. This capability is very useful in examples, for example for the calculus of fractions in the SMT of Interacting Hopf Algebras [interactinghopf].

1.4 Frobenius theories

A Frobenius theory—a concept introduced in this paper—is a lax product theory that includes additionally a “black” commutative monoid right adjoint to the comonoid.

Moreover, the monoid-comonoid pair satisfies the Frobenius equations and the special law – i.e. an additional inequation relating the multiplication and comultiplication.

Notice that the presence of the Frobenius equations induces a self-dual compact closed structure. Together, the Frobenius equations and the special law give us the spider theorem, which implies that the mirror images of (3) hold, i.e.

The resulting free ordered prop is what we refer to as a Frobenius prop (frop) or a Carboni-Walters category, after A Carboni and RFC Walters. Indeed, it is an example of Carboni and Walters’ bicategory of relations [Carboni1987, Sec. 2]: a cartesian bicategory where the “black” structure satisfies the Frobenius equations. Moreover, discarding the 2-structure, one obtains a hypergraph category (a.k.a. well-supported compact closed category).

Specification Frobenius theory
Syntax string diagrams
Category Carboni-Walters category
Models lax product preserving functors
Homomorphisms monoidal lax natural transformations

The frop of commutative monoids can be thought of as the prop of bialgebras, together with an additional commutative “black” monoid. Again, as in the case of lax product theories, the models in are ordinary commutative monoids, and the model transformations are monoid homomorphisms. The example of commutative monoids generalises to arbitrary algebraic theories: there is a procedure, analogous to that of producing an SMT from a classical algebraic theory, that results in a Frobenius theory, so that the models of the relevant Lawvere category in are in bijective correspondence with the models of the Frobenius theory in . More than that, the categories of models are equivalent.

But Frobenius theories give us much more that a way of doing “resource-honest” algebraic theories in : they are much more expressive and allow us to bring many new examples into the fold. This report introduces the basic theory together with a wide range of examples.

Structure of the paper.

We recall the concepts of symmetric monoidal theory and props in Section 2 and explain how classical algebraic theories can be considered as symmetric monoidal theories, and the corresponding Lawvere theories as certain props. In Section 3 we extend the picture to inequational theories, resulting in poset-enriched props. We also identify the crucial concept of lax product structure, which allows us to keep the “arity-preservation” property of classical models. In Section LABEL:sec:frobenius we introduce the central concept of Frobenius theory, describe models and focus on some general properties. In Section LABEL:sec:ex, we highlight interesting examples of Frobenius theories, showcasing the expressivity of the framework. In Section LABEL:sec:frobcartesian we explain how cartesian theories can be considered as Frobenius theories, without altering the category of models. In the last three sections are an in-depth look at three ubiquitous mathematical theories, considered as Frobenius theories: commutative monoids (Section LABEL:sec:monoid), abelian groups (Section LABEL:sec:ag) and modules (Section LABEL:sec:modules).

2 Symmetric Monoidal Theories and Props

Our exposition is founded on symmetric monoidal theories: presentations of algebraic structures borne by objects in a symmetric monoidal category.

Definition 2.1.

A (presentation of a) symmetric monoidal theory (SMT) is a pair consisting of a signature and a set of equations . The signature is a set of generators with arity and coarity . The set of -terms is obtained by composing generators in , the unit and the symmetry with and . This is a purely formal process: given -terms , , , one constructs new -terms and . The set of equations contains pairs of -terms with the same arity and coarity.

The categorical concept associated with symmetric monoidal theories is the notion of prop (product and permutation category [MacLane1965]).

Definition 2.2.

A prop is a symmetric strict monoidal category with objects the natural numbers, where on objects is addition. The prop freely generated by a theory , denoted by , has as its set of arrows the set of -terms taken modulo the laws of symmetric strict monoidal categories — Fig. 1 — and the smallest congruence (with respect to and ) containing equations for any .

Figure 1: Axioms of symmetric strict monoidal categories for a prop .

There is a natural graphical representation for arrows of a prop as string diagrams, which we now sketch, referring to [Selinger2009] for the details. A -term is pictured as a box with ports on the left and ports on the right. Composition via and are rendered graphically by horizontal and vertical juxtaposition of boxes, respectively.


In any SMT there are specific -terms generating the underlying symmetric monoidal structure: these are , represented as , the symmetry , represented as , and the unit object for , that is, , whose representation is an empty diagram. Graphical representation for arbitrary identities and symmetries are generated according to the pasting rules in (4).

Example 2.3.
  1. We write for the SMT of commutative monoids. The signature contains a multiplication and a unit . Equations assert associativity (5), commutativity (6) and unitality (7).

  2. Next, the SMT of commutative comonoids. The signature consists of a comultiplication and a counit . consists of the following equations.

  3. Monoids and comonoids can be combined into a theory that plays an important role in our exposition: the theory of special Frobenius algebras [Carboni1987]. This is given by , where is the following set of equations.

  4. Another fundamental way to combine monoids and comonoids is the theory of (commutative/cocommutative) bialgebras , where is the following set of equations.


    One can read (13)-(16) as stating that the monoid structure (multiplication,unit) is a comonoid homomorphism, and vice versa, the comonoid structure is a monoid homomorphism.

    Bialgebras and special Frobenius algebras play an important role in recent research threads in quantum [CoeckeDuncanZX2011, BialgAreFrob14], concurrency [Bruni2006, Sobocinski2013a] and control theory [Bonchi2014b, BaezErbele-CategoriesInControl, Bonchi2015].

  5. Another theory that play a crucial role in the aforementioned works is the theory of Hopf algebras. This is obtained from the theory of bialgebra by extending the , with the antipode and the set of equations with the following three.


The assertion that is the SMT of commutative monoids—and similarly for other SMTs in our exposition—can be made precise through the notion of model of an SMT.

Definition 2.4.

Given a symmetric monoidal category , a model of an SMT in is a symmetric monoidal functor . Then is the category of models of in and monoidal natural transformations between them.

Turning to commutative monoids, there is a category whose objects are the commutative monoids in , i.e., objects equipped with arrows and , satisfying the usual equations. Given any model , it follows that is a commutative monoid in : this yields a functor . Saying that is the SMT of commutative monoids means that this functor is an equivalence natural in .

We can recover classical models by considering symmetric monoidal functors to , the symmetric monoidal category of sets, where the monoidal product is the cartesian product . Indeed, the functor is determined, up-to natural isomorphism, by where it sends . Concretely, we can consider the image of a symmetric monoidal functor of this type to consist of the sets of -tuples . Then is equivalent to the category of ordinary commutative monoids and monoid homomorphisms.

2.1 Cartesian theories and Lawvere Categories

A cartesian category (or finite product category) is a symmetric monoidal category where the monoidal product satisfies the universal property of the categorical product; a cartesian functor is a product preserving functor. It is well-known that a symmetric monoidal category is cartesian iff for every object in , there are arrows and forming a cocommutative comonoid, graphically denoted by and , and every arrow in is a comonoid homomorphism.


A Lawvere category [LawvereOriginalPaper, hyland2007category] is then a symmetric monoidal category that is both cartesian and a prop.

Example 2.5.
  1. Recall the theory of commutative comonoids from Example 2.3(b). The resulting prop is the initial Lawvere category, the free category with products on one object. The comultiplication and the counit are the comonoid on . For , and are defined recursively: and , and .

  2. The prop of bialgebras (Example 2.3(c)) is also a Lawvere category. For every natural number, the comonoid structure is defined as above. Moreover all arrows in are comonoid homomorphisms, since (13), (14), (15), (16) say exactly that and are comonoid homomorphisms.

  3. Amongst the other SMTs in Example 2.3, only freely generates a Lawvere category: indeed equations (17) and (18) state that the antipode is a comonoid homomorphism.

Definition 2.6.

A (presentation of a) cartesian theory is a pair consisting of a signature and equations . is a set of generators with arity and coarity . The set of equations contains pairs of Cartesian -terms, namely arrows of the prop freely generated by the SMT where contains equations


for each generator of the signature .

The Lawvere category freely generated by a cartesian theory , denoted by , is the prop freely generated by the SMT . The latter will be often referred to as the SMT corresponding to the cartesian theory .

Cartesian terms can be thought as the familiar notion of standard syntactic term: trees with leaves labeled by variables. The ability to copy and discard variables is given by and , respectively. Since these structures are implicit in any cartesian theory, one can therefore think of cartesian terms as resource-insensitive syntax. On the other hand, the string diagrams of SMTs provide a resource-aware syntax since the ability to add and copy variables, if available, is made explicit.

Example 2.7.
  1. In -terms of the SMT of commutative monoids (Example 2.3(a)), variables cannot be copied or discarded. The cartesian theory of commutative monoids has the same signature and equations, but terms have the implicit capability of being copied and discharged. Indeed, the Lawvere category is isomorphic to the prop generated by the SMT of bialgebras (Example 2.3(d)).

  2. By adding to the antipode and equation (19), one obtains the cartesian theory of Abelian groups. The corresponding SMT is the theory of Hopf algebras (Example 2.3(e)): i.e. .

As for SMTs, the assertion that is the cartesian theory of commutative monoids can be made precise using the notion of model of an cartesian theory.

Definition 2.8.

Given a cartesian category , a model of a cartesian theory in is a cartesian functor . Then is the category of models of in and monoidal natural transformations between them.

For an example take the cartesian category . Every model maps to some set and thus every natural number to . Requiring to be cartesian forces the counit to be mapped into the unique morphism from to the final object and the comultiplication to the diagonal . So, a model is uniquely determined by the set and the functions for each generator of the signature. In a nutshell, the notion of Cartesian model for coincides with the standard notion of algebra. By spelling out the definition of natural transformation, one can readily check that morphism of models are homomorphisms.

3 Lax product theories

A first step toward Frobenius theories and their models consists in relaxing products into lax products. In this section, we introduce the categorical machinery to deals with theories of inequations and lax products theories.

Suppose that is a set of generators and is a set of inequations: similarly to an equation, the underlying data of an inequation is simply a pair of equal-typed -terms. Unlike equations, however, we will understand this data as being directed:

We call the pair a (presentation of a) symmetric monoidal inequation theory (SMIT).

Throughout the paper we use ordered as a synonym for “enriched in ” - the category of posets and monotonic functions. Indeed, just as SMTs lead to props, SMITs lead to ordered props, as defined below.

Definition 3.1 (Ordered prop).

An ordered prop is a prop enriched over the category of posets: that is, it is a strict symmetric 2-category with objects the natural numbers, monoidal product on objects defined as , where each set of arrows is a poset, with composition and monoidal product monotonic. Similarly, a pre-ordered prop is a prop enriched over the category of pre-orders.

Analogously to how one—given and SMT —constructs a free prop, we can use a SMIT to generate a free ordered prop. First, we constructs the free pre-ordered prop: arrows are -terms. The homset orders are determined by whiskering and closing it under , then applying reflexive and transitive closure: this is the smallest preorder containing that makes into a pre-ordered prop (i.e. composition is monotonic and is a 2-functor). Then, we obtain the free ordered prop by quotienting the free pre-ordered prop by the equivalence induced by the pre-order.

Any SMT gives rise to a canonical SMIT where each equation is replaced with two inequalities , in the obvious way. The free prop for can then be obtained from the free ordered prop for by forgetting the underlying 2-structure. For this reason, we can safely abuse the notation to denote the ordered prop freely generated by an SMIT .

Example 3.2.
  1. The SMT of commutative monoids (Example 2.3 (a)) can be regarded as the SMIT .

  2. The SMT of cocommutative comonoids (Example 2.3 (b)) can be regarded as the SMIT .

  3. The SMT of bialgebra (Example 2.3 (d)) can be regarded as the SMIT .

  4. From the SMIT of bialgebra, one can drop the inequations and obtain the SMIT of lax bialgebras . In this theory we have a monoid, a comonoid and the inequations of – that we depict below for the convenience of the reader – force the monoid to be a lax comonoid homomorphism.

  5. Otherwise one can drop the inequations in and obtains the SMIT of oplax bialgebras . The inequations of are depicted below.


Particularly relevant for our exposition is the SMIT of commutative comonoids: cartesian theories include an implicit comonoid structure and force the generators in the signature to be comonoid homomorphisms. The theories that we are going to introduce next – lax product theories – are analogous, but they require the generators to be lax comonoid homomorphisms.

Definition 3.3 (Lax Product Theory).

A (presentation of a) lax product theory (LPT) is a pair consisting of a signature and a set of inequations . The signature is a set of generators with arity and coarity . The set of inequations contains pairs of L--terms, namely arrows of the ordered prop freely generated by the SMIT where is the set containing


for each generator in .

We refer to as the SMIT corresponding to a LPT . The ordered prop freely generated by the SMIT corresponding to is called the lax product prop freely generated by and denoted by .

The mismatch between and SMITs and LPTs is analogous to the one of SMTs and cartesian theories: the theory of comonoids (Example 3.2 (b)) is the SMIT corresponding to the empty LPT ; the theory of lax bialgebra (Example 3.2 (d)) is the SMIT corresponding to the LPT of commutative monoids (Example 3.2 (a)).

An important difference between lax product theories and cartesian theories is that generators in can have arbitrary coarity, not necessarily as is the case in any cartesian theory. Indeed, the presence of finite products eliminates the need for coarities other than 1, since to give an arrow , in a cartesian category is to give an -tuple of arrows , obtained by composing with the projections. In a lax product theory, instead, this is not the case. As we shall see below, the category of relations can be considered as a source of models for a lax product theory and it is clearly not true, in general, that relations are determined by their projections.

The notion of lax product prop will be formalised in the next subsection. For the moment, the reader can think of these structures as ordered props where objects are equipped with a comonoid structure and arrows are lax comonoid homomorphism. This is the case in

as shown below.

Theorem 3.4.

Let be an LPT and be lax product prop freely generated by it. Then every in is a lax comonoid homomorphism.


By inequations (32) and (33), every generator in is a lax comonoid homomorphism. A simple structural induction confirms it for compound terms.

3.1 Lax product structures and lax products

In Section 2.1 we recalled that the monoidal product is a categorical product precisely when all arrows are comonoid homomorphisms. Here we show that the property of arrows being lax-comonoid homomorphisms force the monoidal product to be a lax product, a bicategorical limit. We begin by noting that the commutative comonoid structure in any lax product theory is an instance of something we call a lax product structure.

Definition 3.5 (Lax product structure).

Given an ordered monoidal category , a lax product structure is a choice, for each object , of commutative comonoid , compatible with the monoidal product in the obvious way, i.e.:

such that for every arrow we have

Lemma 3.1.

In an ordered monoidal category , a lax product structure, if it exists, is unique.


Suppose that for some we have lax product structures and which we shall draw and , respectively. It follows that, for all , since :

and, using a symmetric argument, . Using the fact that the lax product structure is, by definition, assumed to be compatible with monoidal product and the fact that it follows that :

and, again by a symmetric argument, that . ∎

We will now show that, if an ordered monoidal category has a lax product structure then the monoidal product is a lax product, by which we mean the following bicategorical limit. Given objects and , a lax product is an object with projections, that is arrows , s. t. for any , there exists and 2-cells , as illustrated below: