Scholarly article on topic 'Two Cotensors in One: Presentations of Algebraic Theories for Local State and Fresh Names'

Two Cotensors in One: Presentations of Algebraic Theories for Local State and Fresh Names Academic research paper on "Computer and information sciences"

Share paper
{"cartesian closed category" / "monoidal closed category" / "enriched algebraic theories"}

Abstract of research paper on Computer and information sciences, author of scientific article — Sam Staton

Abstract Various situations in computer science call for categories that support both cartesian closed and monoidal closed structure. Such situations include (i) models of local state, where the monoidal product describes disjointness of memory, and (ii) treatment of fresh names, as required in models of the π-calculus. I propose a technique to embed the two closed structures into one single structure. To demonstrate the technique, I show how previously studied theories of local state and fresh names can be understood formally as presentations of (enriched) algebraic theories.

Academic research paper on topic "Two Cotensors in One: Presentations of Algebraic Theories for Local State and Fresh Names"

Available online at

W ScienceDirect

ELSEVIER Electronic Notes in Theoretical Computer Science 249 (2009) 471-490

Two Cotensors in One: Presentations of Algebraic Theories for Local State and Fresh Names

Sam Staton

Computer Laboratory University of Cambridge


Various situations in computer science call for categories that support both cartesian closed and monoidal closed structure. Such situations include (i) models of local state, where the monoidal product describes disjointness of memory, and (ii) treatment of fresh names, as required in models of the ^-calculus.

I propose a technique to embed the two closed structures into one single structure. To demonstrate the technique, I show how previously studied theories of local state and fresh names can be understood formally as presentations of (enriched) algebraic theories.

Keywords: cartesian closed category, monoidal closed category, enriched algebraic theories

1 Introduction

When giving a semantics for a language with local state, or for the n-calculus, it is appropriate to work in a category that supports two kinds of function space:

[A ^ X] given a location/channel, return an element of X

[A ^ X] given a new location/channel, return an element of X

(Here A is a distinguished object of locations/channels.) Just as the function space [A ^ X] is right adjoint to the cartesian product, the restricted function space [A ^ X] is right adjoint to a monoidal product (—) ® A.

This use of two closed structures is a nuisance when it comes to using general techniques from category theory, which typically consider only a single closed structure. In this paper, we take our illustrations from algebraic theories for local state and the n-calculus; there is a rich body of work on algebraic theories for monoidal closed categories (e.g. [14,22,26]).

1571-0661/$ - see front matter © 2009 Elsevier B.V. All rights reserved. doi:10.1016/j.entcs.2009.07.103

A crucial contribution of this paper is the observation that both kinds of function space can be described by a single 'cotensor' structure, —•:

[A ^ X] = [¿(A) —• X] [A ^ X] = [is(A) —• X] as will be explained.

1.1 Cartesian and monoidal structures in models of the n-calculus and local state

Recall that the n-calculus [16] is a language that allows communication of channel names along the channels themselves. In the semantics of the n-calculus (e.g. [7,28]) the two closed structures both play crucial roles. The cartesian structure is used for an operator input: A x [A ^ X] ^ X, giving semantics to the input behaviour of the n-calculus; informally, input creates a semantic representation out of a pair (a, f) where a is the name of the channel to input from, and f: A ^ X is thought of as a function specifying how to resume when a channel name is received. The n-calculus also has a restriction operator, the semantics of which is determined by a morphism new: [A ^ X] ^ X making a denotation out of an element requiring a fresh name.

In giving the semantics of a programming language with local state (e.g. [18]), both closed structures are used again. The cartesian closed structure is used for an operator lookup: A x [V ^ X] ^ X, giving semantics to commands such as let v := !a in M. The monoidal closed structure is used for an operator block: V x [A ^ X] ^ X, giving semantics to commands such as block a := v in M, that introduce local state. (Here V is a set of values.)

1.2 Algebraic operations and generic effects

In a sequence of papers (e.g. [20]), Plotkin, Power and collaborators have outlined a program to understand Moggi's monadic semantics from a more axiomatic perspective: the monads can be presented in terms of operators and equations. A simple example is the algebraic theory of semilattices, which gives rise to the finite powerset monad Pf, a simple monad for non-determinism. The operators of the theory give 'effects', 1 —————^ Pf(0) and 1 —--—U Pf(2).

In the literature, strong monads arise on a presheaf category I, for modelling local state and the n-calculus. As Plotkin and Power [21] and Stark [29] have observed, the algebras for these monads can be described in terms of operators — such as new and lookup above — subject to equations expressed as commuting diagrams. For instance, an algebra for the n-calculus must satisfy the following axiom:

which corresponds to the axiom

va.P = P if a £ fv(P) (from [16]).

A problem with these developments is that, although the theories appear informally as a presentation by operators and equations, they are not presentations in the formal sense proposed by Kelly and Power [14], because the two closed structures are used. Thus, the general results do not apply; for instance, the monadicity results are proved by hand.

A contribution of this paper is a demonstration of how the theories of local state and the n-calculus from [21,29] can be understood as presentations of enriched algebraic theories, in the sense of [14]. We also investigate how a theory for open bisimulation [27] can be understood in this way.

1.3 Two cotensors in one

