Scholarly article on topic 'Freyd categories are Enriched Lawvere Theories'

Freyd categories are Enriched Lawvere Theories Academic research paper on "Computer and information sciences"

CC BY-NC-ND
0
0
Share paper
Keywords
{"Freyd categories" / "Lawvere theories" / "monads and notions of computation"}

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

Abstract Lawvere theories provide a categorical formulation of the algebraic theories from universal algebra. Freyd categories are categorical models of first-order effectful programming languages. The notion of sound limit doctrine has been used to classify accessible categories. We provide a definition of Lawvere theory that is enriched in a closed category that is locally presentable with respect to a sound limit doctrine. For the doctrine of finite limits, we recover Power's enriched Lawvere theories. For the empty limit doctrine, our Lawvere theories are Freyd categories, and for the doctrine of finite products, our Lawvere theories are distributive Freyd categories. In this sense, computational effects are algebraic.

Academic research paper on topic "Freyd categories are Enriched Lawvere Theories"

Available online at www.sciencedirect.com

ScienceDirect

Electronic Notes in Theoretical Computer Science 303 (2014) 197-206

www.elsevier.com/locate/entcs

Freyd categories are Enriched Lawvere Theories

Sam Staton

Radboud University Nijmegen

Abstract

Lawvere theories provide a categorical formulation of the algebraic theories from universal algebra. Freyd categories are categorical models of first-order effectful programming languages.

The notion of sound limit doctrine has been used to classify accessible categories. We provide a definition of Lawvere theory that is enriched in a closed category that is locally presentable with respect to a sound limit doctrine.

For the doctrine of finite limits, we recover Power's enriched Lawvere theories. For the empty limit doctrine, our Lawvere theories are Freyd categories, and for the doctrine of finite products, our Lawvere theories are distributive Freyd categories. In this sense, computational effects are algebraic.

Keywords: Freyd categories, Lawvere theories, monads and notions of computation.

1 Introduction

Strong monads have helped to organize the semantics of impure programming languages from at least two perspectives: firstly by examining the crucial properties of concrete models of programming languages; secondly by axiomatizing the equations between programs that must hold in all models [24,25].

However, more refined perspectives have since emerged.

• Firstly, the monads involved in many concrete models of impure programming languages actually arise as free algebras for equational theories, in the setting of enriched category theory (e.g. [28,29]).

• Secondly, when we separate first-order effectful computation from higher-order types, we arrive at the notion of Freyd categories as an axiomatization of firstorder effectful computation. (Moggi's monad-models can be recovered as closed Freyd categories, see e.g. [19].)

In this paper I explain that the second development can be seen as an instance of the former.

http://dx.doi.org/10.1016/j.entcs.2014.02.010 1571-0661/© 2014 Elsevier B.V. All rights reserved.

Informal overview

The generalization from traditional equational theories to enriched ones proceeds as follows. Recall that in a traditional algebraic signature there is a set of n-ary operations for each natural number n, and so a structure for the signature comprises a function Xn — X for each n-ary operation.

This is enriched by replacing the category of sets by a category V (perhaps the simplest interesting example of V to have in mind is the category of posets and monotone functions). The n-ary operations are no longer required to form a set, but rather an object On of V; the arities n are no longer natural numbers, but rather 'finitary' objects of V; and a structure for such a signature in a given V-enriched category A comprises a morphism On — A(Xn,X) in V, where Xn is a power. (This line of thought goes back to Kelly's work [14,15]; our starting point is Power's development [30]; see also [34] for an overview.)

A traditional equational theory determines a Lawvere theory, which is a category where the objects are natural numbers, and a morphism m — 1 is a term in m variables modulo the equations, and in general a morphism m — n is a family of n terms-mod-equations in m variables. The categories arising in this way can be characterized as categories L with finite products equipped with a functor J : Nop — L, where N is the category of natural numbers and functions between them; the functor J is required to be identity-on-objects (i.e. Nop and L have the same objects) and to preserve products.

Similarly a V-enriched Lawvere theory [30] is defined to be a V-enriched category L with 'finitary' powers and an identity-on-objects finitary-power-preserving V-functor Fop — L, where F is the category of finitary objects of V.

On the other hand, the notion of Freyd category arose in the work of Levy, Power and Thielecke [19,33] as a categorical framework for first order effectful programs. Recall the basic ideas of the categorical interpretation of type theory: that types are denoted by objects of a category, that a context is denoted by the product of its constituent types, and that a judgement r h t : t is interpreted as a morphism r — t in the category. A Freyd category comprises two categories with the same objects: one V, whose morphisms denote pure, value judgements, and one C, whose morphisms denote judgements of computations, together with an identity-on-objects functor J : V — C. For example, C might be the Kleisli category for a strong monad on V. Since the order of effectful computation matters, C typically does not have products, but it does have a product-like structure, and the functor J is required to preserve it. This was initially described in terms of premonoidal categories [32]. Subsequently, Levy used a formulation based on actions of monoidal categories [18, App. B] (see also [23]) and that is what we use in this paper.

Coming back to the definition of enriched Lawvere theory, notice that, naively put, there is some choice in what is meant by 'finitary' when it comes to the arities. When V = Set, 'finitary' means finite. Power takes V to be a locally finitely presentable category, and 'finitary' means finitely presentable. If V is a category with finite products, and V is the functor category [Vop, Set], then we can take 'finitary' to mean representable. In this case, an enriched Lawvere theory is the

same thing as a Freyd category (Theorem 3.3).

Several authors have found profit in analyzing the 'arities' of monads and Law-vere theories, including in the study of computational effects [4,7,16,20,21]. The line of work best suited for us is the classification of accessible categories by Adamek et al. [1]. This is based on a notion of sound limit doctrine D, and includes concepts of D-presentable object, which form our arities, and locally D-presentable categories. A locally D-presentable category is tightly connected with its subcategory of D-presentable objects, since each is determined by the other. We consider enriched Lawvere theories in this setting, following Lack and Rosicky [16]

By considering different sound limit doctrines we recover familiar concepts:

• For the sound doctrine of finite limits, enriched Lawvere theories are the concept defined by Power [30].

• For the sound doctrine of finite products, enriched Lawvere theories are the same as distributive Freyd categories (Theorem 3.5).

• For the empty sound doctrine, enriched Lawvere theories are the same as Freyd categories (Theorem 3.3).

2 Preliminaries

2.1 Sound limit doctrines

A sound limit doctrine is a class of limits that admits a well-behaved refinement of the theory of accessible and locally presentable categories [1].

Definition 2.1 [1] A doctrine is a set D of small categories. A D-limit is a limiting cone whose diagram is indexed by a category in D. Dually a D-colimit is a colimiting cone whose diagram is indexed by a category in D. We write Dop for the doctrine {Dop I D e D}.

A set of small categories D is a sound limit doctrine if for any functor F : A — Set the left Kan extension [Aop, Set] — Set of F along the Yoneda embedding A — [Aop, Set] preserves D-limits if and only if it preserves D-limits of representables.

The condition of soundness ensures that the theory of accessible and locally presentable categories, which is traditionally based on A-small limits, makes sense for D-limits. Examples of sound limit doctrines include:

• FinLim: the doctrine of finite limits;

• FinProd: the doctrine of finite products;

• 0: the empty doctrine.

Those are the three doctrines that we study in this paper.

Definition 2.2 [1] Let D be a sound limit doctrine. A small category C is D-filtered if C-indexed colimits commute in Set with D-limits (i.e. the functor colim : [C, Set] — Set preserves D-limits). A D-filtered colimit is a colimiting cone

whose diagram is indexed by a D-filtered category.

For example:

• A FinLim-filtered category is normally just called a filtered category.

• A FinProd-filtered category is sometimes called a sifted category [3]. Roughly speaking, sifted colimits are built from filtered colimits and reflexive coequalizers.

• All categories are trivially 0-filtered, so a D-filtered colimit is the same thing as a colimit.

2.2 Locally presentable categories

Definition 2.3 Let D be a sound limit doctrine. Let A be a category with all small colimits. An object a of A is D-presentable if the representable functor A(a, —) : A ^ Set preserves D-filtered colimits. The cocomplete category A is locally D-presentable if there is a set F of D-presentable objects such that every object of A is a D-filtered colimit of objects from F.

For example:

• A locally 0-presentable category is a presheaf category [Fop, Set] and the 0-presentable objects are retracts of representables.

• Any locally 0-presentable category is also locally FinProd-presentable. More generally, the category of models for a multi-sorted algebraic theory is always a locally FinProd-presentable category, and all locally FinProd-presentable categories arise in this way (e.g. [3]). In particular, the category of sets is locally FinProd-presentable, and the FinProd-presentable objects are the finite sets.

• A locally FinLim-presentable category is normally called a locally finitely presentable category (e.g. [2]). Any locally FinProd-presentable category is also locally FinLim-presentable. More generally, the category of models for an 'essentially algebraic' theory is always a locally finitely presentable category, and all locally finitely presentable categories arise in this way.

2.3 Locally presentable symmetric monoidal closed categories

The following definition is a mild generalization of the standard concept of a locally finitely presentable closed category [15].

Definition 2.4 Let D be a sound limit doctrine. A symmetric monoidal closed category (V, ®,I) is locally D-presentable as a symmetric monoidal closed category if it is locally D-presentable, if I is D-presentable, and a ® b is D-presentable when a and b are.

If (V, ®,I) is locally D-presentable as a closed category, then we define a basis for V to be a small full subcategory F of V whose objects are D-presentable, which is closed under Dop-colimits and ® and I, and which is such that every object of V is a D-filtered colimit of objects from F.

Note that an object of a locally D-presentable closed category is D-presentable if and only if it is a retract of an object in the basis. If D contains the category with one object and one idempotent non-identity morphism, e.g. if D = FinLim, then the basis is closed under retracts and so all bases are equivalent.

Recall (e.g. [2, Prop. 1.45]) that for any category F with Dop-colimits, the category [Fop, Set]D of D-limit-preserving set-valued functors and natural transformations has a universal property as a cocompletion. It has small colimits; the Yoneda embedding restricts to a functor F — [Fop, Set]D that preserves Dop-colimits; and every Dop-colimit-preserving functor G : F — A with A cocomplete extends to a colimit-preserving-functor G* : [Fop, Set]D — A, unique up-to unique isomorphism. The extension G* has a right adjoint, G* : A — [Fop, Set]D, with G*(x) = A(G(—),x).

Moreover, if (F, ®,i) is a symmetric monoidal category with Dop-colimits and (a ®—) : F — F preserves Dop-colimits for all a, then [Fop, Set]D is a symmetric monoidal closed category and the embedding F — [Fop, Set]D preserves the symmetric monoidal structure [8,11].

Proposition 2.5 Let D be a sound limit doctrine.

• Let F be a small symmetric monoidal category F with Dop-colimits such that a® — preserves Dop-colimits for all a in F. Then [Fop, Set]D is locally D-presentable as a closed category, with basis F.

• Let V be locally D-presentable as a closed category, with basis F. It is equivalent to [Fop, Set]D.

2.4 Actions and powers

The relationship between monoidal actions and enrichment is widely understood (e.g. [13]) and has proved useful in studying algebraic theories and notions of computation (e.g. [9], [10, Ch. 6], [18], [23]). Proposition 2.7 is the main step towards our two main theorems.

Definition 2.6 Let (C, ®,i) be a monoidal category and let A be an ordinary category. An action of C on A is a functor M : C xA — A together with natural isomorphisms

M(i,x) = x M(c ® d,x) = M(c,M(d,x))

satisfying the evident coherence conditions.

Note that any monoidal category acts on itself in the obvious way.

Recall [14] that, for a symmetric monoidal category (V, <8>,I), a V-enriched category C is like an ordinary category except that between a pair of objects x, y in C, we have an object C(x, y) of V instead of a set of morphisms. Any enriched category C has an underlying ordinary category C with the same objects and with hom-sets

C(x, y) = V(I, C(x, y)). An enrichment of an ordinary category C in V is defined to be a V-enriched category C whose underlying ordinary category is C. For example, if V is a symmetric monoidal closed category, then the closed structure provides an enrichment of V in itself.

Finally, recall the definition of powers (aka cotensors) in a category C enriched in a symmetric monoidal closed category (V, <8>,I). For x G C, a GV, a power is an object xa together with an isomorphism V(a, C(y,x)) = C(y,xa) that is natural in y.

Proposition 2.7 Let D be a sound limit doctrine. Let (V, ®,I) be locally D-presentable as a closed category with a basis F. Let C be an ordinary category. The following data are equivalent.

(i) An action M of the monoidal category Fop on C such that for each x in C the functor M(—,x) : Fop ^ C preserves D-limits.

(ii) An enrichment of C in V with powers by objects in F.

Proof notes. From (ii) to (i): let M(a,x) be the power xa. From (i) to (ii): we define the hom-object C(x, y) in V by working up to the equivalence V ~ [Fop, Set]D: let C(x,y)(a)= C(x,ya). □

Proposition 2.7 is probably known quite widely. An instance (D = 0) of Proposition 2.7 is implicit in Levy's work on call-by-push-value [18] and more recently explicit in Mellies work ([22, Prop. 11], [21, Lecture 6]).

3 Enriched Lawvere theories and Freyd categories

We now consider a definition of Lawvere theory enriched in a locally D-presentable closed category. We recall the definitions of Freyd category and distributive Freyd category, and show that they are instances of the concept of Lawvere theory.

3.1 Enriched Lawvere theories

Definition 3.1 Let D be a sound limit doctrine, and let (V, ®,I) be locally D-presentable as a closed category, with a basis F. A V-Lawvere theory is given by

• a category L enriched in V with powers by objects of F.

• an identity-on-objects V-functor Fop ^ L that preserves powers by objects of F.

The choice of basis F is irrelevant to the following extent. Define a change of basis (p, r,s) : F ^ F' to be given by, for each a in F a choice of a section/retraction pair, (a ^ pa a) = id, with pa in F'. This choice determines an assignment from Lawvere theories L' wrt F' to Lawvere theories L wrt F: let L(a, b) be the equalizer

Sb'Tb —

L(a,b) -L'(Pq,Pft)~ ^ L'(pa,pb)

(We could simplify this situation by requiring bases to be closed under retracts, but this would complicate our main theorems, 3.3 and 3.5.)

When D = FinLim, Definition 3.1 is the definition of Power [30]. When, moreover, V is the category of sets with cartesian product structure, this is the original definition of Lawvere [17]. For a broader study of notions of Lawvere theory, including this one, see the article by Lack and Rosicky [16]. It follows from the results in [16, §7] that, for a locally D-presentable closed category V, to give a Lawvere V-theory is to give an enriched monad on V that preserves D-filtered colimits.

3.2 Freyd categories

We recall a formulation of Freyd categories proposed by Levy [18, App. B]. Definition 3.2 A Freyd category is given by

• a small category V with finite products;

• a small category C;

• an action of V on C (with the finite products providing a symmetric monoidal structure for V);

• an identity on objects functor V — C that preserves the actions.

Theorem 3.3 The following data are equivalent.

• A Freyd category.

• A Lawvere theory enriched in a locally 0-presentable cartesian closed category.

Proof notes. A Freyd category, i.e. an identity-on-objects action-preserving-functor V — C, can equivalently be described as an identity-on-objects action-preserving-functor Vop — Cop, which (by Prop. 2.7) is the same thing as a [Vop, Set]-enriched power-preserving functor Vop — Cop, which is the same thing as a Lawvere theory enriched in a locally 0-presentable cartesian closed category.

3.3 Distributive Freyd categories

Recall that a distributive category is a category with finite sums and products such that for all objects a the functor a x (—) preserves sums. This is a model for simple first order type theory with sums and products. A distributive Freyd category [19,31,23], then, is a model for an effectful first order language with sums and products.

Definition 3.4 A distributive Freyd category is given by

• a distributive category V;

• a category C with finite coproducts;

• an action of V on C that distributes over coproducts (i.e. M(a, —) preserves coproducts for all a in V);

• an identity on objects functor V ^ C that preserves the action and coproducts. Theorem 3.5 The following data are equivalent.

• A distributive Freyd category.

• A Lawvere theory enriched in a locally FinPtod-presentable cartesian closed category.

Remark. In this paper we focused on three sound limit doctrines: finite limits, finite products, and the empty doctrine. I am only aware of three other kinds of sound limit doctrine: terminal objects (whose enriched Lawvere theories are like distributive Freyd categories but with an initial object instead of all finite coproducts), finite connected limits, and A-small limits for a regular cardinal A.

Other work in this direction.

Power [31] already used ordinary Lawvere theories to build examples of distributive Freyd categories. He moreover showed how to build an enriched monad on [Vop, Set] from a Freyd category V ^ C, and how to build an enriched monad on [Vop, Set]Finptod from a distributive Freyd category V ^ C. (There, enriched monads are explained in terms of closed Freyd categories.)

Several other authors have discussed the relationships between Freyd categories, monads and the Yoneda embedding [4,5,6,12].

My own main starting point was my work with M0gelberg [23]. We considered 'effect theories', which are a programming language syntax for those distributive Freyd categories where V is a free finite coproduct completion of a category with finite products. In that work we used effect theories in the same way that one uses classical algebraic theories, by considering their models and comodels. Subsequently I developed 'parameterized algebraic theories' [35,36], which are an alternative syntax and deduction system for the same structures (with syntax inspired by [26,27]). One could say that the programming language syntax is for distributive Freyd categories V ^ C whereas the algebraic syntax is for the corresponding enriched Lawvere theories Vop ^ Cop.

The purpose of this paper was to emphasise the relationship between effectful computation and universal algebra.

Acknowledgement

It has been helpful about this topic with many people over the years, including Danel Ahman, James Chapman, Jeff Egger, Marcelo Fiore, Chung-Kil Hur, Martin Hyland, Alexander Kurz, Paul Levy, Paul-Andre Mellies, Rasmus M0gelberg, John Power, Mathys Rennela, Alex Simpson, Stephan Spahn, and Tarmo Uustalu.

This research has been supported by ERC Grant 'Quantum Computation, Logic, and Security'.

S. Staton / Electronic Notes in Theoretical Computer Science 303 (2014) 197—206 205

References

[1] Adamek, J., F. Borceux, S. Lack and J. Rosicky, A classification of accessible categories, J. Pure Appl. Algebra 175 (2002), pp. 7-30.

[2] Adamek, J. and J. Rosicky, "Locally presentable and accessible categories," Cambridge University Press, 1994.

[3] Adamek, J. and J. Rosicky, On sifted, colimits and generalized varieties, Theory Appl. Categ. 8 (2001), pp. 33-53.

[4] Altenkirch, T., J. Chapman and T. Uustalu, Monads need not be endofunctors, in: Proc. FOSSACS

2010, Lecture Notes in Computer Science 6014 (2010), pp. 297-311.

[5] Asada, K., Arrows are strong monads, in: Proc. MSFP 2010, 2010, pp. 33-42.

[6] Atkey, R., What is a categorical model of arrows?, in: Proc. MSFP 2008, Electr. Notes Theor. Comput. Sci. 229, 2011, pp. 19-37.

[7] Berger, C., P.-A. Mellies and M. Weber, Monads with arities and their associated theories, J. Pure Appl. Algebra 216 (2012), pp. 2029-2048.

[8] Day, B., On closed categories of functors, in: Reports of the Midwest Category Seminar, IV, Lect. Notes Math. 137 (1970), pp. 1-38.

[9] Fiore, M. P., Second-order and dependently-sorted abstract syntax, in: Proc. LICS 2008, 2008, pp. 57-68.

[10] Hur, C.-K., "Categorical Equational Systems: Algebraic Models and Equational Reasoning," Ph.D. thesis, University of Cambridge (2009).

[11] Im, G. and G. Kelly, A universal property of the convolution monoidal structure, J. Pure Appl. Algebra

43 (1986), pp. 75-88.

[12] Jacobs, B., C. Heunen and I. Hasuo, Categorical semantics for arrows, J. Funct. Program. 19 (2009), pp. 403-438.

[13] Janelidze, G. and G. Kelly, A note on actions of a monoidal category, Theory Appl. Categ. 9 (2001), pp. 61-91.

[14] Kelly, G. M., "Basic concepts of enriched category theory," Cambridge University Press, 1982.

[15] Kelly, G. M., Structures defined by finite limits in the enriched context, I, Cahiers de topologie et geometrie différentielle categoriques 23 (1982), pp. 3-42.

[16] Lack, S. and J. Rosicky, Notions of Lawvere theory, Applied Categorical Structures 19 (2011), pp. 363391.

[17] Lawvere, F. W., "Functorial Semantics of Algebraic Theories," Ph.D. thesis, Columbia University (1963), Reprints in TAC no. 5.

[18] Levy, P. B., "Call-by-Push-Value. A Functional/Imperative Synthesis," Semantic Structures in Computation 2, Springer, 2004.

[19] Levy, P. B., J. Power and H. Thielecke, Modelling environments in call-by-value programming languages, Information and Computation 185 (2003), pp. 182-210.

[20] Mellies, P.-A., Segal condition meets computational effects, in: Proc. LICS 2010, 2010, pp. 150-159.

[21] Mellies, P.-A., Local stores in string diagrams (2011), slides from a lecture course, available online at http://tinyurl.com/mellies-itu-2011.

[22] Mellies, P.-A., Parametric monads and enriched adjunctions (2012), unpublished draft available at http://www.pps.univ-paris-diderot.fr/~mellies/tensorial-logic.html.

[23] M0gelberg, R. E. and S. Staton, Linearly-used state in models of call-by-value, in: Proc. CALCO 2011,

2011, pp. 298-313.

[24] Moggi, E., Computational lambda-calculus and monads, in: Proc. LICS'89 (1989), pp. 14-23.

[25] Moggi, E., Notions of computation and monads, Information and Computation 93 (1991), pp. 55-92.

[26] Plotkin, G., Some varieties of equational logic, in: Algebra, meaning and computation, Springer, 2006 .

[27] Plotkin, G. and M. Pretnar, Handlers of algebraic effects, in: Proc. ESOP 2009 (2009), pp. 80-94.

[28] Plotkin, G. D. and A. J. Power, Computational effects and operations: An overview, in: Proc. Domains VI, Electr. Notes Theor. Comput. Sci. 73 (2004), pp. 140-163.

[29] Plotkin, G. D. and J. Power, Notions of computation determine monads, in: Proc. FOSSACS 2002 (2002), pp. 342-356.

[30] Power, J., Enriched Lawvere theories, Theory Appl. Categ. (1999), pp. 89-93.

[31] Power, J., Generic models for computational effects, Theor. Comput. Sci. 364 (2006), pp. 254-269.

[32] Power, J. and E. Robinson, Premonoidal categories and notions of computation, Math. Struct. in Comput. Sci. 7 (1997), pp. 453-468.

[33] Power, J. and H. Thielecke, Closed Freyd- and K-categories, in: Proc. ICALP'99, Lecture Notes in Comput. Sci. 1644, 1999, pp. 625-634.

[34] Robinson, E., Variations on algebra: Monadicity and generalisations of equational theories, Formal Asp. Comput. 13 (2002), pp. 308-326.

[35] Staton, S., An algebraic presentation of predicate logic, in: Proc. FOSSACS 2013, 2013, pp. 401-417.

[36] Staton, S., Instances of computational effects: An algebraic perspective, in: Proc. LICS 2013, 2013, pp. 519-519.