To begin to understand the title of this paper, recall that, just as a monoidal closed category (C, involves a functor Cop xC ^ C, a cotensor of a category C

enriched in V gives rise to a functor —•: Vop xC ^ C.

(For a simple example, note that the category of monoids, Mon, has coten-sors —•: Setop x Mon ^ Mon, with [S —• M] the S-fold product of a monoid M.)

The essence of my construction involves a category A, in which the presheaf category I embeds in two different ways, is,i: I ^ A. The category I can be enriched over A, and it has cotensors —•: Aop xI ^ I. The two original closed structures on I can be understood in terms of one cotensor wrt A, in the

sense that

[X ^ Y] = [¿(X) —• Y] and [X ^ Y] = [¿s(X) —• Y] .

The 'two cotensors in one' construction can be understood in some generality, which I axiomatize in terms of 'compatibility structures'.

1.4 Synopsis

The paper is structured as follows. The construction surveyed in Section 1.3 above is introduced in Section 2. Some rudiments of enriched algebraic theories are recalled in Section 3, and illustrated in Section 4 with theories of the n-calculus and of local state. In Section 5, we consider 'two cotensors in one' in a more general setting, and as an example, we investigate the theory of open bisimilarity in the n-calculus.

1.5 Relevance and related work

In this paper, we show that informal, ad-hoc presentations of theories of local state [21] and the n-calculus [29] can be considered as presentations of enriched algebraic theories, in the sense of [14]. In the process, we introduce a new way of understanding the two closed structures of I. This complements the well-established techniques of bunched implications [18,25] and nominal sets [9].

A next step is to better understand the kinds of reasoning permitted in models of Lawvere A-theories. As a first step, Power [24,23] provides an analysis of algebraic theories with a block operator — a generalization of the theory of local state in [21].

Fiore and Hur [6] propose a technique for synthesizing an equational logic from an enriched Lawvere theory. It will be interesting to evaluate this technique for the theories in Section 4.

Nominal equational logic (NEL) [2] and nominal algebra [8] are reasoning systems for theories involving freshness and binding. Unfortunately the theories considered here, for the n-calculus and local state, do not seem to be 'nominal theories', although, conversely, it seems that every NEL theory can be understood as an Law-vere A-theory (in the sense of Sec. 3.4). (Clouston [1] recently introduced a bespoke notion of 'nominal Lawvere theory' for NEL.)

The idea of having two types of atoms to encode two function spaces seems to be implicit in the proof theoretic work of Ziegler, Miller and Palamidessi [32]. I hope that the constructions in this paper will help to explain that work from a more model theoretic perspective.

2 Two cotensors, in one

In this section we consider monoidal closed structures on two presheaf categories: I (in Sec. 2.2) and A (Sec. 2.3). There are two embeddings I ^ A (Sec. 2.4) and these relate the two closed structures of I with a single closed structure in A (in Secs. 2.4-2.6). There is a summary of notation in Section 2.7.

2.1 Preliminaries: promonoidal categories

To begin, recall the observation of Day [3,4], that monoidal biclosed structures on (covariant) presheaf categories (SetC) correspond to 'promonoidal structures' on small categories (C). (Day treats the general case of enriched functor categories, but we will not need that here.)

A promonoidal structure on a small category C is given by the following data:

• two functors, J: C ^ Set and P: Cop x Cop x C ^ Set;

• three natural isomorphisms (subject to coherence conditions):

• Identity: fX J(X) x P(X, A, B) ^ C(A, B) ^ fX J(X) x P(A,X,B);

• Associativity: fX P (A, B,X) x P (X,C,D) ^ fY P (B,C,Y) x P (A, Y, D).

A promonoidal structure on C induces the following monoidal biclosed structure on SetC (notation: SetC(F, [G,H]l) = SetC(F ® G, H) = SetC(G, [F, H]r)):

• The unit is J; for presheaves F and G in SetC,

(F ® G)(A) = fB,CF(B) x G(C) x P(B,C,A) ;

[F, G]l(A) = SetC(yC(A) ® F, G) [F, G]r(A) = SetC(F ® yc(A),G) writing yc(A) for the representable presheaf C(A, —): C ^ Set.

Example 2.1 Cartesian closed structure. For any small category C, the cartesian closed structure on SetC arises from the following promonoidal structure:

• for A in C, let J (A) = 1, the one-element set;

• for A,B,C in C, let P (A,B,C) = {(f,g) | f: A ^ C, g: B ^ C}.

For presheaves F and G in SetC, the cartesian closed structure can be understood as follows: (F x G)(A) = F(A) x G(A), and [F ^ G](A) = SetC(yc(A) x F, G).

2.2 A monoidal closed structure on presheaves over finite sets and injections

Throughout this paper we fix an infinite set of 'atoms'. Atoms can be thought of as locations in memory, or as names of communication channels in the n-calculus.

Let I be the category whose objects are finite sets of atoms, and whose morphisms are injections. In what follows, we write I for the category of presheaves Set1. Let A be the presheaf in I given by A(A) = A.

To get an intuition, following [21], consider a presheaf F in I where F(A) is a set of programs that only use the memory locations in A. For any injection, f : A ^ B, the action F(f) : F(A) ^ F(B) renames the memory locations that the programs use. Alternatively, following [29], consider the case where F(A) is a set of n-calculus processes that only use the channels in A.

As well as the cartesian structure of Example 2.1, we also have the following additional promonoidal structure on I.

• For A in I, let J (A) = 1, the one-element set; for A, B, C in I, let

P(A, B, C) = {(f, g) I f: A ~ C, g: B ~ C and im(f) n im(g) = 0} .

The identity and associativity isomorphisms are fairly straightforward (see Sec. 5.1). Let (<g), be the induced symmetric monoidal closed structure on I, and let (x, be the cartesian closed structure. To understand the monoidal product, notice that (F <g) A)(A) = {(x, a) | a £ A, x £ F(A \ {a})}. As for the closed structures, notice for any atom z £ A, we have two bijections (see e.g. [7,28]):

[A ^ F](A) = F(A U{z}) [A ^ F](A) = (F(A))a x F(A U{z}) . (1)

For instance, a model for local state includes a presheaf F in I and a map block: V x [A ^ F] ^ F (for some set V of values, regarded as a constant presheaf). This can be thought of as follows: for every finite. set A of locations, and every new location z £ A, there is a map block a : V x F (A U {z}) ^ F (A) taking a value and a program involving locations (A U {z}), and returning a program with locations A, i.e. with the location z made local.

For an illustration of the cartesian structure, a semantics for the n-calculus involves a presheaf F in I and a map inp: A x [A ^ F] ^ F. For every finite set A of channel names, and every new name z £ A, there is a function

inp: A x (F(A))a x F(A U {z}) ^ F(A)

which constructs an input behaviour from a tuple (a, (xb)beA,xX): the tuple (xb) is a description of what to do with known names (from A); and x describes what to do with the new name z.

2.3 One promonoidal structure for the arrow category

With the aim of understanding the two closed structures of I in one closed structure, we now consider the following category, I^: objects are pairs of finite sets of atoms, (A, Sa), with Sa Q A; a morphism (A, Sa) — (B, Sb) in I^ is an injection f: A ^ B for which f (Sa) Q Sb. In what follows, we write A for the presheaf category Set1 . A promonoidal structure for I^ is given as follows:

• for (A, Sa) in I^, let J (A, Sa) = 1; for (A, Sa), (B, Sb ), (C, Sc ) in I^, let P((A, Sa), (B, Sb), (C, Sc)) = {(f, g) | f: (A, Sa) - (C, Sc), g: (B, Sb) - (C, Sc) and f (A) n g(SB) = 0}.

The functorial action and identity and associativity isomorphisms are defined fairly straightforwardly.

We write (*, [—, =]l, [—, =]r) for the resulting monoidal biclosed structure on A. We investigate this structure in the remainder of this section. First, notice that the promonoidal structure is not symmetric. For instance, there is one element in the set P((1,1), (1,0), (1,1)) but the set P((1, 0), (1,1), (1,1)) is empty.

2.4 Embedding I in A

There are two embeddings i,is: I — A, given on objects by

(i(F ))(A, Sa) = F (A) (is(F ))(A, Sa) = F (Sa)

(for F in I). The functors i and iS are injective on objects and full and faithful. We also consider a projection functor 5: A — I given on objects by 5(X)(A) = X(A, A). It is a retraction of both iS and i, and indeed the three functors are adjoint:

••• H iS H 5 H i H ••• (One can understand these adjunctions as arising, as essential geometric morphisms, from adjunctions between I and I^ — as indicated, there are also further adjoints to the left and right.)

The embeddings i and iS preserve some of the structure of I:

Theorem 2.2 Let F, G be presheaves in I, and let X be a presheaf in A.

i(F x G) = i(F) ki(G) (3a) F ® G ^ 5(i(F) kis(G)) (3b)

The presheaf [X, i(F)]l is always in the image of i: I — A, and moreover the closed structures are connected as follows:

i[F — G] = [i(F),i(G)]l (3c) i[F ^ G] ^ [is(F),i(G)]l (3d)

Proof notes. Isomorphisms (3a) and (3b) are straightforward to calculate, as is 5(yi- (A, Sa) *X) = 5(i(yi(A)) -k X). The remaining facts, (3c) and (3d), follow from these isomorphisms. □

By way of illustration, notice that the monomorphism m : ¿s(A) ^ ¿(A) gives rise to the natural surjection [A ^ F] ^ [A ^ F] (c.f. (1)):

(3c) \mi(F )li (3d)

¿[A ^ F] = [i(A),i(F)]i ——F^ [¿s(A),i(F)]i = ¿[A ^ F] . (3)

2.5 Tensors and cotensors

In light of Theorem 2.2, we can develop new theories for local state and the ^-calculus, using only the monoidal closed structure of A. The carriers of the models will now be presheaves X in A, and we have structures such as block: [¿(A),X]i * ¿(V) ^ X or input: [¿(A),X]l * ¿(A) ^ X. It is unpleasant, however, to consider models with carriers in A rather than in I, as there is little computational motivation for the extra structure of A.

This quandary can be partly resolved as follows. Following Theorem 2.2, we consider the action of A on I as a functor —•: Aop xI ^ I given by [X —• F] = 5[X, ¿(F)]i; this turns out to be a cotensor (see Sec. 2.6). There is a related tensor structure, •: Ix A^I, given by F • X = ¿(¿(F) *X), and the two constructions are adjoint:

I(F • X,G) = I(F, [X —• G]) in Set, natural in F, G, X.

The properties of the tensor and cotensor are summarized in the following corollary of Theorem 2.2:

Corollary 2.3 Let F and G be presheaves in I. Then:

F • ¿(G) = F x G [¿(F) —• G] = [F ^ G]

F • ¿s(G) = F ® G [¿s(F) —• G] = [F ^ G]

For example, the block structure for local state can now be described as a mor-phism block: [¿s(A) —• F] • ¿(V) ^ F in I, while the input structure for the ^-calculus can be described as a morphism input: [¿(A) —• F] • ¿(A) ^ F in I.

The morphism in (3) can be understood from this perspective: m: ¿s(A) ^ ¿(A) gives rise to [¿(A) —• F] ^ [¿s(A) —• F]. Moreover, thinking about tensors, m gives rise to an natural injection A ® A ^ A x A.

2.6 Universal properties of tensors and cotensors

The constructions introduced in the previous subsection (•, —•) can be understood from a universal perspective, through enriched category theory. The categories A and I can both be considered as categories enriched in A (i.e., where the hom-sets are actually objects of A). We write A and I for the corresponding A-enriched categories; the enrichments are given by

A(X, Y) = [X, Y]r I(F, G) = [¿(F),«(G)]r

The universal properties of the tensor • and cotensor —• can be stated as the following natural isomorphisms, natural in G and F respectively:

I(F • X, G) = [X, !(F, G)]r I(F, [X —• G]) = [X, I(F,G)]l (in A).

The category A also has cotensors, given by the left closed structure, and indeed the embedding i : ! ^ A extends to a cotensor-preserving A-functor, I^A.

(The only justification we have for enriching I in A is that it gives the desired tensor/cotensor structure.)

2.7 Summary of notation

Cartesian closed structure of I = Set1: (1, x, Monoidal closed structure of I : (1,

Monoidal biclosed structure of A = Set1 : (1,*, [—, =]l, [—, =]r) Tensor/cotensor of I (enriched in A): (•, —• ) (Notice that all the monoidal structures have terminal units.)

3 Enriched algebraic theories and their presentations

We survey some rudiments of algebraic theories and Lawvere theories in the enriched setting. The reader will find more detail and discussion, and more generality, in [14,22,26]; a reference for enriched categories is [12]. In Section 3.4, we consider the relevance of the theory to the categories I and A, considered above.

3.1 Preliminaries on enriched categories

To recall the general definitions, we fix a cocomplete monoidal biclosed category (V,I,&>, [—, =]l, [—, =]r). This can be considered as a V-category, V, with V(X, Y) = [X, Y]r. We assume that V is locally finitely presentable as a closed category, i.e.: every object is a filtered colimit of finitely presentables; the unit I of V is finitely presentable; and the monoidal product of finitely presentables is again finitely presentable. We write |Vf | for a set representing the isomorphism classes of finitely presentables of V.

Consider another V-category, C, with underlying category C. It is said to have tensors if, for all X in V and C in C, there is an object (C • X) in C together with an isomorphism [X, C(C, D)]r = C(C • X, D) natural in D. It is said to have finite cotensors if, for every finitely presentable n in V, and D in C, there is an object [n ^ D] in C together with an isomorphism [n,C(C, D)]l = C(C, [n ^ D]) natural in C.

A V-category C with tensors and finite cotensors is said to be locally finitely presentable as a V-category if C is locally finitely presentable and the induced functors ((-) • X), [n —• (—)]: C —> C preserve filtered colimits for every X and every

finitely presentable n in V.

Note that V has tensors given by monoidal product, and cotensors given by the left closed structure, and that it is locally finitely presentable as a V-category [13].

3.2 Presentations of algebraic theories

A V-signature is a family (En £ V)ne\V{\ of objects of V. In other words, a V-sig-nature is a functor |Vf| ^ V. For each finitely presentable n in V, the object En should be thought of as 'the object of operators of arity n'.

Let C be a V-category with tensors and finite cotensors, and write C for the underlying ordinary category. A model of a V-signature E in C is given by an object X of C, together with morphisms [n —• X] • En ^ X in C for each n in |Vf |. A morphism between E-models is a morphism in C that preserves the interpretations appropriately. We thus have a category Mod(E, C) of E-models.

If C is locally finitely presentable as a V-category, the forgetful functor Mod(E, C) ^ C is monadic. In particular, Mod(E, V) ^ V is monadic. We write Ts for the resulting monad on V. The monad Ts can be thought of as a signature: (Ts)n = Ts(n). Indeed, a model for £ is also a model for the derived signature ((Ts)n)ne\Vf\.

A system of equations for a V-signature E is a V-signature (Eqn)n together with morphisms Xn,pn: Eqn ^ (Ts)n for each finitely presentable n. The object Eqn should be thought of as 'the object of n-ary equations', and Xn and pn assign to each equation the terms on either side, with variables from n.

A model of such an equational system (E, Eq,X,p) is a model X of the signature E for which the following diagram commutes for every finitely presentable n.

[n —• X] • Eqn [n->X]^ [n —• X] • (TE)r

[n—• X]^\

(Ts)n-- X

Proposition 3.1 (c.f. [14,26]) Let (E, Eq) be a V-equational system.

(i) Let C be a locally finitely presentable V-category with tensors and finite cotensors. The forgetful functor Mod((E, Eq), C) ^ C is monadic.

(ii) The forgetful V-functor Mod((E, Eq), V) ^V is V-monadic. We write Eq) for the monad referred to in Proposition 3.1.

Example 3.2 Semilattices. For a simple example, let V be the category of sets, with the cartesian closed structure. Finitely presentable sets are precisely the finite sets, and we let |Vf | be the set of natural numbers. Define E as follows: E0 = {0}; E2 = {+}; and for n £ {0,2}, let En = 0. For any set X, the set Ts(X) contains the terms built from 0 and +, with variables in X. Informally, the equations are:

(z) : 0 + x = x (i) : x + x = x (s) : x + y = y + x (a): x + (y + z) = (x + y) + z.

Formally, we define Eq as follows: Eq 1 = {(z), (i)}; Eq2 = {(s)}; Eq3 = {(a)}; and for n ${1, 2,3}, let Eqn = 0. The morphisms X,p associate each equation with its left and right hand side, respectively. A model of the theory (£, Eq) is a semilattice, and the resulting monad on the category of sets is the finite powerset monad (c.f. Sec. 1.2).

3.3 Enriched Lawvere theories

In the following, we write Vf for the V-category whose objects are finitely presentable objects of V, enriched as V0P(m,n) = [n,m]i. This V-category has finite cotensors, given by [m —• n] = m <8> n.

Definition 3.3 ([22]) A Lawvere V-theory is a small V-category T with finite cotensors, together with an identity on objects, strictly finite cotensor preserving V-functor VP — T.

Let C be a V-category with finite cotensors. A model in C of a Lawvere V-theory T is a finite cotensor preserving V-functor T — C. We write FC(T,C) for the (ordinary) category of finite cotensor preserving V-functors T — C, and V-natural transformations between them.

(N.B. What we are calling a Lawvere V-theory would be called a Vt-theory in [22].)

Every V-equational system (£, Eq) induces an Lawvere V-theory T(S,Eq) with T(e,Eq)(n,m) = V(m,T(S ,Eq)(n)). Composition is as in the Kleisli category. Notice that an equation Eqn ^ (Ts)n, with Eqn = m finitely presentable, is the same thing as a pair of morphisms n ^ m in the Lawvere V-theory Ts.

There is an equivalence of categories, FC(T(S,Eq), C) —+ Mod((£, Eq), C), taking a finite cotensor preserving V-functor M: T(s,Eq) —C. to a model with carrier M(I).

3.4 The special case of I and A

We now return to the setting where I = Set1 and A = Set1 . In Section 2.6, we considered I as an A-category, with all tensors and cotensors.

Consider the finitely presentables of A. Notice that the terminal unit 1 is finitely presentable, and that so are (X * Y) and (X xY) if X and Y are finitely presentable. Note also that i and is: I — A preserve finitely presentables, and that the finitely presentables in I are closed under finite products and include all representable presheaves, notably A. The category A is locally finitely presentable as a closed category, and I is locally finitely presentable as an A-category.

One class of A-equational systems has particularly helpful properties.

Proposition 3.4 Let (£, Eq,X, p) be an A-equational system such that, for every n, the presheaves £n and Eqn are in the image of i: I — A. Then

(i) The monad T(s ) on I is a restriction of T(s Eq) on A, along i: I — A.

(ii) The monad T(s Eq) on I is strong with respect to both the cartesian and the monoidal structure of I.

A n-algebra is a presheaf F in F together with six operations:

sum: [2 ^ F] ^ F out: A x A x F ^ F tau: F ^ F

nil: 1 ^ F in: A x [A ^ F ] ^ F new: [A ^ F] ^ F

satisfying the following equations:

sum ( nil, x) = x new({sum(xa, ya) a) = sum (new ({xa)a), new ({ya)a ))

sum ( x, x) = x new ({out (b, c, xa) a) = out (b,c, new ({xa)a ))

sum (x ,y) = sum (y ,x) new({in(b, (xa,c)c) a) = in(b, (new ({xa,c)a))c)

sum (x, sum(y, z)) = sum (sum (x,y),z) new ({tau(xa) a) = tau(new ({xa)a))

new ((x)a) = x new ({out (a, b, xa) a) = nil (*)

new ({new ((xa>b)b))a) = new ({new ({xa>b)a))b) new({in(a, (xa,b)b) a) = nil

Fig. 1. A theory of late bisimulation in the ^-calculus, taken from [29].

Proof notes. Item (i) can be established by following the transfinite constructions for the two monads (see e.g. [5]), noting that i preserves colimits, cotensors, and tensors of the form ((—) • i(F)). For item (ii), recall that the monad T^ ) on A

is strong (Prop. 3.1 (ii)), and deduce that the monad T^ ) on I is strong with respect to the tensor •; the result follows. □

Proposition 3.4 is important because to use Moggi's monadic metalanguage [17], it is necessary for the monad to have a cartesian strength. Notice that the monad T(A Eq) on A will not, in general, be strong with respect to the cartesian

structure of A, even if the restriction T^, Eq) on I has cartesian strength: this is a

reason to consider the restricted monad T1 „ v

4 Examples: presenting the ^-calculus and local state

We now discuss how theories of the n-calculus and of local state can be understood as A-equational systems.

4.1 A theory of late bisimulation in the n-calculus

Stark [29] has translated the axioms for late bisimulation in the n-calcu-lus [16, Sec. 5] to (what might be called) a presentation of a theory in I, reproduced in Figure 1. Stark shows that the resulting category of models is monadic over I, and that the resulting monad is the one used in the semantics of Fiore et al. [7].

The equations in Figure 1 are notated informally, but can be made precise as follows. Consider the axiom labelled (^): new ({out (a,b,xa))a) = nil. In n-cal-culus notation, it is written va.ab.x = 0. Formally, it amounts to the following

commuting diagram:

A x F-^ [A ^ (A x A x F)] [A ^ F]

where the unlabelled horizontal arrow is the transpose of the morphism A ® (A x F) ^ A x A x F.

The presentation in Figure 1 is not an I-equational system, in the sense of Section 3.2, because it involves both closed structures of I. It can, however, be understood as an ^-equational system. We have seen in Section 2.5 how the operators of the theory can be understood using the tensor and cotensor. The equations can also be understood in this way. To demonstrate this, in diagram (a) below, I have transposed diagram (4) across the adjunction (A x—) H [A ], making use of the transposed operator outB: F ^ [A x A ^ F ].

F °ut ">

F]] [A ^ [A ^ F]] 1

[A ^ F ]

i(A) *i(A)-

-i(A) *iS(A)



The Lawvere ^-theory corresponding to Figure 1 has morphisms including nil : 0 ^ 1, out : 0 ^ i(A) x i(A), new : is (A) ^ 1. Axiom corresponds to diagram (b) above, in the Lawvere ^-theory.

By Proposition 3.1, the category of ^-algebras is monadic over I. By Proposition 3.4, the resulting monad on I is strong with respect to both the monoidal and the cartesian structure.

4-2 A theory of local .state

Plotkin and Power [21] have provided a theory of local state as an informal presentation of a theory in I, reproduced in Figure 2. As they show, the resulting category of models is monadic over I.

Remark 4.1 The theory in Figure 2 is parametric in a presheaf V of values. In [21], a countable set V of values is fixed, and V = Ky, where Ky is the presheaf given by Ky(A) = V. (Here, we must restrict attention to the case where V is finite, so that the arity of Ik will be finitary; alternatively, we could revisit Sec. 3 with reference to locally countably presentable categories.) It seems reasonable to also consider the case V = A + Ky, where the values include the locations, and hence we have a primitive theory of heaps and pointers.

As with the theory of the ^-calculus, the notation in Figure 2 is only informal, but is made precise as follows. Consider the axiom labelled (J): bk(v, {lk(a, (xav)v))a) = bk(v, {xav)a). This corresponds to the program assertion

(block new a := v; let x be !a in M) = (block new a := v; M [v/x]).

An algebra for local state is a presheaf F in F together with three operations:

Ik: A x [V — F] — F up: V x A x F — F bk: V x [A ^ F] — F (lookup) (update) (block)

satisfying the following equations:

Ik (a, (up(a,v,x))v) = x (t) bk (v, {up(a, w, xa))a) = bk (w, (xa)a)

Ik (a, (Ik (a, (xv,w)v ))w) = Ik (a, (xv,v)v) bk (v, {Ik (a, (xa,v )v ))a) = bk (v, (xa,v )a) (t)

up(a,v, up(a,w,x)) = up(a,w,x) bk(v, {x)a) = x

up(a,v, Ik (a, (xv )v)) = up(a,v,xv)

Ik (a, (Ik (b, (xv,w)v ))w) = Ik (b, (Ik (a, (xv,w)w))v) bk (v, {bk (w, {xa,b)b))a) = bk (w, {bk (v, {xa,b)a))b) up(a,v, up(b,w,x)) = up(b,w, up(a,v,x)) bk(v, {up(b,w,xa))a) = up(b,w, bk(v, {xa)a))

up(a,v, lk(b, (xw)w)) = lk(b, (up(a,v, xw))w) bk(v, {Ik(b, (xa,w)w))a) = Ik(b, (bk(v, {xa,w)a))w)

Fig. 2. A theory of local state, taken from [21]. The last three equations in the left column require a side condition: a = b.

What is meant is that the following diagram commutes: [A ^ [V — F]] [A^lk'U [A ^ [A — F]]-[A x A ^ F] ; [A ^ F]

[V - [A ^ F ]] ivqa^kr [V — [V - F [V x V - F ] [A^f] : [V - F ]

The corresponding Lawvere ^-theory includes three morphisms Ik: i(V) — i(A), up: 1 — i(V) x i(A), bk: is (A) — i(V), and axiom (J) amounts to the following equation in the Lawvere ^-theory:

is (A) x i(V) *s(A)*lk , is (A) x i(A)-^ is (A x A)-^l is (A)

i(V) * is (A)-^-- i(V) x i(V) ^^ i(V)

Here, we have elided the equality X x i(F) = X * i(F).

4-2.1 Remark: The monoidal structure on I suffices for presenting local state The theory of local state can be rewritten as a theory involving only the monoidal structure (<8>, of I. There is a natural isomorphism (^2, eval): A ® [A ^ F] = A x F, and, assuming that V is a constant functor (as in [21]) we also have a natural isomorphism [V — F] = [V ^ F]. In place of the update and lookup operations, we can equivalently consider operations lk': A ® [(A x V) ^ F] — F and up': (V x A) ® [A ^ F] — F. For example, following (1), we have a component up 'A: F (A i±J {z}) — F (A i±J {z})V, specifying how to update location z. The axioms can be translated straightforwardly to this


for instance, F] — [V x A

the first axiom (J) in Figure 2 says that the composite

F] — [A ^ F] is the identity.

There are disadvantages to this approach, compared to the approach presented in the remainder of this paper: (i) the translation is limited to the setting where V is constant, and, for a similar reason, one cannot translate the theory of the n-calculus presented in Section 4.1; (ii) the translation weakens the correspondence between the informal presentation of the theory and the formal one, and there is less connection with the presentation of global state in [21]; (iii) Proposition 3.4(ii) cannot be used to establish strength with respect to the cartesian structure of I, although Proposition 3.1 (ii) ensures that the monad on I is enriched with respect to the monoidal structure (<8>,

4.2.2 Remarks on other axioms for local state, and Hilbert-Post completeness There are other axioms that one could consider for local state. For instance:

(V x A) ® F

x(a := v; M) = M, if a £ fv(M)':

(V x A) ® [A


V x [A ^

'(a := v; M) = (block a := v in M end)"

(The second equation implies the first.) These equations are consistent with, but not derivable from, the axioms in Figure 2. Indeed, they are not satisfied in the model T(L) of [21]. Thus the conjecture [21] of Hilbert-Post completeness for Figure 2 is refuted. However, the nature of these equations is such that Proposition 3.4 does not apply. Indeed, the resulting monad does not have cartesian strength, and so the monadic metalanguage is not immediately relevant: the program fragments above have no formal status. Perhaps the theory in Figure 2 is complete with respect to 'cartesian equations'.

5 Two cotensors in one: towards generality

We now axiomatize the structure of the promonoidal category I, of finite sets and injections, that allowed the development in Section 2. We call this 'compatibility structure'. In Section 5.5, we use a compatibility structure on a different category to sketch a presentation of a theory for open bisimulation in the n-calculus.

(The reader might have hoped that the development of Sec. 2 could be carried out for any monoidal and cartesian closed category, or at least for any promonoidal category. But this does not seem to be the case.)

5.1 Compatibility structures

Terminology. Let C be a category, and M be a class of monomorphisms, closed under identity and composition. The M-image of a cospan (A U C A B) is a


with m G M minimal in the sense that it factors through every other such factorization. In this setting we refer to the cospan (A ^ im(f, g) ^ B) as jointly M-covering; it has the property that it is isomorphic to its M-image.

Definition 5.1 A compatibility structure (C, M, is a small category C with an initial object together with: a class M of monomorphisms, closed under composition and identity, such that every cospan in C has an M-image; and a binary relation ^ on morphisms with common codomain such that

(i) ! ^ f and f ^ !, where !: 0 ^ cod(f) is the unique map from the initial object;

(ii) f w g implies jfh ^ jgk, whenever the compositions make sense;

(iii) If mf ^ mg and m GM then f ^ g;

(iv) If hifi ^ hf2, higi ^ hf2,

hifi ^ h2g2, higi ^ h2g2, then hi ^ h2,

where (fi,gi) and (f2,g2) are both jointly M-covering. A compatibility structure is symmetric if f ^ g g ^ f.

Ai ■ Bi

Promonoidal structure from compatibility

A compatibility structure (C, M, —) induces a promonoidal structure on C, in the sense of Day (Sec. 2.1). We let J (A) = 1, and

P (A, B, C ) = {(f,g) | f : A ^ C, g : B ^ C, f - g} .

Using axiom (ii), P extends to a functor P : Cop x Cop x C ^ Set.

The identity and associativity isomorphisms arise as follows. Since 0 is initial,

fAJ(X) x P(X,B,C)^ P(0,B,C) and fX J(X) x P(A,X,C) = P(A, 0,C).

The identity isomorphisms thus follow from axiom (i). As for the associativity isomorphism, notice that

fXP(A,B,X) x P(X, C, D)

= {(f,g,h) I f : A ^ D,g : B ^ D,h : C ^ D; f - g, g - h, f - h} fX P (A, X, D) x P (B, C, X) .

This is established using M-factorization structure, and axioms (ii)-(iv).

5.2 Examples of compatibility structures

Example 5.2 Cartesian structure. For a simple first example, let C be any category with an initial object, and let M be the class of all isomorphisms in C. There is a compatibility structure in which all morphisms with common codomain are related. The induced structure on SetC is the cartesian closed structure.

Example 5.3 Disjoint images in I. Recall that I is the category of finite sets of atoms and injections between them, and let M be the class of all morphisms in I. The M-image of a pair of injections is their set-theoretic image. The compatibility structure defined by f ^ g ^^ im(f ) n im(g) = 0 induces the promonoidal structure on I that we considered in Section 2.2.

Example 5.4 Models for the ^-calculus with distinctions. In some aspects of the ^-calculus, particularly open bisimulation [27], it is important to keep track of which names are distinct. To this end, following [10,15,30], let D be the category whose objects ( A, d^) are pairs of a finite set A together with an irreflexive symmetric binary relation dA on A; a morphism f : (A, d^) ^ (B, ) is given by a function f : A ^ B that respects the distinctions, i.e. if a dA a' then f (a) f (a').

Let M be the class of those monomorphisms m : (A, d^) ^ (B, ) in D for which m (a) m(a') implies a dA a'. We consider the compatibility structure

defined as follows: for a cospan (X, dx) ^ (Z, dz) <— (Y, dy), let

f ^ g ^ Vx G X, y G Y. f(x) dy g(y) .

For a flavour of the structure of SetD, let (&, be the induced symmetric monoidal closed structure on SetD, and let A be the presheaf given on objects by A(A, d^) = A. Now, let z be an atom not in A; the cartesian structure gives a bijection [A ^ F](A, d^) = F (A Ù {z}, d^) and the monoidal structure satisfies

[A ^ F](A, dA) = F (A Ù {z}, dA Ù (A x {z}) Ù ({z} x A)) . (5)

Informally: [A ^ F] is the type of programs involving a fresh atom, whereas [A ^ F] is the type of programs involving an atom which is known to be distinct from all the others.

Other examples. Various authors have used more sophisticated monoidal structures on presheaf categories. The structure considered in [19], for modelling syntactic control of interference, appears to be an example of a compatibility structure. It would be interesting to investigate a process of adjoining 'indeterminates' to compatibility structures, following [11].

5.3 Compatibility structure on categories of monomorphisms

Let (C, M, be a compatibility structure. Write C[M] for the category whose objects are monomorphisms (Sa ^ A) in M; a morphism (Sa,A) ^ (Sb,B) in C[M]

is a morphism A ^ B in C for which there is a morphism Sa ^ Sb making the evident diagram commute. We now give a compatibility structure for C[M]. Note that the category C[M] has an initial object (id: 0 ^ 0), and that it inherits M-images from C. A span

Sa f > Sc^— Sb (6)

is jointly M-covering in C[M] when both (f',g') and (f,g) are jointly M-covering in C. The relation — on C induces a compatibility structure — on C[M]: in the situation of (6), let f — g whenever f — gb. It is straightforward to verify that — satisfies axioms (i)-(iv).

5.4 Revisiting the situation of Section 2

In the setting of Example 5.3, the category I[M] is equivalent to the category I^, and thus we recover the situation of Section 2.3.

In the general setting, the situation is much as in Section 2. Let (C, M, —) be a symmetric compatibility structure. Write C for SetC, and A for SetC[^] ; let (<8>, be the symmetric monoidal closed structure induced by the compatibility structure on C, and let (*, [—, =]i, [—, =]r) be the induced monoidal biclosed structure on A.

• There are embeddings i, is : C^A given on objects by

i(F )(Sa - A) = F (A) is (F )(Sa - A) = F (Sa)

(for F in C), and there is a projection functor S: A^C given by SX (A) = X (A A) (for X in A).

• The functors are adjoint: ■■■ H is H S H i H---.

• The category C is a A-category, with enrichment C(F,G) = [i(F),i(G)]r. It has tensors and cotensors, and Corollary 2.3 holds:

F • i(G) = F x G [i(F) —• G] = [F ^ G]

F • is (G) ^ F ® G [is (F) —• G] = [F ^ G]

5.5 Open bisimulation and the n-calculus

We return to the setting of Example 5.4, writing D for the category of finite sets and distinction relations, with the compatibility structure that we introduced there. Let D be the category SetD, and let A be the presheaf in D given by A(A, dA) = A. Let A be the category SetD[^]. (In fact, the category A is equivalent to one that I used in [31] to study the operational semantics for the n-calculus.)

I now sketch how to understand the well-known axiomatization of open bisimulation [27] as an A-equational system (in the sense of Sec. 3.2). We proceed informally, following Section 4.1. Define an open n-algebra to be a presheaf F in D together

with the six operations of Figure 1 and an additional operator if: A x A x F ^ F, subject to some equations. Before we consider the equations, we note that the free model for this signature £ (without the equations) is the presheaf T^o for which the set Ts,o(A, dA is the set of ^-calculus terms (without parallel composition), up-to a-equivalence, involving free channel names from A.

Sangiorgi [27] presents open bisimilarity as a family of equivalence relations, =d, one for each distinction relation d. Thus D is an appropriate universe, since here an equivalence relation is a subfunctor (=) C T^o x T^o which determines a family of relations of sets, {(=aA) C TSio(A, dA x TSio(A, dA)}A,dA.

There are too many axioms in [27] to list them all here; roughly speaking they include the axioms of Figure 1, plus extra axioms for the interaction and commuta-tivity of the if operator. The interesting new axioms are as follows (informally).

(P) If x d y then (if x = y then P) =d 0 (W) If d C d' and P =d Q then P =d> Q (CR) If P =d Q then (vx. P) =d\W (vx. Q)

There is no need to include axioms (W) and (CR) in the corresponding ^-equational system, for they are satisfied in every E-model. Axiom (W) amounts to functoriality of our equivalence relation, and axiom (CR) follows from the congruence of new, given the explicit description of the type [A ^ F] in (5).

Axiom (P) amounts to diagram (a) below. Notice that A ® A satisfies (A ® A)(A, dA) =dA.

(A ® A) x X>—>^^ X 1-i(A x A)

1-^—i(A ® A)

Diagram (b) is the corresponding diagram in the Lawvere ^-theory.

Consider the free model of the resulting theory, as a presheaf ),o in D. The kernel of the quotient T^o ^ ),o is the family {=dA}dA: open bisimilarity.


It has been helpful to discuss [5,21,29,32] with their authors. I've had helpful discussions with Martin Hyland and Paul Levy too. Referees' comments were helpful. Research supported by EPSRC fellowship EP/E042414/1.


[1] R. A. Clouston. Nominal Lawvere theories. Unpublished manuscript, 2009.

[2] R. A. Clouston and A. M. Pitts. Nominal equational logic. In Computation, Meaning, and Logic: Articles dedicated to Gordon Plotkin, volume 172 of Electron. Notes Theor. Comput. Sci., pages 223— 257. 2007.

B. Day. Construction of Biclosed Categories. PhD thesis, University of New South Wales, 1970.

B. Day. On closed categories of functors. In Reports of the Midwest Category Seminar, IV, volume 137 of Lecture Notes in Math., pages 1—38, 1970.

M. P. Fiore and C.-K. Hur. Equational systems and free constructions. In Proc. of ICALP'07, volume 4596 of Lecture Notes in Comput. Sci., pages 607—618, 2007.

M. P. Fiore and C.-K. Hur. Term equational systems and logics. In Proc. of MFPS XXIV, volume 218 of Electron. Notes Theor. Comput. Sci., pages 171—192, 2008.

M. P. Fiore, E. Moggi, and D. Sangiorgi. A fully abstract model for the ^-calculus. Inform. and Comput, 179(1):76—117, 2002.

M. J. Gabbay and A. Mathijssen. A formal calculus for informal equality with binding. In Proc. of WoLLIC'07, volume 4576 of Lecture Notes in Comput. Sci., pages 162-176, 2007.

M. J. Gabbay and A. M. Pitts. A new approach to abstract syntax with variable binding. Formal Aspects of Computing, 13:341-363, 2001.

N. Ghani, K. Yemane, and B. Victor. Relationally staged computations in calculi of mobile processes.

In Proc. of CMCS'04, volume 106 of Electron. Notes Theor. Comput. Sci., pages 105-120, 2004.

C. Hermida and R. D. Tennent. Monoidal indeterminates and categories of possible worlds. In Proc. of MFPS XXV, 2009.

G. M. Kelly. Basic concepts of enriched category theory, volume 64 of Lecture Notes in Math. Cambridge University Press, 1982.

G. M. Kelly. Structures defined by finite limits in the enriched context, I. Cah. Topol. Geom. Differ. Catég, 23(1):3-42, 1982.

G. M. Kelly and A. J. Power. Adjunctions whose counits are coequalizers, and presentations of finitary enriched monads. J. Pure Appl. Algebra, 89(1-2):163-179, 1993.

M. Miculan and K. Yemane. A unifying model of variables and names. In Proc. of FoSSaCS'05, pages 170-186, 2005.

R. Milner, J. Parrow, and D. Walker. A calculus of mobile processes, II. Inform. and Comput., 100(1):41-77, 1992.

E. Moggi. Notions of computation and monads. Inform. and Comput., 93(1):55-92, 1991.

P. W. O'Hearn. On bunched typing. J. Funct. Programming, 13(4):747-796, 2003.

P. W. O'Hearn, J. Power, M. Takeyama, and R. D. Tennent. syntactic control of interference revisited. Theoret. Comput. Sci., 228(1-2):211-252, 1999.

G. Plotkin and J. Power. Computational effects and operations: An overview. In Proc. of Domains VI, volume 73 of Electron. Notes Theor. Comput. Sci., pages 149-163, 2004.

G. D. Plotkin and J. Power. Notions of computation determine monads. In Proc. of FoSSaCS'02, volume 2303 of Lecture Notes in Comput. Sci., pages 342-356, 2002. Erratum at http://homepages.

A. J. Power. Enriched Lawvere theories. Theory Appl. of Categ., 6(7):83-93, 1999. J. Power. Semantics for computational effects: from global to local. Draft, 2006.

J. Power. Semantics for local computational effects. In Proc. of MFPS XXII, volume 158 of Electron. Notes Theor. Comput. Sci., pages 355-371, 2006.

D. J. Pym. The Semantics and Proof Theory of the Logic of Bunched Implications, volume 26 of Applied Logic Series. Kluwer, 2002.

E. Robinson. Variations on algebra: Monadicity and generalisations of equational theories. Formal Aspects of Computing, 13(3-5):308-326, 2002.

D. Sangiorgi. A theory of bisimulation for the pi-calculus. Acta Inform., 33(1):69-97, 1996. I. Stark. A fully abstract domain model for the ^-calculus. In Proc. of LICS'96, pages 36-42, 1996. I. Stark. Free-algebra models for the ^-calculus. Theoret. Comput. Sci., 390(2-3):248-270, 2008.

[30] S. Staton. Name-Passing Process Calculi: Operational Models and Structural Operational Semantics. PhD thesis, Cambridge, 2007. Technical Report UCAM-CL-TR-688.

[31] S. Staton. General structural operational semantics through categorical logic. In Proc. of LICS'08, pages 166-177, 2008.

[32] A. Ziegler, D. Miller, and C. Palamidessi. A congruence format for name-passing calculi. In Proc. of SOS'05, volume 156 of Electron. Notes Theor. Comput. Sci., pages 169—189, 2006.