Modules over monads and operational semantics
aa r X i v : . [ c s . P L ] D ec MODULES OVER MONADS AND OPERATIONAL SEMANTICS
ANDR´E HIRSCHOWITZ, TOM HIRSCHOWITZ, AND AMBROISE LAFONTUniversit´e Cˆote d’Azur, CNRS, Nice, FranceUniv. Grenoble Alpes, Univ. Savoie Mont Blanc, CNRS, LAMA, 73000, Chamb´ery,FranceUNSW, Sydney, Australia
Abstract.
This paper is a contribution to the search for efficient and high-level math-ematical tools to specify and reason about (abstract) programming languages or calculi.Generalising the reduction monads of Ahrens et al., we introduce transition monads, thuscovering new applications such as 𝜆𝜇 -calculus, 𝜋 -calculus, Positive GSOS specifications,differential 𝜆 -calculus, and the big-step, simply-typed, call-by-value 𝜆 -calculus. Moreover,we design a suitable notion of signature for transition monads. Introduction
The search for a mathematical notion of programming language goes back at least to Turiand Plotkin [51], who coined the name “Mathematical Operational Semantics”, and ex-plained how known classes of well-behaved rules for structural operational semantics, suchas GSOS [15], can be categorically understood and specified via bialgebras and distributivelaws. Their initial framework did not cover variable binding, and several authors have pro-posed variants which do [27, 26, 49], treating examples like the 𝜋 -calculus. However, noneof these approaches covers higher-order languages like the 𝜆 -calculus.In recent work, following previous work on modules over monads for syntax with bind-ing [35, 6] (see also [5]), Ahrens et al. [7] introduce reduction monads , and show howthey cover several standard variants of the 𝜆 -calculus. Furthermore, as expected in similarcontexts, they propose a mechanism for specifying reduction monads by suitable signatures.Our starting point is the fact that already the call-by-value 𝜆 -calculus does not forma reduction monad. Indeed, in this calculus, variables are placeholders for values but notfor 𝜆 -terms; in other words, reduction, although it involves general terms, is stable undersubstitution by values only. In the present work, we generalise reduction monads to whatwe call transition monads . The main new ingredients of our generalisation are as follows. • We now have two kinds of terms, called placetakers and states : variables are place-holders for our placetakers, while transitions relate states. Typically, in call-by-value,small-step 𝜆 -calculus, placetakers are values, while states are general terms. Key words and phrases: operational semantics; category theory.An extended abstract of this paper appeared in FSCD ’20 [34]. The present version incorporates severalimprovements and additions, listed in § Preprint submitted toLogical Methods in Computer Science © A. Hirschowitz, T. Hirschowitz, and A. Lafont CC (cid:13) Creative Commons
A. HIRSCHOWITZ, T. HIRSCHOWITZ, AND A. LAFONT • We also have a set of types for placetakers, and a possibly different set of types fortransitions and states: transitions of a given type relate states of this type. Typically,in the simply-typed, call-by-value 𝜆 -calculus, both sets of types coincide and are givenby simple types; while in ¯ 𝜆𝜇 -calculus, we have two placetaker types, one for programsand one for stacks, and three transition types, respectively for programs, stacks, andcommands. • We in fact have two possibly different kinds of states for each transition type, source states and target states, so that a transition of a given type now relates a source stateto a target state of this type. Typically, in untyped, call-by-value, big-step 𝜆 -calculus,source states (of the unique transition type) are general terms, while target states arevalues. • Our variables form a (variable!) family of sets indexed by the placetaker types. To sucha variable object 𝑋 , a transition monad assigns – an object 𝑇 ( 𝑋 ) (‘of placetakers with free variables in 𝑋 ’), which is again a family ofsets indexed by the placetaker types, and – two state objects 𝑆 ( 𝑇 ( 𝑋 )) and 𝑆 ( 𝑇 ( 𝑋 )) (‘of source (resp. target) states with freevariables in 𝑋 ’), which are families of sets indexed by transition types; here 𝑆 and 𝑆 are two functors producing state objects out of palcetaker objects.Roughly speaking (see § • a placetaker monad 𝑇 , • two state functors 𝑆 , 𝑆 , • a transition structure consisting of a 𝑇 -module 𝑅 and two 𝑇 -module morphisms src : 𝑅 → 𝑆 𝑇 and tgt : 𝑅 → 𝑆 𝑇 ,where 𝑇 -modules [35] are objects equipped with substitution by elements of 𝑇 . We viewthe transition structure ( 𝑅, src , tgt ) as an object of the slice category 𝑇 - Mod 𝑓 / 𝑆 𝑇 × 𝑆 𝑇 of (finitary) 𝑇 -modules over 𝑆 𝑇 × 𝑆 𝑇 .Reduction monads [7] correspond to the untyped case with 𝑆 = 𝑆 = Id Set . There,reduction monads are identified with suitable relative monads [8], and we provide asimilar identification for transition monads (see Proposition 3.6).We present our series of examples of transition monads in § 𝜆𝜇 -calculus, simply-typed 𝜆 -calculus (in its call-by-value, big-step variant), 𝜋 -calculus (as an unlabelled transitionsystem), positive GSOS systems, and differential 𝜆 -calculus.The rest of this work concerns the specification of transition monads via signaturesin the spirit of Initial Semantics [30]. This approach to specification is categorical in na-ture, and that is why we have to upgrade our sets of transition monads into categories,say TrMnd ( P , S ) , one for each pair ( P , S ) of sets of placetaker types and transition types(see § register : for a category C , aregister consists of(1) a set Sig of signatures ,(2) a semantics map J − K assigning to each signature 𝑆 in Sig a category 𝑆 -alg of algebras ,together with a forgetful functor 𝑈 : 𝑆 -alg → C , and(3) a validity proof of the fact that for each 𝑆 , the category 𝑆 -alg has an initial object.A register for C yields a “specification” map spec sending 𝑆 to spec ( 𝑆 ) : = 𝑈 ( ) , where 0 heredenotes the initial object in 𝑆 -alg. The efficiency of a register for a category lies in the fact Here “algebra” and “forgetful” have no technical meaning and are chosen by analogy.
ODULES OVER MONADS AND OPERATIONAL SEMANTICS 3 that it allows the expert to easily formalise the informal specification she has in mind forthe relevant object. We illustrate in §
11 the expressiveness of our register
TrModMnd ( P , S ) for transition monads by designing signatures for our examples of §
4. For Positive GSOSsystems, we even go further by defining a specific register, in which each individual systemis more easily specified.Our register for transition monads is built out from three intermediate registers: • a register ModMnd ( P ) for monads in the category Set P , • a register PModFun ( P , S ) for functors between Set P and Set S , and • a register Slice ∗ ( C , 𝑀 ) for a given slice category C / 𝑀 .And as could be expected, a signature for a transition monad in our register TrModMnd ( P , S ) is a record consisting of • a signature in ModMnd ( P ) specifying the placetaker monad 𝑇 , • two signatures in PModFun ( P , S ) specifying the state functors 𝑆 and 𝑆 , and • a signature in Slice ∗ ( 𝑇 - Mod 𝑓 , 𝑆 𝑇 × 𝑆 𝑇 ) specifying the transition structure.Here, a crucial feature is that the involved register in the last field of this record depends onthe objects specified by previous fields. This contrasts with the approach taken in [7], wherethe corresponding field cannot be expressed in terms of the specified placetaker monad,and must instead be parametric in the models of previous fields. Our approach allowsmore signatures, and we take advantage of this subtle fact in our treatment (see § 𝜆 -calculus [20]. Let us mention that the counterpart forthis advantage is that the recursion principle induced by our initial semantics is significantlyweaker than could be expected (see Remark 9.2 and § 𝑇 , whose equational nature manifests itself through thefact that 𝑇 is a coequaliser of a parallel pair 𝑅 ⇒ 𝑆 of monad morphisms. In principle, thus,the free model on an object 𝑋 is simply 𝑇 ( 𝑋 ) . But the question is: how do we compute 𝑇 ? In each case, 𝑅 and 𝑆 come with explicit, syntactic characterisations, but the problemis that colimits of monads are far from easy to compute. The solution will follow if we finda functor 𝑈 : Mnd 𝑓 ( C ) → D from monads to some other category D , such that • we know how to compute coequalisers in D , and • 𝑈 creates the desired coequaliser. A. HIRSCHOWITZ, T. HIRSCHOWITZ, AND A. LAFONT
Indeed, the latter means that any coequaliser 𝑈 ( 𝑅 ) ⇒ 𝑈 ( 𝑆 ) → 𝑄 lifts to a unique coequalis-ing arrow 𝑅 ⇒ 𝑆 → ˜ 𝑄 , which in fact is a coequaliser, hence the desired monad. In practice,we will take D to be the category of finitary endofunctors on C , where we know how tocompute coequalisers (namely pointwise). Thus, the carrier of the free model on any 𝑋 ∈ C is the coequaliser of 𝑈 ( 𝑅 ) ( 𝑋 ) ⇒ 𝑈 ( 𝑆 ) ( 𝑋 ) .More concretely, this description is a crucial ingredient of our treatment of the differen-tial 𝜆 -calculus: as already mentioned, the type of the third field of its signature depends inparticular on the monad specified by the first field, and the description we give for this thirdfield relies on our “free+quotient” description for that monad (see the proof of Lemma 11.1).1.1. Plan. In §
2, we present our notations and give some categorical preliminaries. In § §
4, we present our selected examples (in the traditional way).Then, in §
5, we introduce registers, and rephrase the relevant parts of the current knowledgeon signatures in terms of registers, including three fundamental tools: the endofunctorial , equational , and monoidal families of registers. We also provide elementary methodsfor constructing new registers out of existing ones. We then exploit these results in § § ModMnd ( P ) and PModFun ( P , S ) , respectively for monadsand state functors, in the spirit of [7]. Then, in §
8, we define our “slice” registers, inparticular the registers
Slice ∗ ( 𝑇 - Mod 𝑓 , 𝑆 𝑇 × 𝑆 𝑇 ) (for 𝑇 - Mod 𝑓 / 𝑆 𝑇 × 𝑆 𝑇 ). Our categoriesand our main registers TrModMnd ( P , S ) are delivered in §
9. In §
10, we explain how initialalgebras of signatures of our intermediary registers involving equations can be computed(as coequalisers). We then revisit our examples in §
11, specifying them through signaturesof our registers
TrModMnd ( P , S ) for transition monads. Finally, we conclude in §
12 bysumming up our contributions, assessing the scope of our registers
TrModMnd ( P , S ) , andgiving some perspectives.1.2. Related work.
As mentioned above, our work refines a recent work [7], allowingto cover many new applications with the same approach. This approach differs from thebialgebaic one introduced long ago by Plotkin and Turi [51]: the positive difference is thatit covers higher-order languages like the 𝜆 -calculus, while a negative difference is that itdoes not recover congruence of bisimilarity.The present work is largely about signatures and relies heavily on previous work on equa-tional systems [23], pointed strong endofunctors [24], and modules over monads [6]. We elab-orate on equational systems and modules over monads by establishing new characterisationsof initial models under mild additional hypotheses (Theorem 10.12 and Corollary 10.23).Wefurther introduce a new register ( § monoidal equational systems ,combine pointed strong endofunctors and equational systems.Concerning our registers for slice categories, we suspect that they could be understoodin terms of polynomial functors [39], as they were recently used in a similar context byArkor and Fiore [11].We are aware of a few notions of signatures for languages with variable binding equippedwith some notion of evaluation (or transition), e.g., Hamana [31], T. Hirschowitz [36], andAhrens [5]. They essentially model rewriting, which implies that transitions are closed underarbitrary contexts. Such approaches cannot cover languages like the 𝜋 -calculus, in whichtransitions may not occur under inputs or outputs. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 5
As is well-known, evaluation is an oriented variant of equality, and transition proofs arean oriented form of identity proofs. For this reason, notions of signatures for dependently-typed languages like type theory may provide an alternative approach to the specification ofoperational semantics systems. Examples of such notions of signatures include Fiore’s simpledependently-sorted signatures [22], Altenkirch et al.’s categorical semantics of inductive-inductive definitions [9], and Garner’s combinatorial approach [28]Finally, let us mention that a preliminary version of the present work appears in thethird author’s PhD thesis [41, Chapter 6].1.3.
Differences with conference version.
Here is a list of significant differences w.r.t.the conference version, beyond more detailed proofs. • We provide an alternative way in which to organise the 𝜋 -calculus as a transition monad. • We design a new register combining the features of equational systems and pointed strongendofunctors into monoidal equational systems ( § • We design an abstract version of the original register for slice module categories. Inpassing, the new version is slightly more expressive. • We provide an explicit construction (as coequalisers) of the initial algebras of signaturesinvolving equations in § • Finally, we correct a few errors, notably we had omitted the congruence rules for reduc-tion in ¯ 𝜆𝜇 -calculus and differential 𝜆 -calculus. Regarding differential 𝜆 -calculus, we nowaccount for the syntactic equation 𝐷 ( 𝐷𝑒 · 𝑓 ) · 𝑔 ≡ 𝐷 ( 𝐷𝑒 · 𝑔 ) · 𝑓 . We had also erroneouslyclaimed that the method we used for defining unary multiterm substitution applies topartial derivation. We now rely on the characterisations of §
10 for both operations.2.
Notations and categorical preliminaries
In this section, we fix some notation, and recall a few categorical notions. We advisethe reader to skip it, except perhaps § § § § convenient monoidal category,which is just a monoidal category with additional hypotheses. This is important for usbecause we will use finitary monads a lot, and these are monoids for the compositionmonoidal structure on the category of finitary endofunctors. We show in particular that thiscomposition monoidal structure is convenient. We go on in § § § CAT . A. HIRSCHOWITZ, T. HIRSCHOWITZ, AND A. LAFONT
Basic notation.
In the following,
Set denotes the category of sets,
SET denotes thecategory of large sets, of which
Set is an object, and
CAT denotes the (very large) cate-gory of locally small categories. We often implicitly view natural numbers 𝑛 ∈ N as thecorresponding set { , . . . , 𝑛 } , so that, e.g., 2 ∈
3. Furthermore, in any category, we denoteby h 𝑓 , 𝑔 i : 𝐶 → 𝐴 × 𝐵 the pairing induced by any morphisms 𝑓 : 𝐶 → 𝐴 and 𝑔 : 𝐶 → 𝐵 .Similarly, the copairing of 𝑓 : 𝐴 → 𝐶 and 𝑔 : 𝐵 → 𝐶 is denoted by [ 𝑓 , 𝑔 ] : 𝐴 + 𝐵 → 𝐶 .2.2. Locally finitely presentable categories and finitary functors.
We heavily relyon the theory of locally finitely presentable categories [2]. Very briefly, recall that filteredcategories are a categorical generalisation of directed posets. A category is filtered when • it is not empty, • for any two objects 𝐶 and 𝐷 , there is an object 𝐸 and arrows 𝐶 → 𝐸 and 𝐷 → 𝐸 , andfurthermore, • any two parallel arrows 𝐶 ⇒ 𝐷 are coequalised by some morphism 𝐷 → 𝐸 .A filtered colimit is a colimit of some functor from some small filtered category. Definition 2.1.
An object of a category is finitely presentable iff its covariant hom-functor preserves filtered colimits.
Definition 2.2. [2, Definition 1.9] A locally small category is locally finitely presentable iff it is cocomplete and every object is a filtered colimit of objects from a fixed set of finitelypresentable generators.
Example 2.3 ([2, Example 1.12]) . Any presheaf category is locally finitely presentable.In this context, functors that preserve filtered colimits are important. They are called finitary . Definition 2.4.
Let [ C , D ] 𝑓 denote the category of finitary functors C → D for anycategories C and D . Proposition 2.5. If C and D are locally finitely presentable, then so is [ C , D ] 𝑓 .Proof. Since locally finitely presentable categories are in particular 𝜔 -accessible, by [2, Theo-rem 2.26], [ C , D ] 𝑓 is equivalent to [ C 𝑓 , D ] , where C 𝑓 is the full subcategory of C consistingof finitely presentable objects. Since C 𝑓 is essentially small, by [2, Corollary 1.54], [ C , D ] 𝑓 is locally finitely presentable.2.3. Convenient monoidal categories.
We sometimes work in a monoidal category sat-isfying some additional properties. We call such monoidal categories convenient.
Definition 2.6.
A monoidal category is convenient when • it is locally finitely presentable; • the tensor preserves filtered colimits on the right and all colimits on the left. Example 2.7.
Any category of finitary endofunctors on a locally finitely presentable cate-gory is convenient for the composition monoidal structure. Indeed, by Proposition 2.5, it islocally finitely presentable. Furthermore, since colimits are computed pointwise in functorcategories, ( colim 𝑖 𝐺 𝑖 ) ◦ 𝐹 (cid:27) colim 𝑖 ( 𝐺 𝑖 ◦ 𝐹 ) for all diagrams 𝐺 and objects 𝐹 , thus the com-position tensor product preserves all limits and colimits on the left. Finally, because the ODULES OVER MONADS AND OPERATIONAL SEMANTICS 7 considered functors are finitary, they preserve filtered colimits, hence for all such diagrams 𝐺 and objects 𝐹 we have 𝐹 ◦ colim 𝑖 𝐺 𝑖 (cid:27) colim 𝑖 ( 𝐹 ◦ 𝐺 𝑖 ) as desired. Example 2.8.
In particular, all categories of the form [ Set P , Set P ] 𝑓 that we will considerbelow (where P is a set) are convenient for the composition monoidal structure.2.4. (Parametric) modules over monoids and monads. Let us fix a monoidal category C . We first recall the standard notion of (right) module over a monoid, and introduce thenotion of parametric module, inspired by [35]. Definition 2.9.
Given a monoid 𝑋 ∈ C , a (right) 𝑋 -module is an object 𝑀 equipped witha morphism 𝑀 ⊗ 𝑋 → 𝑀 satisfying natural coherence conditions (the axioms for the dualcase of left modules are given in [48, § 𝑋 - Mod the category of thesealgebras.
Remark 2.10.
The coherence conditions amount to equipping 𝑀 with algebra structurefor the monad − ⊗ 𝑋 induced by 𝑋 .A parametric module assigns a module to any monoid. In order to formally define this,let us introduce the following category, which collects all categories of the form 𝑋 - Mod . Definition 2.11.
Let
Mod ( C ) denote the category • whose objects consist of a monoid 𝑋 equipped with an 𝑋 -module 𝑀 , and • whose morphisms ( 𝑋, 𝑀 ) → (
𝑌 , 𝑁 ) are pairs ( 𝑓 , 𝑔 ) of a monoid morphism 𝑓 : 𝑋 → 𝑌 anda morphism 𝑔 : 𝑀 → 𝑁 in C such that the following diagram commutes. 𝑀 ⊗ 𝑋 𝑁 ⊗ 𝑌𝑋 𝑌 𝑔 ⊗ 𝑓𝑔 Let U Mod : Mod ( C ) → Mon ( C ) denote the forgetful functor. Definition 2.12. A parametric module over C is a section of the forgetful functor U Mod : Mod ( C ) → Mon ( C ) , i.e., a functor 𝑆 : Mon ( C ) → Mod ( C ) such that U Mod ◦ 𝑆 = id Mon ( C ) .Since finitary monads on a category E are the same as monoids in C = [ E , E ] 𝑓 (forthe composition monoidal structure), the previous considerations apply. However, becausein this case C is a functor category, there is a slightly more general, “relative” notion ofmodule [35] which will be important for us. Let us recall it now. Definition 2.13.
Let
Mnd 𝑓 ( C ) denote the category of finitary monads on C . When C isclear from context, we sometimes abbreviate this to just Mnd 𝑓 . Definition 2.14.
Given a monad 𝑇 on C , a D -valued 𝑇 -module is a finitary functor 𝑀 : C → D equipped with a right 𝑇 -action 𝑀 ◦ 𝑇 → 𝑀 satisfying coherence conditionsanalogous to those of Definition 2.9. A morphism of 𝑇 -modules is similarly a natural trans-formation commuting with action. We denote by 𝑇 - Mod 𝑓 ( D ) the category of 𝑇 -modulesand morphisms between them.Let us briefly show how to exploit the variability of D . A. HIRSCHOWITZ, T. HIRSCHOWITZ, AND A. LAFONT
Definition 2.15.
For any sequence 𝑝 , . . . , 𝑝 𝑛 in a set P , for any monad 𝑇 on Set P and D -valued 𝑇 -module 𝑀 , we denote by 𝑀 ( 𝑝 ,..., 𝑝 𝑛 ) the D -valued 𝑇 -module defined by 𝑀 ( 𝑝 ,..., 𝑝 𝑛 ) ( 𝑋 ) = 𝑀 ( 𝑋 + y 𝑝 + . . . + y 𝑝 𝑛 ) ,where y : P → Set P is the embedding defined by y 𝑝 ( 𝑞 ) = 𝑝 = 𝑞 and ∅ otherwise. If P isa singleton, we abbreviate this to 𝑀 ( 𝑛 ) .As in the case of a general monoidal category, there is a notion of parametric module,spelled out in § Creation of (co)limits and monadic functors.
In this section, we recall Beck’smonadicity theorem [43, Theorem VI.7.1], and state a cancellation property for monadicfunctors. First, we need to recall creation of (co)limits, monadic functors, and absolute(co)limits.
Definition 2.16.
A functor 𝐹 : C → D creates (co)limits of shape E iff for all functors 𝐽 : E → C , if 𝐹 𝐽 has a (co)limit 𝐷 ∈ D , then the (co)limiting (co)cone uniquely lifts to C ,and the lifting is again (co)limiting.The typical example is: Proposition 2.17. [43, Exercise VI.2.2]
For any monad 𝑇 on a category C , the forgetfulfunctor 𝑈 : 𝑇 -alg → C creates limits.Proof. Given a limiting cone ( 𝐶 → 𝑈𝐽 ( 𝐸 )) 𝐸 ∈ E , the composites 𝑇 ( 𝐶 ) → 𝑇 ( 𝑈 ( 𝐽 ( 𝐸 ))) → 𝑈 ( 𝐽 ( 𝐸 )) given by the 𝑇 -algebra structure of each 𝐽 ( 𝐸 ) form a cone over 𝑈𝐽 , whose mediatingarrow 𝑇 ( 𝐶 ) → 𝐶 provides the desired compatible 𝑇 -algebra structure on 𝐶 .We also have the following well-known result: Proposition 2.18.
For any monad 𝑇 on a category C , the forgetful functor 𝑈 : 𝑇 -alg → C creates all colimits that 𝑇 preserves.Proof. This is a straightforward consequence of [17, Proposition 4.3.2].
Definition 2.19.
A functor 𝑈 : E → B is monadic iff it is isomorphic (in the slice category CAT / B ) to the category of algebras for some monad. Remark 2.20.
This notion of monadicity is quite strict. Some authors prefer a relaxedversion where isomorphism is replaced with equivalence.
Definition 2.21.
A (co)limit is absolute iff it is preserved by all functors.
Theorem 2.22 (Beck’s monadicity theorem) . A functor 𝑈 : E → B is monadic iff • it has a left adjoint, and • it creates coequalisers for those parallel pairs 𝑓 , 𝑔 : 𝐸 ⇒ 𝐸 for which ( 𝑈 ( 𝑓 ) , 𝑈 ( 𝑔 )) hasan absolute coequaliser in B . We will use the following consequence.
Proposition 2.23.
Given a commuting triangle of functors
ODULES OVER MONADS AND OPERATIONAL SEMANTICS 9
A BC
𝐻𝐹 𝐺 between cocomplete categories, if 𝐹 and 𝐺 are monadic, then so is 𝐻 .Furthermore, if 𝐹 and 𝐺 are finitary, then so is 𝐻 .Proof. For monadicity, Borceux [17, Corollary 4.5.7] gives a proof in the weakly monadiccase (see Remark 2.20). This is a straightforward adaptation. Finitariness follows from thenext lemma.
Lemma 2.24.
Given a commuting triangle of functors as in Proposition 2.23, if 𝐹 isfinitary and 𝐺 creates filtered colimits, then 𝐻 is finitary.Proof. In this situation, 𝐹 and 𝐺 in fact create filtered colimits. So given a colimiting cocone 𝑐 : 𝐽 → 𝐴 for a filtered diagram 𝐽 : D → A , this cocone is preserved by 𝐹 and created by 𝐺 . So 𝐹 ( 𝑐 ) is colimiting, and has a unique antecedent by 𝐺 , which is again colimiting. But 𝐻 ( 𝑐 ) is an antecedent, hence has to be the antecedent, and so is colimiting as desired.2.6. Equalisers of finitary monadic functors.
In this section, we recall some folkloreresults about finitary monadic functors, mainly that they are they are equivalent to finitarymonads, and that equalisers are computed as in
CAT . Definition 2.25.
For any locally finitely presentable category C , let Monadic 𝑓 / C de-note the full subcategory of CAT / C spanning (strictly) monadic functors whose underlyingmonad is finitary.Let us readily make the following observation. Lemma 2.26.
The functor underlying any morphism in
Monadic 𝑓 / C is itself monadic.Proof. By Proposition 2.23.In fact, a lot of our understanding of
Monadic 𝑓 / C will follow from the following equiv-alence. Proposition 2.27 (Street’s correspondence) . The functor (−) -alg :
Mnd 𝑓 ( C ) op → Monadic 𝑓 / C mapping any finitary monad 𝑇 to the forgetful functor 𝑇 -alg → C is an equivalence.Proof. In [50, Theorem 6], Street constructs a full embedding of
Mnd 𝑓 ( C ) op into a suitablecategory, and shows that its essential image is precisely Monadic 𝑓 / C . Notation 2.28.
We denote by 𝑈 ↦→ ˇ 𝑈 the (or, rather, some chosen) inverse equivalence. In particular, we have the following well-known fact.
Lemma 2.29.
Finitary monads over any locally finitely presentable category form a locallyfinitely presentable category.
Proof sketch (see [40] ). Let C be locally presentable. Then C 𝑓 is small, so [ C 𝑓 , C ] is againlocally presentable. Now, finitary monads on C are equivalently monoids for the compositiontensor product in [ C 𝑓 , C ] , hence also algebras for a finitary monad on a locally presentablecategory, which allows us to conclude by the following lemma. Lemma 2.30.
The category of algebras for a finitary monad on any locally finitely pre-sentable category is again locally finitely presentable.Proof.
This is [2, Remark 2.78] with 𝜆 = 𝜔 .Now a useful tool to prove that registers are monadic is the following result and itscorollary, coming up just next. Proposition 2.31.
The forgetful functor
Monadic 𝑓 / C → CAT / C creates limits.Proof. By Lemma 2.29 and Proposition 2.27,
Monadic 𝑓 / C is complete and is equivalentto the opposite category of finitary monads on C . Through this equivalence, a limit in Monadic 𝑓 / C corresponds to a colimit of finitary monads. By [14, Proposition 5.6], such acolimit is computed in the category of (possibly non-finitary) monads on C . Finally, by [38,Proposition 26.3], its category of algebras is the limit computed in CAT / C of the involvedmonadic functors. Corollary 2.32.
The forgetful functor
Monadic 𝑓 / C → CAT creates equalisers. More pre-cisely, if 𝐹 : D → C and 𝐹 : D → C are two monadic functors and 𝐺 , 𝐺 : D → D are two functors such that 𝐹 ◦ 𝐺 𝑖 = 𝐹 , then the equaliser of 𝐺 and 𝐺 in CAT is finitarymonadic and underlies the equaliser of 𝐺 and 𝐺 in Monadic 𝑓 / C .Proof. This follows straightforwardly from Proposition 2.31 and the fact that the forgetfulfunctor from any slice category to the base category creates equalisers (and more generallyall connected limits). 3.
Transition monads
In this section, we introduce the main new mathematical notion of the paper: transitionmonads. In § § § § Overview of transition monads.Placetakers and states
In standard 𝜆 -calculus, we have terms, variables are placeholders for terms, and tran-sitions relate a source term to a target term. In a general transition monad we still havevariables and transitions, but placetakers for variables and endpoints of transitions can beof a different nature, which we phrase as follows: variables are placeholders for placetakers ,while transitions relate a source state with a target state . The categories for placetakers and for states
In standard 𝜆 -calculi, we have a set T of types for terms (and variables); for instancein the untyped version, T is a singleton. Accordingly, terms form a monad on the category Set T . In a general transition monad we have a set P of placetaker types, and placetakers ODULES OVER MONADS AND OPERATIONAL SEMANTICS 11 form a monad on the category
Set P ; similarly, we have a set S of transition types, andthe category of states is Set S . For example, for simply-typed 𝜆 -calculus, P = S is the set ofsimple types. The object of variables
In our view of the untyped 𝜆 -calculus, there is a (variable!) set of variables and ev-erything is parametric in this ‘variable set’. Similarly, in a general transition monad 𝑅 ,there is a ‘variable object’ 𝑉 in Set P and everything is functorial in this variable object.In particular, we have a placetaker object 𝑇 𝑅 ( 𝑉 ) in Set P and a source (resp. target) stateobject in Set S , both depending upon the variable object. The state functors 𝑆 and 𝑆 While in the 𝜆 -calculus, states are the same as placetakers, in a general transition monad,they may differ, and more precisely both state objects are derived from the placetaker objectby applying the state functors 𝑆 , 𝑆 : Set P → Set S . The transition structure
In standard 𝜆 -calculi, there is a (typed!) set of transitions, which yields a graph on theset of terms. That is to say, if 𝑉 is the variable object, and 𝐿𝐶 ( 𝑉 ) the placetaker object, thereis a transition object Trans ( 𝑉 ) equipped with two maps src 𝑉 , tgt 𝑉 : Trans ( 𝑉 ) → 𝐿𝐶 ( 𝑉 ) .Note that we consider ‘proof-relevant’ transitions here, in the sense that two different tran-sitions may have the same source and target (see 3.4 for the irrelevant variant).In a general transition monad 𝑅 , we still have a transition object Trans 𝑅 ( 𝑉 ) , whichnow lives in Set S , together with state objects 𝑆 ( 𝑇 𝑅 ( 𝑉 )) and 𝑆 ( 𝑇 𝑅 ( 𝑉 )) , so that src 𝑉 and 𝑡𝑟𝑔 𝑉 form a span 𝑆 ( 𝑇 𝑅 ( 𝑉 )) ← Trans 𝑅 ( 𝑉 ) → 𝑆 ( 𝑇 𝑅 ( 𝑉 )) or equivalently a morphism Trans 𝑅 ( 𝑉 ) → 𝑆 ( 𝑇 𝑅 ( 𝑉 )) × 𝑆 ( 𝑇 𝑅 ( 𝑉 )) .3.2. The definition of transition monad.
Here is our formal definition:
Definition 3.1.
Given two sets P and S , a transition monad over ( P , S ) consists of • a finitary monad 𝑇 on Set P , called the placetaker monad, • two finitary functors 𝑆 , 𝑆 : Set P → Set S , called state functors, and • a transition structure 𝑅 ( src , tgt ) −−−−−−−→ 𝑆 𝑇 × 𝑆 𝑇 consisting of – a finitary 𝑇 -module 𝑅 : Set P → Set S , called the transition module, – a source 𝑇 -module morphism src : 𝑅 → 𝑆 𝑇 , and – a target 𝑇 -module morphism tgt : 𝑅 → 𝑆 𝑇 . Notation 3.2.
For any sets P and S , finitary monad 𝑇 over Set P , and finitary functors 𝑆 , 𝑆 : Set P → Set S , we let TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) denote the class of transition monads withstate functors 𝑆 and 𝑆 and TrMnd P , S denote the coproduct Í 𝑇 ,𝑆 ,𝑆 TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) . In § Transition monads as relative monads.
In our definition of transition monad, wehave required the two state modules to take the form 𝑆 𝑇 and 𝑆 𝑇 , but this is not essentialin our development. Moreover, it probably leaves some relevant examples out of reach. Wethink in particular about the standard presentation of the 𝜋 -calculus as a labelled transitionsystem. Our original reason for this design choice was purely aesthetic: it ensures that ourtransition monads are relative monads, as were the reduction monads introduced in [7] (in particular the untyped 𝜆 -calculus). These were monads relative to the ‘discrete graph’functor from sets to graphs, and in our extended context, we have to replace graphs by 𝑆 -graphs . Let us provide more detail.Let us first recall [8] that, given any functor 𝐽 : C → D , a monad relative to 𝐽 , or 𝐽 -relative monad , consists of • an object mapping 𝑇 : ob ( C ) → ob ( D ) , together with • morphisms 𝜂 𝑋 : 𝐽 ( 𝑋 ) → 𝑇 ( 𝑋 ) , and • for each morphism 𝑓 : 𝐽 ( 𝑋 ) → 𝑇 ( 𝑌 ) , an extension 𝑓 ★ : 𝑇 ( 𝑋 ) → 𝑇 ( 𝑌 ) ,satisfying coherence conditions. Any 𝐽 -relative monad 𝑇 has an underlying functor C → D ,and is said finitary when this functor is.Now we define 𝑆 -graphs: Definition 3.3.
For any pair 𝑆 = ( 𝑆 , 𝑆 ) of functors Set P → Set S , an 𝑆 -graph over anobject 𝑉 ∈ Set P consists of • an object 𝐸 (of edges ) in Set S , and • a span 𝑆 ( 𝑉 ) ← 𝐸 → 𝑆 ( 𝑉 ) , which we alternatively view as a morphism 𝜕 : 𝐸 → 𝑆 ( 𝑉 ) × 𝑆 ( 𝑉 ) .Accordingly, an 𝑆 -graph consists of an object 𝑉 ∈ Set P and an 𝑆 -graph over 𝑉 .We can now say that in a general transition monad, transitions form an 𝑆 -graph overthe placetaker object (the whole thing depending upon the variable object...). Before pro-ceeding, we must introduce the category of 𝑆 -graphs: a morphism 𝐺 → 𝐺 ′ consists of amorphism for vertices 𝑓 : 𝑉 𝐺 → 𝑉 𝐺 ′ together with a morphism for edges 𝑔 : 𝐸 𝐺 → 𝐸 𝐺 ′ making the following diagram commute. 𝐸 𝐺 𝐸 𝐺 ′ 𝑆 ( 𝑉 𝐺 ) × 𝑆 ( 𝑉 𝐺 ) 𝑆 ( 𝑉 𝐺 ′ ) × 𝑆 ( 𝑉 𝐺 ′ ) 𝑔𝜕 𝐺 𝑆 ( 𝑓 )× 𝑆 ( 𝑓 ) 𝜕 𝐺 ′ Proposition 3.4.
For any pair 𝑆 = ( 𝑆 , 𝑆 ) of functors Set P → Set S , 𝑆 -graphs form acategory 𝑆 - Gph . The proof is a straightforward verification.We will consider monads relative to the following functors:
Definition 3.5.
For any pair 𝑆 = ( 𝑆 , 𝑆 ) of functors Set P → Set S , the discrete 𝑆 -graph functor 𝐽 𝑆 : Set P → 𝑆 - Gph maps any 𝑉 ∈ Set P to the 𝑆 -graph on 𝑉 with no edges.Now we are ready to deliver our characterisation of transition monads as relative mon-ads: Proposition 3.6.
Given functors 𝑆 , 𝑆 : Set P → Set S , transition monads with state func-tors 𝑆 and 𝑆 are exactly monads relative to the discrete 𝑆 -graph functor for 𝑆 = ( 𝑆 , 𝑆 ) . The proof consists merely in unfolding the definitions. Since we do not use this result,we do not give further details.
ODULES OVER MONADS AND OPERATIONAL SEMANTICS 13
The proof-irrelevant variant.
Although we have chosen a “proof-relevant” notionof transition monad, we can sketch a presentation of a “proof-irrelevant” variant.
Definition 3.7.
We denote by
ITrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) the subset of TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) con-sisting of transition monads h src , tgt i : 𝑅 → 𝑆 𝑇 × 𝑆 𝑇 such that h src , tgt i is a pointwiseinclusion.We have a natural retraction of TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) on ITrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) whichmaps a transition monad 𝜕 : 𝑅 → 𝑆 𝑇 × 𝑆 𝑇 to the monomorphism 𝑅 ↩ → 𝑆 𝑇 × 𝑆 𝑇 obtainedfrom the (strong epi)-mono factorisation; this factorisation exists [2, Proposition 1.61] sincethe category of finitary Set -valued 𝑇 -modules is a presheaf category [4, Definition 2.71]. InProposition 9.3, we will upgrade this retraction into a coreflection of categories.4. Examples of transition monads
In this section, we present very informally the announced examples of transition monads.This presentation should eventually be compared to the one via signatures given in § The call-by-value, simply-typed, big-step 𝝀 -calculus. The notion of transitionmonad accounts for many different variants of the 𝜆 -calculus. Let us detail the case of thesimply-typed, call-by-value, big-step 𝜆 -calculus. Most often, big-step semantics describesevaluation of closed terms. Here we consider a variant describing the evaluation of openterms [44, 42]. In this setting, the main subtlety lies in the fact that variables are onlyplaceholders for values.We fix some set of base types, ranged over by 𝜄 and define successively types, valuesand terms, typing contexts, well-typed terms, and transitions as follows. Definition 4.1.
The set P of types , ranged over by 𝐴 , 𝐵 , is defined inductively by 𝐴, 𝐵 F 𝜄 | 𝐴 → 𝐵 . Definition 4.2.
For any set, say 𝑋 , of variables , we then define values , ranged over by 𝑣 , 𝑤 , and general terms , ranged over by 𝑒 , 𝑓 in a mutually inductive way as follows. 𝑣, 𝑤 F 𝑥 | 𝜆𝑥.𝑒𝑒, 𝑓 F 𝑣 | 𝑒 𝑓 Terms are considered equivalent modulo 𝛼 -conversion, and capture-avoiding substitution isdefined as usual. Definition 4.3. A typing context is a type-indexed family of sets, i.e., an object of Set P .For all Γ ∈ Set P , 𝐴 ∈ P , and 𝑥 ∉ Γ 𝐴 , we let Γ , 𝑥 : 𝐴 denote Γ augmented with 𝑥 over 𝐴 (which is isomorphic to Γ + y 𝐴 ). Definition 4.4. Well-typed terms are inductively defined by the following rules. Γ ⊢ 𝑥 : 𝐴 ( 𝑥 ∈ Γ 𝐴 ) Γ , 𝑥 : 𝐴 ⊢ 𝑒 : 𝐵 Γ ⊢ 𝜆𝑥.𝑒 : 𝐴 → 𝐵 Γ ⊢ 𝑒 : 𝐴 → 𝐵 Γ ⊢ 𝑓 : 𝐴 Γ ⊢ 𝑒 𝑓 : 𝐵 Definition 4.5. Transitions are inductively defined by the following rules. 𝑣 ⇓ 𝑣 𝑒 ⇓ 𝜆𝑥.𝑒 𝑒 ⇓ 𝑤 𝑒 [ 𝑥 ↦→ 𝑤 ] ⇓ 𝑣𝑒 𝑒 ⇓ 𝑣 This calculus forms a transition monad as follows.
Placetakers and transition types
As foreshadowed by the notation, because variablesand values are indexed by (simple) types, we take P = S to be the set of types. Placetaker monad
The placetaker monad 𝑇 over Set P is given by well-typed values: givenany Γ ∈ Set P , the placetaker object 𝑇 ( Γ ) ∈ Set P assigns to each type 𝐴 the set 𝑇 ( Γ ) 𝐴 ofvalues 𝑣 such that Γ ⊢ 𝑣 : 𝐴 holds. State functors
In big-step semantics, transitions relate terms to values. Hence, we areseeking state functors 𝑆 , 𝑆 : Set P → Set P such that 𝑆 ( 𝑇 ( Γ )) 𝐴 is the set of 𝜆 -terms oftype 𝐴 with free variables in Γ , and 𝑆 ( 𝑇 ( Γ )) 𝐴 is the subset of values therein. For 𝑆 ,we should clearly take the identity functor since 𝑇 consists of all values. For 𝑆 , we firstobserve that 𝜆 -terms can be described as application binary trees whose leaves are values(internal nodes being typed applications). More formally, let 𝑆 ( Γ ) 𝐴 denotes the set of terms Γ ⊢ 𝑆 𝑏 : 𝐴 , as inductively defined by the following rules. 𝑥 ∈ Γ 𝐴 Γ ⊢ 𝑆 𝑥 : 𝐴 Γ ⊢ 𝑆 𝑏 : 𝐴 → 𝐵 Γ ⊢ 𝑆 𝑏 ′ : 𝐴 Γ ⊢ 𝑆 𝑏 𝑏 ′ : 𝐵 · If Γ is a typing context, 𝑆 ( 𝑇 ( Γ )) is indeed the set of well-typed general terms with variablesin Γ . Transition module
Finally, the transition module maps any Γ ∈ Set P to the family, overall 𝐴 ∈ P , of transition proofs of some 𝑒 ⇓ 𝑣 with 𝑒 ∈ 𝑆 ( 𝑇 ( Γ )) 𝐴 and 𝑣 ∈ 𝑇 ( Γ ) 𝐴 . Suchtransition proofs are stable under value substitution, so we obtain a transition monad.4.2. The ¯ 𝝀𝝁 -calculus. The 𝜆𝜇 -calculus, introduced by Herbelin [32], models the computa-tional contents of cut elimination in the sequent calculus. Following Vaux’s presentation [52, § 𝑐 F h 𝑒 | 𝜋 i Programs 𝑒 F 𝑥 | 𝜇𝛼.𝑐 | 𝜆𝑥.𝑒 Stacks 𝜋 F 𝛼 | 𝑒 · 𝜋, where 𝑥 and 𝛼 range over two disjoint sets of variables, called stack and program variables,respectively. Both constructions 𝜇 and 𝜆 bind their variable in the body. Reduction isgenerated by the following two basic transition rules concerning commands: h 𝜇𝛼.𝑐 | 𝜋 i → 𝑐 [ 𝛼 ↦→ 𝜋 ] h 𝜆𝑥.𝑒 | 𝑒 ′ · 𝜋 i → h 𝑒 [ 𝑥 ↦→ 𝑒 ′ ] | 𝜋 i . Since reduction may occur “everywhere”, it concerns programs and stacks as well.Let us show how this gives rise to a transition monad.
Placetaker types
In the transition rules above, we see that placetakers may be programsor stacks. So, we take two placetaker types, hence P = = { p , s } . A variable object isan element of Set P , that is, a pair of sets: the first one gives the available free programvariables, and the second one the available free stack variables. Placetaker monad
The syntax may be viewed as a monad 𝑇 : Set P → Set P : given avariable object 𝑋 = ( 𝑋 p , 𝑋 s ) ∈ Set P , the placetaker object ( 𝑇 ( 𝑋 ) p , 𝑇 ( 𝑋 ) s ) ∈ Set P consists ofthe sets of program and stack terms with free variables in 𝑋 , up to bound variable renaming.As usual, monad multiplication is given by capture-avoiding substitution. The 𝑇 -modules for programs, stacks and commands We have three important
Set -valued 𝑇 -modules: the first two, Prg for programs and
Stk for stacks, are the two components
ODULES OVER MONADS AND OPERATIONAL SEMANTICS 15 of 𝑇 . The third one, for commands, is just the cartesian product of the previous two: Cmd : = Prg × Stk . Transition types and state functors
As mentioned above, transitions concern programsand stacks as well as commands. Thus, we take three transition types: S = = { c , p , s } .Furthermore, commands are pairs of a program and a stack, so that, setting 𝑆 ( 𝐴 ) = 𝑆 ( 𝐴 ) = ( 𝐴 p × 𝐴 s , 𝐴 p , 𝐴 s ) , we get 𝑆 𝑖 ( 𝑇 ( 𝑋 )) = ( 𝑇 ( 𝑋 ) p × 𝑇 ( 𝑋 ) s , 𝑇 ( 𝑋 ) p , 𝑇 ( 𝑋 ) s ) for 𝑖 = ,
2, as desired.
Transition module
Finally, transitions with free variables in 𝑋 form a triple of graphswith vertices respectively in 𝑇 ( 𝑋 ) p × 𝑇 ( 𝑋 ) s (the set of commands taking free variables in 𝑋 ), 𝑇 ( 𝑋 ) p , and 𝑇 ( 𝑋 ) s . This family is natural in 𝑋 and commutes with substitution, henceforms a 𝑇 -module morphism, which completes our transition monad.4.3. The 𝝅 -calculus. For an example involving equations on placetakers, let us recall thefollowing standard presentation of (a simple variant of) the 𝜋 -calculus [47]. The syntax for processes is given by 𝑃, 𝑄 : : = | ( 𝑃 | 𝑄 ) | 𝜈𝑎.𝑃 | ¯ 𝑎 h 𝑏 i .𝑃 | 𝑎 ( 𝑏 ) .𝑃 ,where 𝑎 and 𝑏 range over channel names , and 𝑏 is bound in 𝜈𝑏.𝑃 and 𝑎 ( 𝑏 ) .𝑃 . Processesare identified when related by the smallest context-closed equivalence relation ≡ satisfying0 | 𝑃 ≡ 𝑃 𝑃 | 𝑄 ≡ 𝑄 | 𝑃 𝑃 | ( 𝑄 | 𝑅 ) ≡ ( 𝑃 | 𝑄 ) | 𝑅 ( 𝜈𝑎.𝑃 ) | 𝑄 ≡ 𝜈𝑎. ( 𝑃 | 𝑄 ) ,where in the last equation 𝑎 should not occur free in 𝑄 . Transitions are then given by thefollowing rules.¯ 𝑎 h 𝑏 i .𝑃 | 𝑎 ( 𝑐 ) .𝑄 −→ 𝑃 | ( 𝑄 [ 𝑐 ↦→ 𝑏 ]) 𝑃 −→ 𝑄𝑃 | 𝑅 −→ 𝑄 | 𝑅 𝑃 −→ 𝑄𝜈𝑎.𝑃 −→ 𝜈𝑎.𝑄 The 𝜋 -calculus gives rise to a transition monad as follows. Placetaker types
We consider two placetaker types, one for channels and one for processes.Hence, P = = { c , p } . Placetaker monad
Then, the syntax may be viewed as a monad 𝑇 : Set P → Set P : givena variable object 𝑋 = ( 𝑋 c , 𝑋 p ) ∈ Set P , the placetaker object 𝑇 ( 𝑋 ) = ( 𝑋 c , 𝑇 ( 𝑋 ) p ) ∈ Set P consists of the sets of channels and processes with free variables in 𝑋 (modulo ≡ ). Notethat 𝑇 ( 𝑋 ) c = 𝑋 c as there is no operation on channels. Transition type and state functors
Transitions relate processes, so we take S = 𝑆 ( 𝑋 ) = 𝑆 ( 𝑋 ) = 𝑋 p . Transition module
Transitions are stable under substitution, hence form a transitionmonad.Let us now describe a second way of organising the 𝜋 -calculus as a transition monad,this time over a single placetaker type. Placetaker
This time we set P = Placetaker monad
Since all that needs substitution in the 𝜋 -calculus is channels, andthe syntax contains no channel constructor, the placetaker monad is merely the identitymonad. Transition types and state functors
However, since transitions relate processes, weneed to fit the syntax into the state functors. We thus take S = 𝑆 ( 𝑋 ) = 𝑆 ( 𝑋 ) to bethe set of processes with free channels in 𝑋 . Transition module
Transitions are stable under channel renaming, hence again form atransition monad.
Remark 4.6.
This would not work in the presence of the mismatch operator [47, p13],which breaks stability of reduction under renaming.4.4.
Positive GSOS systems.
An example involving labelled transitions (and 𝑆 ≠ 𝑆 )is given by Positive GSOS systems [15, p246]. They specify labelled transition systems, inwhich transitions have the shape 𝑒 𝑎 −→ 𝑓 , where 𝑎 is drawn from some fixed set A of labels .Let us further fix a set 𝑂 of operations with arities in N and an infinite set of variables ,ranged over by 𝑥 , 𝑦 ,... Definition 4.7. A Positive GSOS rule has the shape . . . 𝑥 𝑖 𝑎 𝑖, 𝑗 −−−→ 𝑦 𝑖, 𝑗 . . . ( 𝑖 ∈ 𝑛, 𝑗 ∈ 𝑛 𝑖 ) 𝑜 𝑝 ( 𝑥 , . . . , 𝑥 𝑛 ) 𝑐 −→ 𝑒 , (4.1)where • 𝑜 𝑝 ∈ 𝑂 is an operation with arity 𝑛 , • for all 𝑖 ∈ 𝑛 , 𝑛 𝑖 is a natural number, • the variables 𝑥 𝑖 and 𝑦 𝑖, 𝑗 are all distinct, and • 𝑒 is an expression potentially depending on all the variables.A Positive GSOS system is a set of Positive GSOS rules.The semantics of a Positive GSOS rule is that of a “rule scheme”, in the following sense.
Definition 4.8.
The labelled transition relation generated by a Positive GSOS system isthe smallest A -labelled transition system on expressions generated by 𝑂 , such that for allrules (4.1), and expressions 𝑒 , . . . , 𝑒 𝑛 and 𝑒 𝑖, , . . . , 𝑒 𝑖,𝑛 𝑖 for all 𝑖 ∈ 𝑛 , if 𝑒 𝑖 𝑎 𝑖, 𝑗 −−−→ 𝑒 𝑖, 𝑗 for all 𝑖 ∈ 𝑛 and 𝑗 ∈ 𝑛 𝑖 , then 𝑜 𝑝 ( 𝑒 , . . . , 𝑒 𝑛 ) 𝑐 −→ 𝑒 [ 𝑥 𝑖 ↦→ 𝑒 𝑖 , . . . , 𝑥 𝑖, 𝑗 ↦→ 𝑒 𝑖, 𝑗 , . . . ] . Otherwise said, each rule scheme (4.1) induces a rule . . . 𝑒 𝑖 𝑎 𝑖, 𝑗 −−−→ 𝑒 𝑖, 𝑗 . . . ( 𝑖 ∈ 𝑛, 𝑗 ∈ 𝑛 𝑖 ) 𝑜 𝑝 ( 𝑒 , . . . , 𝑒 𝑛 ) 𝑐 −→ 𝑒 [ . . . , 𝑥 𝑖 ↦→ 𝑒 𝑖 , . . . , 𝑥 𝑖, 𝑗 ↦→ 𝑒 𝑖, 𝑗 , . . . ] · Remark 4.9.
The general notion of GSOS system includes negative rules, which meansrules that may have premises of the shape 𝑥 𝑖 𝑎 . Their semantics is significantly moreinvolved, so we leave their integration as an open problem.Each Positive GSOS system yields a transition monad as follows. Placetaker and transition types
We take P =
1, because we are in an untyped setting,and S = ODULES OVER MONADS AND OPERATIONAL SEMANTICS 17
Placetaker monad
The selected family of operations (or rather arities) specifies the termmonad 𝑇 . State functors
In order to take labels into account, we take 𝑆 ( 𝑋 ) = 𝑋 and 𝑆 ( 𝑋 ) = A × 𝑋 .Transitions thus form a set over 𝑋 × ( A × 𝑋 ) as desired. Remark 4.10.
We could as well take 𝑆 ( 𝑋 ) = A × 𝑋 and 𝑆 ( 𝑋 ) = 𝑋 , as in the end, onlythe product 𝑆 ( 𝑋 ) × 𝑆 ( 𝑋 ) matters. Transition structure
As before, we take as transitions the set of all proofs generated bythe rules, which is indeed stable under substitution by construction.4.5.
The differential 𝝀 -calculus. Let us finally sketch how the differential 𝜆 -calculus [20]provides a further example with 𝑆 ≠ 𝑆 . Following Vaux [52, § 𝑒, 𝑓 , 𝑔 F 𝑥 | 𝜆𝑥.𝑒 | 𝑒 h 𝑈 i | 𝐷𝑒 · 𝑓 (terms) 𝑈, 𝑉 F | 𝑒 + 𝑈 (multiterms),where terms and multiterms are considered equivalent up to the following equations. 𝑒 + 𝑒 ′ + 𝑈 = 𝑒 ′ + 𝑒 + 𝑈 𝐷 ( 𝐷𝑒 · 𝑓 ) · 𝑔 = 𝐷 ( 𝐷𝑒 · 𝑔 ) · 𝑓 . The definition of transitions is based on two auxiliary constructions:(1)
Unary multiterm substitution 𝑒 [ 𝑥 ↦→ 𝑈 ] of a multiterm 𝑈 for a variable 𝑥 in a term 𝑒 , which returns a multiterm (not to be confused with unary monadic substitution,which handles the particular case where 𝑈 is a mere singleton).(2) Partial derivative 𝜕𝑒𝜕𝑥 · 𝑈 of a term 𝑒 w.r.t. a term variable 𝑥 along a multiterm 𝑈 .This again returns a multiterm.Both are defined by induction on 𝑒 (see [52, Definition 6.3 and 6.4]).We may now define the transition relation as the smallest context-closed relation satis-fying the rules below. ( 𝜆𝑥.𝑒 ) h 𝑈 i → 𝑒 [ 𝑥 ↦→ 𝑈 ] 𝐷 ( 𝜆𝑥.𝑒 ) · 𝑓 → 𝜆𝑥. (cid:18) 𝜕𝑒𝜕𝑥 · 𝑓 (cid:19) The compact formulation of the second rule relies on the abbreviation 𝜆𝑥. ( 𝑒 + . . . + 𝑒 𝑛 ) : = 𝜆𝑥.𝑒 + . . . + 𝜆𝑥.𝑒 𝑛 .Let us now sketch how this forms a transition monad. Placetaker monad
Terms induce a monad 𝑇 on Set , which we take as the placetakermonad (hence P = State functors
Transitions relate terms to multiterms, hence S = 𝑆 is the identity, and 𝑆 = ! is the functor mapping any set 𝑋 to the set of (finite) multisets over 𝑋 . Transition structure
Transitions are stable under substitution by terms, hence we againhave a transition monad. State of the art on signatures
In this section we revisit the standard theory of signatures.We start in § abstract signature over a category,and we call registers the families of such abstract signatures. In § monadic abstract signatures and registers. All the remaining subsectionspresent various monadic registers. We start in § EF C , whose signatures are finitary endofunctors. Furthermore, in § ES C of this register to deal with equations, whose signatures are Fioreand Hur’s equational systems [23]. Next, in § C , namely Fiore, Plotkin, andTuri’s pointed strong endofunctors [24], and recast them as the signatures of a register PSEF C for monoids in C . The final subsection § MES C for monoidal equational systems , extending the previous one with suitable equations.5.1. Abstract signatures and registers.Definition 5.1. An abstract signature 𝑆 over a given category C consists of • a category 𝑆 -alg of models of 𝑆 , or 𝑆 -algebras , • a forgetful functor U 𝑆 : 𝑆 -alg → C , and • a validity proof ensuring that 𝑆 -alg admits an initial object. Remark 5.2.
In other words, an abstract signature over C is just a functor from a categorywith an initial object to C . Terminology 5.3 .
Given an abstract signature 𝑆 over a category C , we say that 𝑆 isa signature for spec ( 𝑆 ) : = U 𝑆 ( ) , where here denotes the initial object in 𝑆 -alg , oralternatively that 𝑆 specifies spec ( 𝑆 ) . Notation 5.4.
When convenient, we introduce an abstract signature over C as 𝑢 : E → C ,to be understood as the abstract signature 𝑆 with 𝑆 -alg : = E and U 𝑆 : = 𝑢 . Here are some trivial examples.
Example 5.5.
Consider the standard endofunctor 𝐹 : Set → Set with 𝐹 ( 𝑋 ) = 𝑋 +
1. Wedefine an abstract signature over
Set for which the category of models is the category of 𝐹 -algebras, and the forgetful functor sends any 𝐹 -algebra to its carrier. In order to completethe definition of this example, we should prove that the category of 𝐹 -algebras has an initialobject. This is well-known and the carrier of the initial model is N . Example 5.6.
Any object 𝑐 of any given category C is specified by the following signatures: • the functor 1 → C mapping the only object of the final category (with one object andone morphism) to 𝑐 ; • the codomain functor 𝑐 / C → C from the coslice category. Definition 5.7.
We denote by UR C the (large) set of abstract signatures over the category C (here, UR stands for ‘universal register’, as later justified by Definition 5.10).We now introduce registers for a category C : they are (possibly large) families ofabstract signatures over C . Roughly speaking, each register allows to write down specificsignatures, gives the recipe for the corresponding abstract signature, hence yielding a notionof model together with the existence of an initial one. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 19
Definition 5.8. A register 𝑅 for a given category C consists of • a (potentially large) set Sig 𝑅 of signatures , and • a semantics map J − K 𝑅 : Sig 𝑅 → UR C . Notation 5.9.
Below, we “define” each of our registers by providing the base category C ,the set of “signatures”, and the semantics map from signatures to UR 𝐶 . Such a definitioninvolves a validity proof , showing the existence of an initial model, that we explicitly providewhen it is non-trivial. We can now motivate the notation UR C above, by first organising it into a register, andthen showing that all registers may be “compiled” into it, in a suitable sense. Definition 5.10.
For a given category C , the universal register UR C is defined as follows: • its signatures are abstract signatures for C , and • the map J − K UR C is the identity (on UR C ). Notation 5.11.
When convenient, we introduce a register as 𝑢 : 𝑆 → UR C , to be understoodas the register 𝑅 with Sig 𝑅 : = 𝑆 and J − K 𝑅 : = 𝑢 . Definition 5.12. A compilation from a register 𝑅 on a category C to a register 𝑅 on thesame category is a map 𝑐 : Sig 𝑅 → Sig 𝑅 preserving the semantics up to isomorphism, inthe sense that for any Σ ∈ Sig 𝑅 , there is an isomorphism J Σ K 𝑅 (cid:27) J 𝑐 ( Σ ) K 𝑅 commuting withthe forgetful functors to C . In this case, we say that 𝑅 is a subregister of 𝑅 . Definition 5.13.
For any register 𝑅 for C , set S , and map 𝑓 : S → Sig 𝑅 , precompositionwith 𝑓 induces a register 𝑓 ∗ ( 𝑅 ) for C , whose signatures are elements of S , and which is byconstruction a subregister of 𝑅 .Every subregister is obtained in this way up to isomorphism in the following sense. Definition 5.14.
Two registers are isomorphic when one compiles into the other, with abijective underlying map.
Proposition 5.15.
A register 𝑅 is a subregister of a register 𝑅 iff it is isomorphic to 𝑓 ∗ ( 𝑅 ) for some map 𝑓 : Sig 𝑅 → Sig 𝑅 . Proposition 5.16.
All registers for a category C admit a compilation into UR C . Otherwisesaid, every register is a subregister of UR C .Proof. Straightforward.Let us conclude this subsection with a notion that is more or less dual to compilation.Indeed, compilation relates registers through their signatures, while the following does sothrough their underlying categories.
Proposition 5.17.
The assignment C ↦→ UR C extends to a functor CAT → SET . Theaction of a functor 𝐹 : C → D , denoted by UR 𝐹 , is given by postcomposition. Definition 5.18.
For any register 𝑅 for C and functor 𝐹 : C → D , postcomposition withUR 𝐹 induces a register 𝐹 ! ( 𝑅 ) : = ( Sig 𝑅 , UR 𝐹 ◦ J − K 𝑅 ) for D . Monadic abstract signatures and registers.Definition 5.19.
An abstract signature is monadic if its forgetful functor is monadic andthe associated monad is finitary.
Remark 5.20.
Strictly speaking, we should call this “finitary monadic”. We omit the“finitary” for readability. The same remark applies to Definition 5.22 below.
Example 5.21.
The signature of Example 5.5 is monadic, but those of Example 5.6 veryrarely are.
Definition 5.22.
A register J − K : 𝑆 → UR C is monadic when for all signatures 𝑠 ∈ 𝑆 , theassociated abstract signature J 𝑠 K is. Notation 5.23.
For a monadic register, we denote by 𝑠 ★ the finitary monad on C inducedby any signature 𝑠 . There is a universal monadic register:
Definition 5.24.
For any locally presentable category C , let Monads C denote the (monadic)register • whose signatures are finitary monads on C , • the abstract signature of any signature 𝑇 being the forgetful functor 𝑇 -alg → C Proof.
The category of 𝑇 -algebras admits 𝑇 ( ) as an initial object. Remark 5.25.
Signatures of
Monads C are equivalently abstract signatures (Definition 5.19)such that the forgetful functor is finitary monadic. Remark 5.26.
A register is monadic iff it is a subregister of
Monads C , i.e., if it admits acompilation to Monads C .5.3. The universal endofunctorial register EF C . We can now convert the slogan
Endo-functors are signatures into a register, using the following well-known initiality result [46,p62].
Proposition 5.27.
For any finitary endofunctor 𝐹 on a cocomplete category C , the forgetfulfunctor 𝐹 -alg → C is monadic, and the left adjoint maps any object 𝐶 ∈ C to the initialalgebra 𝐹 ★ ( 𝐶 ) of the functor 𝐴 ↦→ 𝐶 + 𝐹 ( 𝐴 ) , i.e., the least fixed point 𝜇 𝐴. ( 𝐶 + 𝐹 ( 𝐴 )) , with 𝐹 -algebra structure given by 𝐹 ( 𝐹 ★ ( 𝐶 )) ↩ → 𝐶 + 𝐹 ( 𝐹 ★ ( 𝐶 )) (cid:27) 𝐹 ★ ( 𝐶 ) . Definition 5.28.
For a given cocomplete category C , we define the monadic register EF C ,called the universal endofunctorial register , as follows. Signatures:
A signature is a finitary endofunctor on C . Semantics:
The abstract signature associated to any finitary endofunctor 𝐹 is the forgetfulfunctor 𝑈 𝐹 : 𝐹 -alg → C . Validity proof:
By Proposition 5.27.Let us conclude by naming all registers defined by compilation into EF C . Definition 5.29.
We call endofunctorial all registers of the form 𝑓 ∗ ( EF C ) , for some map 𝑓 : S → Sig EF C , or equivalently all registers equipped with a compilation to EF C . ODULES OVER MONADS AND OPERATIONAL SEMANTICS 21
A useful fact is that endofunctorial registers are closed under the family construction:
Definition 5.30.
For any endofunctorial register 𝑅 , we denote by 𝑅 ∗ the endofunctorialregister whose signatures are families of signatures in Sig 𝑅 , and whose semantics maps anyfamily to the coproduct of associated endofunctors.5.4. Equational systems.
A general device for constructing categories of algebras is Fioreand Hur’s equational systems [23]. In this section, we turn equational systems on acategory C into signatures of a register ES C for C , called the equational register , whichrefines with equations the endofunctorial register EF C (see Definition 5.28). The validityproof for this register is deferred to §
10, where we will additionally provide characterisationsof underlying monads and initial algebras.Briefly, an equational system consists of two parts: • an endofunctor Σ on C , which intuitively specifies operations, • and equations.We present them in a slightly non-standard way, and the proof that it is equivalent tothe original is not exactly simple, so we defer it to Proposition 10.9 below.An equation will consist of a parallel pair of metaterms , in the following sense. Definition 5.31.
For any endofunctor Γ and monad 𝑇 on a category C , a 𝑇 -metaterm oftype Γ is a natural transformation Γ → 𝑇 .Recalling that Σ ★ denotes the free monad on any finitary endofunctor Σ , let us nowintroduce equational systems. Definition 5.32. An equational system E = ( C : Σ ⊲ Γ ⊢ 𝐿 = 𝑅 ) consists of • a locally finitely presentable category C , • finitary endofunctors Σ and Γ , together with • Σ ★ -metaterms 𝐿 and 𝑅 of type Γ . Example 5.33.
Let us consider the finitary endofunctor Σ on sets defined by Σ ( 𝑋 ) = 𝑋 ,so that Σ ★ ( 𝑋 ) denotes the set of binary trees with leaves in 𝑋 , as generated by the followinggrammar, 𝑒, 𝑓 F 𝑥 | ( 𝑒, 𝑓 ) where 𝑥 ranges over 𝑋 . Since Σ -algebras are sets equipped with a binary operation, a naturalequation to impose on them is associativity. To do this we take Γ ( 𝑋 ) = 𝑋 , 𝐿 ( 𝑥 , 𝑥 , 𝑥 ) = ( ( 𝑥 , 𝑥 ) , 𝑥 ) , and 𝑅 ( 𝑥 , 𝑥 , 𝑥 ) = ( 𝑥 , ( 𝑥 , 𝑥 )) .This should be rather natural, but it remains to define the models of an equationalsystems. For this, the idea is that a model is a Σ -algebra satisfying the equations in allcontexts . One way to enforce this is to consider the free monad on Σ + Γ , which intuitivelygenerates terms by interleaving operations from Σ and Γ . Now, recalling that we have ( Σ + Γ ) ★ (cid:27) Σ ★ + Γ ★ (in the category of finitary monads), each metaterm Γ → Σ ★ induces amonad morphism ( Σ + Γ ) ★ → Σ ★ , as follows. Definition 5.34.
For any metaterm 𝐾 : Γ → Σ ★ , let ˜ 𝐾 denote the monad morphism ( Σ + Γ ) ★ (cid:27) Σ ★ + Γ ★ [ id Σ ★ ,𝐾 ′ ] −−−−−−−−→ Σ ★ ,where 𝐾 ′ : Γ ★ → Σ ★ denotes the monad morphism induced by 𝐾 by freeness of Γ ★ . Let us now use this to define models.
Definition 5.35.
For any equational system E = ( C : Σ ⊲ Γ ⊢ 𝐿 = 𝑅 ) , an E -algebra is a Σ -algebra 𝑋 whose induced Σ ★ -algebra structure coequalises˜ 𝐿 𝑋 , ˜ 𝑅 𝑋 : ( Σ + Γ ) ★ ( 𝑋 ) ⇒ Σ ★ ( 𝑋 ) . Remark 5.36.
Families ( 𝑡 𝑖 = 𝑢 𝑖 ) 𝑖 of equations are covered by taking the coproduct of allinvolved endofunctors, say Γ 𝑖 , and the pointwise copairing of metaterms. Definition 5.37.
For a given locally finitely presentable category C , we define the monadicregister ES C , called the equational register , as follows. Signatures:
A signature is just an equational system.
Semantics:
The abstract signature associated to a signature E is the forgetful functor E -alg → C . Validity proof:
By Theorem 10.12 below.
Example 5.38.
Given a cocomplete category C , the universal endofunctorial register EF C is a subregister of ES C , by mapping any finitary endofunctor Σ to the (finitary) equationalsystem given by taking Γ = ∅ , and the unique 𝐿 and 𝑅 .5.5. The register
PSEF C for monoids. In the previous subsection, we reviewed thefundamental register available for pretty general categories. Here we review the fundamentalregister available for the category of monoids in a convenient monoidal category, essentiallydue to Fiore, Plotkin, and Turi [24].Signatures in the register
PSEF C will be pointed strong endofunctors on the monoidalcategory C , namely endofunctors equipped with the following additional structure. Definition 5.39.
Consider an endofunctor Σ on a monoidal category ( C , ⊗ , 𝐼 ) . A pointedstrength for Σ is a natural transformation 𝑠𝑡 𝑋,𝑌 : Σ ( 𝑋 ) ⊗ 𝑌 → Σ ( 𝑋 ⊗ 𝑌 ) ,where 𝑋 ∈ C and 𝑌 ∈ 𝐼 / C , making the following diagrams commute, ( Σ ( 𝑋 ) ⊗ 𝑌 ) ⊗ 𝑍 Σ ( 𝑋 ) ⊗ ( 𝑌 ⊗ 𝑍 ) Σ ( 𝑋 ⊗ 𝑌 ) ⊗ 𝑍 Σ ( ( 𝑋 ⊗ 𝑌 ) ⊗ 𝑍 ) Σ ( 𝑋 ⊗ ( 𝑌 ⊗ 𝑍 )) 𝛼 Σ ( 𝑋 ) ,𝑌,𝑍 𝑠𝑡 𝑋,𝑌 ⊗ 𝑍 𝑠𝑡 𝑋 ⊗ 𝑌 ,𝑍 Σ ( 𝛼 𝑋,𝑌 ,𝑍 ) 𝑠𝑡 𝑋,𝑌 ¤⊗ 𝑍 Σ ( 𝑋 ) Σ ( 𝑋 ) ⊗ 𝐼 Σ ( 𝑋 ⊗ 𝐼 ) 𝜌 Σ ( 𝑋 ) Σ ( 𝜌 𝑋 ) 𝑠𝑡 𝑋, ¤ 𝐼 where • 𝐼 / C inherits monoidal structure ( ¤ 𝐼, ¤⊗ , . . . ) from C in the obvious way [53], and • pointed objects 𝑒 𝑌 : 𝐼 → 𝑌 are denoted by their codomains 𝑌 for readability. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 23
Remark 5.40.
There is a simpler notion of strong endofunctor, which also involves anatural transformation 𝑠𝑡 𝑋,𝑌 : Σ ( 𝑋 ) ⊗ 𝑌 → Σ ( 𝑋 ⊗ 𝑌 ) , although with 𝑌 not pointed. Strongendofunctors embed into pointed strong endofunctors, which are thus more general. Thisgeneralisation is necessary to cover variable binding, as shown by the following example. Example 5.41.
For defining the 𝜆 -calculus syntax, we take C : = [ Set , Set ] 𝑓 to be thecategory of finitary endofunctors on sets with the composition tensor product, and Σ ( 𝑋 ) ( 𝑛 ) = 𝑋 ( 𝑛 ) + 𝑋 ( 𝑛 + ) (using the equivalence [ Set , Set ] 𝑓 ≃ [ Set 𝑓 , Set ] , where Set 𝑓 is the fullcategory spanning finite ordinals). Elements of 𝑋 ( 𝑌 ( 𝑛 )) = ∫ 𝑚 𝑋 ( 𝑚 ) × 𝑌 ( 𝑛 ) 𝑚 may be thoughtof as explicit substitutions 𝑥 L 𝜎 M , with 𝑥 ∈ 𝑋 ( 𝑚 ) and 𝑦 : 𝑚 → 𝑌 ( 𝑛 ) , considered equivalent upto standard equations, compactly summarised by ( 𝑓 · 𝑥 ) L 𝜎 M = 𝑥 L 𝜎 ◦ 𝑓 M , for all 𝑓 : 𝑚 → 𝑝 , 𝑥 ∈ 𝑋 ( 𝑚 ) and 𝑦 : 𝑝 → 𝑌 ( 𝑛 ) , where 𝑓 · 𝑥 is shorthand for 𝑋 ( 𝑓 ) ( 𝑥 ) .The pointed strength ( 𝑠𝑡 𝑋,𝑌 ) 𝑛 : Σ ( 𝑋 ) ( 𝑌 ( 𝑛 )) → Σ ( 𝑋 ( 𝑌 ( 𝑛 ))) describes the behaviour ofsubstitution w.r.t. application and abstraction. E.g., for application, we define it to map ( 𝑖𝑛 ( 𝑥 , 𝑥 )) L 𝜎 M to 𝑖𝑛 ( 𝑥 L 𝜎 M , 𝑥 L 𝜎 M ) . Abstraction is the point where pointedness of 𝑠𝑡 comes into play. Indeed, supposing that 𝑌 is equipped with a point 𝑒 𝑌 : 𝐼 → 𝑌 , we maydefine 𝜎 ↑ : 𝑚 + → 𝑌 ( 𝑛 + ) by copairing of 𝑚 𝜎 −→ 𝑌 ( 𝑛 ) 𝑌 ( 𝑖𝑛 ) −−−−−→ 𝑌 ( 𝑛 + ) and 1 ( 𝑒 𝑌 ) −−−−→ 𝑌 ( ) 𝑌 ( 𝑖𝑛 ) −−−−−→ 𝑌 ( 𝑛 + ) .We use this in defining the strength to map any 𝑖𝑛 ( 𝑥 ) L 𝜎 M , where 𝑥 ∈ 𝑋 ( 𝑚 + ) and 𝜎 : 𝑚 → 𝑌 ( 𝑛 ) , to 𝑖𝑛 ( 𝑥 L 𝜎 ↑ M ) .Since a signature in our register will be a pointed strong endofunctor, its models willbe monoids equipped with a “compatible” algebra structure, as we now define. The abstract signature Σ ⊗ associated to a pointed strong endofunctor Σ The crucial virtue of a pointed strong endofunctor Σ on C is that it yields a (monadic)abstract signature Σ ⊗ on Mon ( C ) , which we now describe.Let us thus fix a pointed strong endofunctor Σ on C . First, we associate to Σ a para-metric module (in the sense of Definition 2.12) on C as follows. Definition 5.42.
We define the parametric module Σ 𝑚𝑜𝑑 on C as assigning to any monoid 𝑋 ∈ C , the object Σ ( 𝑋 ) , equipped with the action given by the composite Σ ( 𝑋 ) ⊗ 𝑋 → Σ ( 𝑋 ⊗ 𝑋 ) → Σ ( 𝑋 ) . The verification that this assignment indeed defines a parametric module is straightfor-ward.Let us now define the category of models of our abstract signature Σ ⊗ . This is exactlythe classical category of Σ -monoids, which we present from a point of view better suited toour purpose. Definition 5.43. A Σ -monoid is a monoid 𝑋 , equipped with an 𝑋 -module morphism 𝜈 𝑋 : Σ 𝑚𝑜𝑑 ( 𝑋 ) → 𝑋 . A Σ -monoid morphism in a monoid morphism 𝑓 : 𝑋 → 𝑌 making thefollowing square commute. Σ 𝑚𝑜𝑑 ( 𝑋 ) Σ 𝑚𝑜𝑑 ( 𝑌 ) 𝑋 𝑌 Σ 𝑚𝑜𝑑 ( 𝑓 ) 𝜈 𝑋 𝑓 𝜈 𝑌 Let Σ - Mon denote the category of Σ -monoids and morphisms between them, and let 𝑈 Σ : Σ - Mon → Mon ( C ) denote the forgetful functor.Let us first prove that this agrees with the standard definition. Proposition 5.44.
The category Σ - Mon is isomorphic over
Mon ( C ) to the category whose • objects are monoids 𝑋 equipped with Σ -algebra structure 𝜈 𝑋 : Σ ( 𝑋 ) → 𝑋 making the dia-gram Σ ( 𝑋 ) ⊗ 𝑋 Σ ( 𝑋 ⊗ 𝑋 ) Σ ( 𝑋 ) 𝑋 ⊗ 𝑋 𝑋 𝑠𝑡 𝑋,𝑋 𝜈 𝑋 ⊗ 𝑋 Σ ( 𝑚 𝑋 ) 𝑚 𝑋 𝜈 𝑋 (5.1) commute, and whose • morphisms are morphisms in C which are both monoid and Σ -algebra morphisms.Proof. By definition of Σ 𝑚𝑜𝑑 , it is equivalent for a morphism Σ ( 𝑋 ) → 𝑋 to be an 𝑋 -modulemorphism, and for the condition (5.1) to hold. Theorem 5.45.
For any pointed strong endofunctor on a convenient monoidal category C , the category Σ - Mon and the forgetful functor 𝑈 Σ : Σ - Mon → Mon ( C ) form a monadicabstract signature. Equivalently, the forgetful functor 𝑈 Σ : Σ - Mon → Mon ( C ) is monadic.Proof. We have a commuting triangle Σ - Mon Mon ( C ) C , 𝑈 Σ U Σ - Mon U Mon ( C ) where, by [23, § U Σ - Mon and U Mon ( C ) are both monadic, the corresponding monadsbeing finitary (noting that Mon ( C ) (cid:27) Mon ). By [2, Remark 2.78] with 𝜆 = 𝜔 , it followsthat all three categories are locally finitely presentable, hence in particular cocomplete. Theresult thus follows by Proposition 2.23.Before recalling a standard characterisation of the monad induced by the monadicfunctor 𝑈 Σ , let us fix some notation. Notation 5.46.
Given a pointed strong endofunctor Σ , the notation Σ ★ may now thusdenote two monads: “free Σ -monoid” monad on Mon ( C ) that we just proved to exist, andthe more basic “free Σ -algebra” monad on C . Additionally, we also saw that there is a “free Σ -monoid” on C , which could also be denoted by Σ ★ . In order to partially disambiguate, letus fix the following convention when Σ is a pointed strong endofunctor: • Σ ★ denotes the “free Σ -monoid” monad, either on Mon ( C ) or C , depending on context(but more often on C ), and • Σ ∗ denotes the “free Σ -algebra” monad on C . Proposition 5.47.
For any pointed strong endofunctor Σ on a convenient monoidal cate-gory C , the monad Σ ★ induced by the right adjoint functor Σ - Mon → Mon ( C ) → C mapsany object 𝐶 ∈ C to 𝜇 𝐴. ( 𝐼 + Σ ( 𝐴 ) + 𝐶 ⊗ 𝐴 ) .Furthermore, the carrier Σ ★ ( ) of the initial Σ -monoid is isomorphic to Σ ∗ ( 𝐼 ) . ODULES OVER MONADS AND OPERATIONAL SEMANTICS 25
Proof.
This is more or less known since [24, 23, 25], see [18, Theorem 2.15] for an explicit,complete statement.Let us finally define our register for monoids.
Definition 5.48.
For any convenient monoidal category C , the monadic register PSEF C for the category Mon ( C ) of monoids in C is defined as follows. Signatures:
A signature is a finitary, pointed strong endofunctor on C . Semantics:
The abstract signature associated to any signature Σ is the forgetful functor Σ - Mon → Mon ( C ) . Validity proof:
By Theorem 5.45.5.6.
Monoidal equational systems.
In this section, we combine the registers ES C and PSEF C of the two previous sections, yielding a new register MES C obtained from PSEF C by ‘adding monoidal equations’. Definition 5.49. A monoidal equational system E = ( C : Σ ⊲ Γ ⊢ 𝐿 = ⊗ 𝑅 ) consists of • a convenient monoidal category C , • two pointed strong endofunctors Σ and Γ on C , and • a reflexive pair of monad morphisms 𝐿, 𝑅 : ( Σ + Γ ) ★ ⇒ Σ ★ , with common section theobvious morphism Σ ★ → ( Σ + Γ ) ★ . We say that 𝐿 = ⊗ 𝑅 is a monoidal equation . Remark 5.50.
By Street’s correspondence (Proposition 2.27), a monoidal equation is equiv-alently a pair of functors Σ - Mon → ( Σ + Γ ) - Mon over C with common section the obviousfunctor in the opposite direction. Clearly, this is further equivalent to a pair of functors Σ - Mon → Γ - Mon over C . Remark 5.51.
We conjecture that monad morphisms ( Σ + Γ ) ★ → Σ ★ with the obvioussection are in 1-1 correspondence with morphisms Γ → Σ ★ of pointed strong endofunctors,i.e., natural transformations commuting with strengths. Example 5.52.
Recall from Example 5.41 the pointed strong endofunctor Σ ( 𝑋 ) ( 𝑛 ) = 𝑋 ( 𝑛 ) + 𝑋 ( 𝑛 + ) for pure 𝜆 -calculus on [ Set , Set ] 𝑓 . In this paper we are more inter-ested in dynamics, but we could consider the 𝛽 -rule as an equation. For this, we wouldtake Γ ( 𝑋 ) ( 𝑛 ) = 𝑋 ( 𝑛 + ) × 𝑋 ( 𝑛 ) , and define 𝐿 and 𝑅 at any Σ -monoid 𝑇 to map any ( 𝑓 , 𝑒 ) ∈ 𝑇 ( 𝑛 + ) × 𝑇 ( 𝑛 ) to 𝜆 ( 𝑓 ) 𝑒 and 𝑓 [ 𝑒 ] respectively, where 𝑓 [ 𝑒 ] denotes the result ofsubstituting 𝑒 for the ( 𝑛 + ) th variable of 𝑓 . Definition 5.53.
For any monoidal equational system E = ( C : Σ ⊲ Γ ⊢ 𝐿 = ⊗ 𝑅 ) , an E -algebra is an object 𝑋 whose Σ ★ ( 𝑋 ) -algebra structure coequalises 𝐿 𝑋 , 𝑅 𝑋 : ( Σ + Γ ) ★ ( 𝑋 ) ⇒ Σ ★ ( 𝑋 ) . An E -algebra morphism is a morphism between underlying Σ -monoids. We let 𝑈 E : E -alg → Mon ( C ) denote the forgetful functor. Definition 5.54.
For a given convenient monoidal category C , we define the monadicregister MES C , called the monoidal equational register , as follows. Signatures:
A signature is a monoidal equational system.
Semantics:
The abstract signature associated to a signature E is the forgetful functor E -alg → Mon ( C ) . Validity proof:
By Theorem 10.14 below. Registers for monads
In this section, we design a register for monads on a category of the form
Set P for some set P . Because monads are monoids in the category of endofunctors, the register MES [ Set P , Set P ] 𝑓 could allow us to specify the monads of §
4. However, we choose to define below a dedicatedsubregister,
ModMnd ( P ) which we hope more user-friendly, especially in the simply-typedcase. The name ModMnd ( P ) is chosen because signatures are based on modules overmonads. This register generalises straightforwardly Ahrens et al.’s approach [6] from theuntyped to the simply-typed setting. The basic idea for specifying operations is that thearity of an operation consists of • an “input” ( Set -valued) parametric module, in the sense of module that is definable forany monad on
Set P , together with • an “output” placetaker type 𝑝 ∈ P .In our first subsection below, we review parametric modules. In the second subsection,we construct the subregister SModMnd ( P ) of PSEF [ Set P , Set P ] 𝑓 (as justified later by Propo-sition 10.18) which only allows to specify operations. We then deal with equations in thethird subsection. All validity proofs are again deferred to §
10, where we will additionallyprovide characterisations of underlying monads and initial algebras.6.1.
Parametric modules.
We start by reviewing some categories of modules.
Definition 6.1.
Given categories C and D , let Mod ( C , D ) , or Mod ( D ) when C is clearfrom context, denote the category • whose objects are pairs ( 𝑇 , 𝑀 ) of a finitary monad 𝑇 on C and a finitary 𝑇 -module 𝑀 : C → D , • and whose morphisms ( 𝑇 , 𝑀 ) → (
𝑈, 𝑁 ) are pairs ( 𝛼, 𝛽 ) of a monad morphism 𝛼 : 𝑇 → 𝑈 and a natural transformation 𝛽 : 𝑀 → 𝑁 commuting with action, in the sense that thefollowing square commutes. 𝑀 ◦ 𝑇 𝑁 ◦ 𝑈𝑀 𝑁 𝛽 ◦ 𝛼𝛽 The first projection yields a forgetful functor p : Mod ( D ) → Mnd 𝑓 . Definition 6.2.
A ( D -valued) parametric module is a section of p , or in other words afunctor 𝑠 : Mnd 𝑓 → Mod ( D ) such that p ◦ 𝑠 = id Mnd 𝑓 . Terminology 6.3 .
In the following, C = Set P , and parametric modules are implicitly Set -valued by default.
Example 6.4.
Let us start by a few basic constructions of parametric modules: • analogously to Definition 5.42, any pointed strong endofunctor Σ on [ C , C ] 𝑓 induces a C -valued parametric module Mnd 𝑓 ( C ) → Mod ( C , C ) that we again denote by Σ 𝑚𝑜𝑑 , orsimply Σ for short; • we denote by Θ the Set P -valued parametric module mapping a monad 𝑇 to itself, as amodule over itself; ODULES OVER MONADS AND OPERATIONAL SEMANTICS 27 • for any 𝑝 , . . . , 𝑝 𝑛 ∈ P and D -valued parametric module 𝑀 , let 𝑀 ( 𝑝 ,..., 𝑝 𝑛 ) associate toeach monad 𝑇 the 𝑇 -module 𝑀 ( 𝑇 ) ( 𝑝 ,..., 𝑝 𝑛 ) as in the notations of §
1, i.e., 𝑀 ( 𝑝 ,..., 𝑝 𝑛 ) ( 𝑇 ) ( 𝑋 ) = 𝑀 ( 𝑇 ) ( 𝑋 + y 𝑝 + . . . + y 𝑝 𝑛 ) ; when P =
1, we merely count the 𝑝 𝑖 ’s and write 𝑀 ( 𝑛 ) ; • for any finitary functor 𝐹 : D → E and D -valued parametric module 𝑀 , the E -parametricmodule 𝐹 ◦ 𝑀 maps any monad 𝑇 to the 𝑇 -module 𝐹 ◦ 𝑀 ( 𝑇 ) ; as particular cases: – the terminal Set -valued parametric module 1 = ◦ Θ maps any monad 𝑇 to the constant 𝑇 -module 1; – for any 𝑝 ∈ P and Set P -valued parametric module 𝑀 , we denote by 𝑀 𝑝 the Set -valuedparametric module mapping any monad 𝑇 to the 𝑇 -module 𝑋 ↦→ 𝑀 ( 𝑋 ) 𝑝 (see § – given a finite family ( 𝑀 𝑖 ) 𝑖 ∈ 𝐼 of Set -valued parametric modules, 𝐼 , let Î 𝑖 𝑀 𝑖 associateto any monad 𝑇 the 𝑇 -module Î 𝑖 𝑀 𝑖 ( 𝑇 ) . Example 6.5.
The idea of our register is that an operation will be specified by two para-metric modules, one for the source and one for the target. Let us give the parametricmodules for a few operations from our examples.Language Operation Source TargetPure 𝜆𝜇 Push Θ p × Θ s Θ s Pure 𝜆𝜇 Abstraction Θ ( p ) p Θ p 𝜋 -calculus Input 𝑎 ( 𝑏 ) .𝑃 Θ c × Θ ( c ) p Θ p The register
SModMnd ( P ) for specifying operations. This section is devoted todefining the monadic register
SModMnd ( P ) .Signatures will rely on parametric modules, but these need to be restricted in order toensure existence of an initial algebra (and even monadicity). Proposition 6.6.
For any set P , 𝑝 , . . . , 𝑝 𝑛 ∈ P , and finitary functor 𝐹 : Set P → Set ,the assignment
𝑇 , 𝑋 ↦→ 𝐹 ( 𝑇 ( 𝑋 + Í 𝑖 ∈ 𝑛 y 𝑝 𝑖 )) defines a parametric module denoted by ( 𝐹 ◦ Θ ) ( 𝑝 ,..., 𝑝 𝑛 ) .Proof. Straightforward.
Definition 6.7.
A parametric module is elementary iff it is isomorphic to some finiteproduct of parametric modules of the shape ( 𝐹 ◦ Θ ) ( 𝑝 ,..., 𝑝 𝑛 ) . Example 6.8.
Typically, taking 𝐹 ( 𝑋 ) = 𝑋 ( 𝑝 ) , an elementary parametric module is a finiteproduct of parametric modules of the shape Θ ( 𝑝 ,..., 𝑝 𝑛 ) 𝑝 , for some 𝑝, 𝑝 , . . . , 𝑝 𝑛 ∈ P . Definition 6.9.
Given any set P , a modular signature is a family of pairs ( 𝑑, 𝑝 ) where • 𝑑 is an elementary parametric module, and • 𝑝 ∈ P . Definition 6.10.
Given any modular signature 𝑆 = ( 𝑑 𝑖 , 𝑝 𝑖 ) 𝑖 ∈ 𝐼 , an 𝑆 -algebra is a monad 𝑇 equipped with module morphisms 𝑑 𝑖 ( 𝑇 ) → 𝑇 𝑝 𝑖 for all 𝑖 ∈ 𝐼 . A model morphism is amonad morphism commuting with these morphisms. We denote by 𝑆 -alg → Mnd 𝑓 ( Set P ) the forgetful functor. Definition 6.11.
For any set P , we define the monadic register SModMnd ( P ) for Mnd 𝑓 ( Set P ) as follows. Signatures:
A signature is a modular signature.
Semantics:
The abstract signature associated to any signature 𝑆 is the forgetful functor 𝑆 -alg → Mnd 𝑓 ( Set P ) . Validity proof:
By Corollary 10.19 below.6.3.
The register
ModMnd ( P ) . We now define our register
ModMnd ( P ) , where a signa-ture will consist of a signature of SModMnd ( P ) , plus a family of “equations”. An equationis essentially a pair of “metaterms”, which may have “metavariables”. The idea is thatmetavariables are given by a parametric module. Example 6.12.
Consider associativity of parallel composition in 𝜋 -calculus, 𝑃 | ( 𝑄 | 𝑅 ) ≡( 𝑃 | 𝑄 ) | 𝑅 : the metavariables are 𝑃 , 𝑄 , and 𝑅 . The corresponding parametric module is Θ p .Intuitively, a metaterm will be a parametric module morphism from metavariables tosome Θ 𝑝 . However, it should potentially rely on constructions from the considered signature 𝑆 of SModMnd ( P ) , as in Example 6.12. We thus consider a modified notion of parametricmodule morphism, which is parametric in models of 𝑆 instead of mere monads. Definition 6.13.
Given any signature 𝑆 for SModMnd ( P ) , • an 𝑆 -module morphism 𝑀 → 𝑁 between parametric modules 𝑀 and 𝑁 is a naturalfamily of morphisms ( 𝛼 𝑇 : 𝑀 ( 𝑇 ) −→ 𝑁 ( 𝑇 )) 𝑇 ∈ 𝑆 -alg , such that 𝛼 𝑇 is a 𝑇 -module morphism,for each 𝑆 -model 𝑇 ; • an 𝑆 -equation consists of an elementary parametric module 𝑉 , called the metavariablemodule , and two parallel 𝑆 -module morphisms 𝑉 −→ 𝜃 𝑝 , for some 𝑝 ∈ P , called the metaterms (of type 𝑝 ) .This gives the desired notion of signature. Definition 6.14. An equational modular signature is a signature 𝑆 of SModMnd ( P ) ,together with a family of 𝑆 -equations. Definition 6.15.
For any equational modular signature ( 𝑆, 𝐸 ) , an ( 𝑆, 𝐸 ) -algebra is an 𝑆 -algebra 𝑇 such that for all equations ( 𝐿, 𝑅 ) ∈ 𝐸 , 𝐿 𝑇 = 𝑅 𝑇 . A morphism of ( 𝑆, 𝐸 ) -algebrasis a morphism of models of 𝑆 . We let ( 𝑆, 𝐸 ) -alg denote the category of ( 𝑆, 𝐸 ) -algebras andmorphisms between them.Let us at last define our register. Definition 6.16.
For any set P , we define the monadic register ModMnd ( P ) for Mnd 𝑓 ( Set P ) as follows. Signatures:
A signature is an equational modular signature.
Semantics:
The abstract signature associated to any equational modular signature ( 𝑆, 𝐸 ) is the forgetful functor ( 𝑆, 𝐸 ) -alg → Mnd 𝑓 ( Set P ) Validity proof:
By Corollary 10.23 below.
Example 6.17.
Let us revisit Example 6.12: the relevant signature Σ has in particular anoperation 𝑝𝑎𝑟 : Θ p → Θ p for parallel composition, which gives our two metaterms Θ p 𝑝𝑎𝑟 × Θ p −−−−−−→ Θ p 𝑝𝑎𝑟 −−−→ Θ p and Θ p Θ p × 𝑝𝑎𝑟 −−−−−−→ Θ p 𝑝𝑎𝑟 −−−→ Θ p . ODULES OVER MONADS AND OPERATIONAL SEMANTICS 29
Notation 6.18 (Format for equations) . We have already started to write pairs ( 𝑑, 𝑝 ) as 𝑑 → Θ 𝑝 . Given any signature Σ for SModMnd ( P ) , we write any Σ -equation 𝑉 → Θ 𝑝 𝑥 ↦→ ( 𝐿, 𝑅 ) as 𝑥 : 𝑉 ⊢ 𝐿 ≡ 𝑅 : Θ 𝑝 , or just 𝐿 ≡ 𝑅 when the rest may be inferred. Example 6.19.
We write associativity from Example 6.17 as just 𝑝𝑎𝑟 ( 𝑃, 𝑝𝑎𝑟 ( 𝑄, 𝑅 )) ≡ 𝑝𝑎𝑟 ( 𝑝𝑎𝑟 ( 𝑃, 𝑄 ) , 𝑅 ) . In this case, the argument 𝑥 is the triple ( 𝑃, 𝑄, 𝑅 ) .7. Registers for (state) functors
In this section, we define a register
PModFun ( P , S ) , which is an adaptation of ModMnd ( P ) to the case of state functors. As in the previous section, we first introduce a register SPModFun ( P , S ) for operations, and then a refinement PModFun ( P , S ) with equations.Again, all validity proofs are deferred to § Parametric premodules.
The signatures of
SPModFun ( P , S ) are based on a notionof parametric premodule over a functor: Definition 7.1.
For any sets P and S , and category D , a D -valued parametric pre-module is a finitary functor [ Set P , Set S ] 𝑓 → [ Set P , D ] 𝑓 . From now on, unless mentionedotherwise, parametric premodules will be Set -valued.Let
PMod ( P , S , D ) : = [[ Set P , Set S ] 𝑓 , [ Set P , D ] 𝑓 ] 𝑓 denote the category of D -valuedparametric premodules.We introduce the following notations: Notation 7.2.
We denote by Θ the identity endofunctor on [ Set P , Set S ] 𝑓 , and by I : [ Set P , Set S ] 𝑓 → [ Set P , Set P ] 𝑓 the constant functor mapping anything to the identity endofunctor. Post-composing withevaluation at any 𝑝 ∈ P , resp. 𝑠 ∈ S , we get parametric premodules Θ 𝑠 and I 𝑝 . The constructions Î 𝑖 𝑀 𝑖 and 𝑀 ( 𝑝 ,..., 𝑝 𝑛 ) on parametric modules carry over essentiallyverbatim. Example 7.3.
We have seen in § 𝑆 for call-by-value,simply-typed 𝜆 -calculus is built with application binary trees. Intuitively, it has two (type-indexed families of) operations: the first one injects values, thus maps 𝑋 𝑡 , into 𝑆 ( 𝑋 ) 𝑡 , andthe second one forms application binary trees, thus maps 𝑆 ( 𝑋 ) 𝑡 → 𝑡 ′ × 𝑆 ( 𝑋 ) 𝑡 into 𝑆 ( 𝑋 ) 𝑡 ′ .This will yield a specification with two families of operations I 𝑡 → Θ 𝑡 and Θ 𝑡 → 𝑡 ′ × Θ 𝑡 → Θ 𝑡 ′ .7.2. The register
SPModFun ( P , S ) for specifying operations. Operations, equations,and models will be defined exactly as for monads, and a signature in
PModFun ( P , S ) willagain consist of families of operations and equations. The only difference lies in the notionof elementary parametric premodule, which becomes the following: Definition 7.4.
A parametric premodule is elementary iff it is isomorphic to some finiteproduct of parametric premodules of the shape ( 𝐻 ◦ h I , Θ i) ( 𝑝 ,..., 𝑝 𝑛 ) for some 𝑝 , . . . , 𝑝 𝑛 ∈ P and finitary functor 𝐻 : Set P × Set S → Set . Example 7.5.
Typically, an elementary parametric premodule is a product of parametricpremodules of the shape I ( 𝑝 ,..., 𝑝 𝑛 ) 𝑝 or Θ ( 𝑝 ,..., 𝑝 𝑛 ) 𝜎 , for some 𝑝, 𝑝 , . . . , 𝑝 𝑛 ∈ P and 𝜎 ∈ S . Definition 7.6. A premodular signature is a family of pairs ( 𝑑, 𝜎 ) consisting of anelementary parametric premodule 𝑑 and an element 𝜎 in S . Definition 7.7.
For any premodular signature 𝑆 = ( 𝑑 𝑖 , 𝜎 𝑖 ) 𝑖 ∈ 𝐼 , an 𝑆 -algebra is a finitaryfunctor 𝐹 : Set P → Set S , equipped with natural transformations 𝑑 𝑖 ( 𝐹 ) → Θ 𝜎 𝑖 ( 𝐹 ) for all 𝑖 ∈ 𝐼 . A morphism of 𝑆 -algebras is a natural transformation commuting with thesemorphisms. Let 𝑆 -alg denote the category of 𝑆 -algebras, and 𝑈 𝑆 : 𝑆 -alg → [ Set P , Set S ] 𝑓 the forgetful functor. Definition 7.8.
For any sets P and S , we define the monadic register SPModFun ( P ) asfollows. Signatures:
A signature is a premodular signature.
Semantics:
The abstract signature associated to any premodular signature 𝑆 is the forget-ful functor 𝑆 -alg → [ Set P , Set S ] 𝑓 . Validity proof:
By Corollary 10.27 below.7.3.
The register
PModFun ( P , S ) .Definition 7.9. Given any signature 𝑆 for SPModFun ( P ) , • an 𝑆 -premodule morphism 𝑀 → 𝑁 between parametric premodules 𝑀 and 𝑁 is anatural family of natural transformations ( 𝛼 𝐹 : 𝑀 ( 𝐹 ) −→ 𝑁 ( 𝐹 )) 𝐹 ∈ 𝑆 -alg ; • an 𝑆 -equation consists of an elementary parametric premodule 𝑉 , called the metavari-able premodule , and two parallel 𝑆 -premodule morphisms 𝑉 −→ 𝜃 𝜎 , for some 𝜎 ∈ S ,called the metaterms (of type 𝜎 ) . Definition 7.10.
For any sets P and S , we define the monadic register PModFun ( P , S ) for [ Set P , Set S ] 𝑓 as follows. Signatures:
A signature is a pair of a signature 𝑆 of SPModFun ( P ) and a family of 𝑆 -equations. Semantics:
A model is a model 𝐹 of 𝑆 such that for all equations ( 𝐿, 𝑅 ) ∈ 𝐸 , 𝐿 ( 𝐹 ) = 𝑅 ( 𝐹 ) .A morphism of models of ( 𝑆, 𝐸 ) is a morphism of models of 𝑆 . Validity proof:
By Corollary 10.31 below.
Remark 7.11.
Any finitary functor 𝐹 admits a trivial signature consisting of the family ( ( 𝐹 𝜎 ◦ I ) → Θ 𝜎 ) 𝜎 ∈ S of operations, which does not prevent other signatures from being moreconvenient (see the case of Example 7.3). Here are a few examples from § 𝜆𝜇 𝑆 ( 𝑋 ) = 𝑆 ( 𝑋 ) = ( 𝑋 p × 𝑋 s , 𝑋 p , 𝑋 s ) h−|−i : I p × I s → Θ c 𝜂 p : I p → Θ p 𝜂 s : I s → Θ s 𝜋 𝑆 ( 𝑋 ) = 𝑆 ( 𝑋 ) = 𝑋 p I p → Θ Call-by-value, simply-typed 𝜆 𝑆 ( 𝑋 ) = 𝑋 𝜂 𝑡 : I 𝑡 → Θ 𝑡 (for all 𝑡 )Positive GSOS specifications 𝑆 ( 𝑋 ) = 𝑋 I → Θ 𝑆 ( 𝑋 ) = A × 𝑋 A × I → Θ ODULES OVER MONADS AND OPERATIONAL SEMANTICS 31
Notation 7.12.
Notation 6.18 extends trivially to equations in signatures of
PModFun ( P , S ) .E.g., Example 6.19 applies verbatim for associativity of multiset union in the target statefunctor for differential 𝜆 -calculus. Registers for slice categories
In this section, we provide registers for slice categories C / 𝑋 , where C is a locally finitely pre-sentable category and 𝑋 an object of C . In §
8, we first present a basic register
SSlice ( C , 𝑋 ) that would work for the untyped case without variable binding. Then, in § SSlice ( C , 𝑋 ) to a more powerful register MSlice ( C , 𝑋 ) that deals with variable bind-ing. Mimicking the passage from endofunctors to parametric modules (more precisely, say,from MES to ModMnd ), we then provide a variant adapted to the typed setting, called
Slice ( C , 𝑋 ) . Finally, in § C = 𝑇 - Mod 𝑓 /( 𝑆 ◦ 𝑇 × 𝑆 ◦ 𝑇 ) , for which we introduce special notation.8.1. Small register for slice categories.
In this section, we introduce a first, limitedregister for slice categories.
Example 8.1.
Let P denote the set of simple types over a given set of basic types, as in § Σ app : Set P → Set P defined by Σ app ( 𝑋 ) ( 𝐴 ) = Õ 𝐵 𝑋 ( 𝐵 → 𝐴 ) × 𝑋 ( 𝐵 ) .Across the equivalence Set P ≃ Set / P , one way of presenting this endofunctor which isperhaps closer to the syntactic inference rule for application is as the span P h arr , 𝜋 i ←−−−−−− P 𝜋 −−→ P ,where arr ( 𝐴, 𝐵 ) = ( 𝐵 → 𝐴 ) . Indeed, Σ app ( 𝑋 ) corresponds to • taking the square 𝑋 → P in the arrow category, • pulling back along h arr , 𝜋 i , and • postcomposing with 𝜋 .To see this, let us observe that after pulling back, we obtain a family 𝑋 ′ over P such that 𝑋 ′ ( 𝐴, 𝐵 ) = 𝑋 ( 𝐵 → 𝐴 ) × 𝑋 ( 𝐵 ) . Postcomposing, we take the disjoint union over 𝐴 as desired.Generalising from this example, we obtain the following “small” register. Definition 8.2.
For all locally finitely presentable categories C and objects 𝑋 ∈ C , wedefine the endofunctorial register SSlice ( C , 𝑋 ) for the slice category C / 𝑋 as follows. Signatures:
A signature consists of: • a metavariable object 𝑉 ; • a list of premise morphisms ( 𝑉 𝑠 𝑖 −→ 𝑋 ) 𝑖 ∈ 𝑛 denoted by 𝑉 ® 𝑠 −→ 𝑋 𝑛 ; • a conclusion morphism 𝑉 𝑡 −→ 𝑋 . Semantics:
A model of a signature ( 𝑋 𝑛 ® 𝑠 ←− 𝑉 𝑡 −→ 𝑋 ) is an algebra for the endofunctormapping any 𝑌 𝑝 −→ 𝑋 to 𝑌 ′ → 𝑉 𝑡 −→ 𝑋 , where 𝑌 ′ → 𝑉 denotes the following pullback. 𝑌 ′ 𝑌 𝑛 𝑉 𝑋 𝑛 ® 𝑠 𝑝 𝑛 Morphisms of models are morphisms of algebras.
Validity proof:
All we have to show is that the induced endofunctor is finitary. But thisfunctor is a composite of three functors C / 𝑋 (−) 𝑛 / 𝑋 −−−−−−→ C / 𝑋 𝑛 ® 𝑠 ∗ −→ C / 𝑉 𝑡 ! −→ C / 𝑋 ,where • (−) 𝑛 / 𝑋 denotes 𝑛 -fold self-product in the arrow category, • ® 𝑠 ∗ denotes pullback along ® 𝑠 , and • 𝑡 ! denotes postcomposition with 𝑡 .The last two functors, as left adjoints, are cocontinuous, hence finitary. Finally, the forget-ful functor C / 𝑋 𝑛 → C creates colimits, so it suffices to show that the composite functor C / 𝑋 (−) 𝑛 / 𝑋 −−−−−−→ C / 𝑋 𝑛 → C is finitary. But this in turn is the composite of C / 𝑋 → C (−) 𝑛 −−−→ C .Because the first component creates, hence preserves all colimits, it suffices to show that (−) 𝑛 is finitary, which holds since filtered colimits commute with finite limits in locallyfinitely presentable categories. Example 8.3.
Let P = Set P (cid:27) Set , and 𝑇 denote the monad for pure 𝜆 -calculussyntax. Taking C = 𝑇 - Mod 𝑓 and 𝑋 = 𝑇 , let us consider the left congruence rule forapplication 𝑀 −→ 𝑁𝑀 𝑃 −→ 𝑁 𝑃 as a signature of
SSlice ( C , 𝑋 ) . For this, we take • as metavariable module 𝑉 = 𝑇 , • a single premise given by h 𝜋 , 𝜋 i : 𝑇 → 𝑇 , and • as conclusion the morphism 𝑡 : 𝑇 → 𝑇 mapping any ( 𝑀, 𝑁 , 𝑃 ) to ( 𝑀 𝑃, 𝑁 𝑃 ) .Let us now see what it means for a module morphism 𝑅 → 𝑇 to be a model. In this case,the pullback along h 𝜋 , 𝜋 i yields 𝑅 × 𝑇 , and so a model structure amounts to a morphism 𝑅 × 𝑇 → 𝑅 making the following triangle commute 𝑅 × 𝑇 𝑅𝑇 × 𝑇 𝑇 . 𝑡 Unfolding the definition, such a map associates to any transition 𝑟 ∈ 𝑅 ( 𝑋 ) over ( 𝑀, 𝑁 ) ∈ 𝑇 ( 𝑋 ) and term 𝑃 ∈ 𝑇 ( 𝑋 ) a transition 𝑟 | 𝑃 over 𝑡 ( 𝑀, 𝑁 , 𝑃 ) = ( 𝑀 𝑃, 𝑁 𝑃 ) , as desired. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 33
Binding register for slice categories.
In this section, we observe that the register
SSlice ( C , 𝑋 ) is not expressive enough in the presence of variable binding, hence proceed todefine a refined variant. Example 8.4.
Let P = Set P (cid:27) Set , and 𝑇 denote the monad for pure 𝜆 -calculussyntax. Taking C = 𝑇 - Mod 𝑓 and 𝑋 = 𝑇 as in Example 8.3, let us consider the 𝜉 -rule 𝑀 → 𝑁𝜆𝑥.𝑀 → 𝜆𝑥.𝑁 · The natural metavariable module for this is 𝑇 ( ) × 𝑇 ( ) , because 𝑀 and 𝑁 have an additional,fresh variable, and the natural premise would be the identity map thereon. However, theregister SSlice ( C , 𝑋 ) only allows premises to target powers of 𝑋 .In order to remedy this situation, we refine SSlice ( C , 𝑋 ) to obtain the following “medium”register. Definition 8.5.
For all locally finitely presentable categories C and objects 𝑋 ∈ C , wedefine the endofunctorial register MSlice ( C , 𝑋 ) for the slice category C / 𝑋 as follows. Signatures:
A signature consists of: • a metavariable object 𝑉 ; • a list of premise morphisms ( 𝑉 𝑠 𝑖 −→ 𝐹 𝑖 𝑋 ) 𝑖 ∈ 𝑛 , where each 𝐹 𝑖 is a finitary endofunctor on C , denoted by 𝑉 ® 𝑠 −→ Î 𝑖 𝐹 𝑖 𝑋 ; • a conclusion morphism 𝑉 𝑡 −→ 𝑋 . Semantics:
A model of a signature ( Î 𝑖 𝐹 𝑖 𝑋 ® 𝑠 ←− 𝑉 𝑡 −→ 𝑋 ) is an algebra for the functormapping 𝑌 𝑝 −→ 𝑋 to 𝑌 ′ → 𝑉 𝑡 −→ 𝑋 , where 𝑌 ′ denotes the pullback 𝑌 ′ Î 𝑖 𝐹 𝑖 ( 𝑌 ) 𝑉 Î 𝑖 𝐹 𝑖 ( 𝑋 ) ® 𝑠 Î 𝑖 𝐹 𝑖 ( 𝑝 ) Validity proof:
Similar to Definition 8.2, with the following composite endofunctor. C / 𝑋 ( Î 𝑖 𝐹 𝑖 (−))/ 𝑋 −−−−−−−−−−−→ C / Î 𝑖 𝐹 𝑖 ( 𝑋 ) ® 𝑠 ∗ −→ C / 𝑉 𝑡 ! −→ C / 𝑋 Example 8.6.
Let us now treat the 𝜉 -rule, rectifying Example 8.4. • We first take as metavariable module 𝑉 : = 𝑇 ( ) × 𝑇 ( ) , as planned. • We then take as unique premise the identity on 𝑉 . For this we should justify that 𝑉 doeshave the desired form 𝐹 ( 𝑇 ) . This is the case for 𝐹 ( 𝑀 ) = 𝑀 ( ) since ( 𝑇 ) ( ) = ( 𝑇 ( ) ) . • Finally, we take as conclusion 𝑉 : = 𝑇 ( ) × 𝑇 ( ) 𝜆 × 𝜆 −−−→ 𝑇 × 𝑇 . Remark 8.7.
We may generalise this register to permit a conclusion between terms withadditionnal free variables, by having the conclusion morphism target
𝑅 𝑋 rather than 𝑋 , forsome finitary right adjoint functor 𝑅 . For example, the application of untyped 𝜆 -calculuscan be viewed as an operation app 𝑎𝑙𝑡 : 𝑇 → 𝑇 ( ) , since 𝑀 ( ) is 𝑀 𝑇 in the category of 𝑇 -modules. Then, the 𝛽 -reduction relates app 𝑎𝑙𝑡 ( 𝑎𝑏𝑠 ( 𝑡 )) to 𝑡 , which both lie in 𝑇 ( ) ( 𝑋 ) , forsome set 𝑋 . Typed variant.
In this section, we observe that the medium register
MSlice ( C , 𝑋 ) isslightly inconvenient in a typed setting. Example 8.8.
Let P denote the set of simple types over a given set of basic types and 𝑇 : Set P → Set P denote the monad for simply-typed 𝜆 -calculus values, and let 𝑆 : Set P → Set P denote the first state functor from § 𝑆 ( 𝑋 ) is the set of typed applicationbinary trees with leaves in 𝑋 . Let us consider the 𝛽 -rule 𝑒 ⇓ 𝜆 ( 𝑒 ) 𝑒 ⇓ 𝑤 𝑒 [ 𝑤 ] ⇓ 𝑣𝑒 𝑒 ⇓ 𝑣 · Implicitly, this is in fact a family of rules indexed over all pairs ( 𝐴, 𝐵 ) ∈ P of types. Forany such ( 𝐴, 𝐵 ) , we have 𝑒 ∈ 𝑆 𝑇 ( 𝑋 ) 𝐴 → 𝐵 , 𝑒 ∈ 𝑆 𝑇 ( 𝑋 ) 𝐴 , and 𝑒 𝑒 ∈ 𝑆 𝑇 ( 𝑋 ) 𝐵 . But theseare all Set -valued modules, while the transition module 𝑅 → 𝑆 𝑇 × 𝑇 is Set P -valued.This discrepancy is reminiscent of the one between pointed strong endofunctors andparametric modules. We thus refine MSlice ( C , 𝑋 ) as follows. Definition 8.9.
For all locally finitely presentable categories C and objects 𝑋 ∈ C , we definethe endofunctorial register Slice ( C , 𝑋 ) for the slice category C / 𝑋 as follows. is defined asfollows. Signatures:
A signature consists of: • a category D and a right adjoint 𝐸 : C → D ; • a metavariable object 𝑉 ∈ D ; • a list of premise morphisms ( 𝑉 𝑠 𝑖 −→ 𝐹 𝑖 𝑋 ) 𝑖 ∈ 𝑛 , where each 𝐹 𝑖 : C → D is a finitary functor,denoted by 𝑉 ® 𝑠 −→ Î 𝑖 𝐹 𝑖 𝑋 ; • a conclusion morphism 𝑉 𝑡 −→ 𝐸 ( 𝑋 ) . Semantics:
Let us consider any signature 𝑆 , consisting of 𝐸 : C → D and morphisms ( Î 𝑖 𝐹 𝑖 𝑋 ® 𝑠 ←− 𝑉 𝑡 −→ 𝐸 ( 𝑋 )) . 𝑆 induces a functor Σ 𝑆 : C / 𝑋 → D / 𝐸 ( 𝑋 ) mapping any 𝑌 𝑝 −→ 𝑋 to 𝑌 ′ → 𝑉 𝑡 −→ 𝐸 ( 𝑋 ) , where 𝑌 ′ denotes the pullback 𝑌 ′ Î 𝑖 𝐹 𝑖 ( 𝑌 ) 𝑉 Î 𝑖 𝐹 𝑖 ( 𝑋 ) ® 𝑠 Î 𝑖 𝐹 𝑖 ( 𝑝 ) A model is a morphism 𝑝 : 𝑌 → 𝑋 equipped with a map 𝑘 making the following trianglecommute. 𝑌 ′ 𝐸 ( 𝑌 ) 𝐸 ( 𝑋 ) 𝑘 Σ 𝑆 ( 𝑌 , 𝑝 ) 𝐸 ( 𝑝 ) A morphism of models ( 𝑌 , 𝑝 ) → (
𝑍, 𝑞 ) is a morphism 𝑓 in C / 𝑋 making the followingsquare commute. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 35 𝑌 ′ 𝐸 ( 𝑌 ) 𝑍 ′ 𝐸 ( 𝑍 ) 𝑘 𝑌 𝑓 ′ 𝑘 𝑍 𝐸 ( 𝑓 ) Validity proof:
Letting 𝐽 denote the left adjoint to 𝐸 , model structure on any 𝑝 : 𝑌 → 𝑋 amounts to a map ℎ making the following triangle commute, 𝐽 ( 𝑌 ′ ) 𝑌𝑋 ℎ Ÿ Σ 𝑆 ( 𝑌 , 𝑝 ) 𝑝 where e − denotes transposition. Otherwise said, model structure is equivalent to algebrastructure for the composite C / 𝑋 Σ 𝑆 −−→ D / 𝐸 ( 𝑋 ) e − −→ C / 𝑋 .The transposition functor e − is cocontinuous, because colimits in slice categories are com-puted on domains, on which it acts like the left adjoint 𝐽 . The candidate register is thusendofunctorial as claimed. Example 8.10.
Let us now treat the big-step 𝛽 -rule, rectifying Example 8.8. For all types 𝐴 and 𝐵 , we define the following rule: • we take D = 𝑇 - Mod 𝑓 ( Set ) and 𝐸 : 𝑇 - Mod 𝑓 ( Set S ) → 𝑇 - Mod 𝑓 ( Set ) to be pointwiseevaluation at 𝐵 , which is indeed right adjoint to (−) · y 𝐵 (recalling (10.1)); • we further take 𝑉 : = ( 𝑆 𝑇 ) 𝐴 → 𝐵 × ( 𝑆 𝑇 ) 𝐴 × ( 𝑆 𝑇 ) ( 𝐴 ) 𝐵 × 𝑇 𝐵 × 𝑇 𝐴 . as metavariable object; • we have three premises 𝑉 → 𝑆 𝑇 × 𝑆 𝑇 , which, at any 𝑋 ∈ Set P , respectively map any ( 𝑒 , 𝑒 , 𝑒 , 𝑤, 𝑣 ) ∈ 𝑉 ( 𝑋 ) to: – ( 𝑒 , 𝜆 𝐴,𝐵 ( 𝑒 )) , – ( 𝑒 , 𝑤 ) , and – ( 𝑒 [ 𝑤 ] , 𝑣 ) ; • the conclusion maps any such ( 𝑒 , 𝑒 , 𝑒 , 𝑤, 𝑣 ) ∈ 𝑉 ( 𝑋 ) to ( app 𝐴,𝐵 ( 𝑒 , 𝑒 ) , 𝑣 ) .Using the notation of § Notation 8.11.
We abbreviate
Slice ( 𝑇 - Mod 𝑓 ( Set S ) , 𝑆 𝑇 × 𝑆 𝑇 ) to Rule ( 𝑇 , 𝑆 , 𝑆 ) , andsimilarly for SSlice ( 𝑇 - Mod 𝑓 ( Set S ) , 𝑆 𝑇 × 𝑆 𝑇 ) and MSlice ( 𝑇 - Mod 𝑓 ( Set S ) , 𝑆 𝑇 × 𝑆 𝑇 ) . Using Definition 5.30, we obtain the register
Rule ∗ ( 𝑇 , 𝑆 , 𝑆 ) for 𝑇 - Mod 𝑓 ( Set S )/ 𝑆 𝑇 × 𝑆 𝑇 , whose signatures are families of signatures in Rule ( 𝑇 , 𝑆 , 𝑆 ) .8.4. A format for displaying signatures in rule-based registers.
In all of our exam-ples of signatures in
SRule ( 𝑇 , 𝑆 , 𝑆 ) , MRule ( 𝑇 , 𝑆 , 𝑆 ) , or Rule ( 𝑇 , 𝑆 , 𝑆 ) , the metavariableobject 𝑉 is a functor to Set . In this case, we adopt the following notational conventions. • For each premise or conclusion 𝑉 → 𝑊𝑥 ↦→ 𝐸 of a rule, we write 𝑥 : 𝑉 ⊢ 𝐸 : 𝑊 . • Furthermore, we organise the premises and conclusion as usual: 𝑥 : 𝑉 ⊢ 𝐸 : 𝑊 . . . 𝑥 : 𝑉 ⊢ 𝐸 𝑛 : 𝑊 𝑛 𝑥 : 𝑉 ⊢ 𝐸 : 𝑊 , or just 𝐸 . . . 𝐸 𝑛 𝐸 when the rest may be inferred from context.Moreover, in our examples 𝑀 = 𝑆 𝑇 × 𝑆 𝑇 , so each element 𝐸 is in fact a pair ( 𝐿, 𝑅 ) ,which we generally denote with an arrow, e.g., by 𝐿 { 𝑅 , 𝐿 → 𝑅 ,.... Example 8.12.
The big-step 𝛽 -rule from Example 8.10 reads as follows. 𝑒 { 𝜆 𝐴,𝐵 ( 𝑒 ) 𝑒 { 𝑤 𝑒 [ 𝑤 ] { 𝑣 app 𝐴,𝐵 ( 𝑒 , 𝑒 ) { 𝑣 Remark 8.13.
The module 𝑉 is often a product and thus 𝑥 is a tuple. Remark 8.14 ([7]) . In practice, there are several choices for building the transition ruleout of such a schematic presentation, depending on the order of metavariables. This orderis irrelevant: all interpretations yield isomorphic semantics, in the obvious sense.
Remark 8.15.
This format could be generalised to any metavariable object, by using theinternal language of categories.9.
Registers for transition monads
In the first subsection, we organise transition monads into categories, and in the secondone, we sketch their “prof-irrelevant” counterparts. We present our registers in the finalsubsection.9.1.
Categories of transition monads.
For the category of transition monads over afixed triple ( 𝑇 , 𝑆 , 𝑆 ) , we take the slice category of 𝑇 -modules alluded to earlier. Then, wewrap together these ‘little’ slice categories into the category TrMnd P , S of transition monads. Definition 9.1.
For any sets P and S , finitary monad 𝑇 over Set P , and finitary functors 𝑆 , 𝑆 : Set P → Set S , let TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) denote the slice category 𝑇 - Mod 𝑓 ( Set S )/ 𝑆 𝑇 × 𝑆 𝑇 .And for any sets P and S , we let TrMnd P , S : = Í 𝑇 ,𝑆 ,𝑆 TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) . Remark 9.2.
Reduction monads of [7] correspond to the case when 𝑆 = 𝑆 = 𝐼𝑑 , butcontrary to the present work, morphisms there can live between reduction monads withdifferent underlying monads. Although our present choice makes our signatures simpler (inparticular for the transition structure), it reduces the scope of the recursion principle, sinceit enforces that all models of a signature have the same underlying monad.9.2. Categories of irrelevant transition monads.
Although we prefer focusing on thisproof-relevant variant, we can define a proof-irrelevant one.
Proposition 9.3.
Let
ITrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) denote the full subcategory of transition mon-ads h src , tgt i : 𝑅 → 𝑆 𝑇 × 𝑆 𝑇 such that h src , tgt i is a pointwise inclusion. Then, the em-bedding 𝑈 𝑇 ,𝑆 ,𝑆 : ITrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) ↩ → TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) is reflective. Consequently,letting ITrMnd P , S : = Í 𝑇 ,𝑆 ,𝑆 ITrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) , the induced embedding ITrMnd P , S ↩ → TrMnd P , S is also reflective. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 37
Proof.
The left adjoint 𝐿 : TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) → ITrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) maps a transitionmonad 𝜕 : 𝑅 → 𝑆 𝑇 × 𝑆 𝑇 to the monomorphism 𝑅 ↩ → 𝑆 𝑇 × 𝑆 𝑇 obtained from the (strongepi)-mono factorisation of 𝜕 . Then, the natural bijection TrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) ( 𝑇 , 𝑈𝑇 ) ≃ ITrMnd P , S ( 𝑇 , 𝑆 , 𝑆 ) ( 𝐿𝑇 , 𝑇 ) follows from the lifting property of strong epimorphisms.9.3. The registers
TrModMnd .Definition 9.4.
We define the register
TrModMnd P , S for the category TrMnd P , S as follows. Signatures:
A signature consists of • a signature Σ 𝑇 of ModMnd ( P ) , specifying a finitary monad 𝑇 on Set P , • signatures Σ and Σ of PModFun ( P , S ) , specifying functors 𝑆 , 𝑆 : Set P → Set S , • a signature Σ Trans of Rule ∗ ( 𝑇 , 𝑆 , 𝑆 ) . Semantics:
The abstract signature associated to a signature ( Σ 𝑇 , Σ , Σ , Σ Trans ) is Σ Trans -alg U Σ Trans −−−−−−→ 𝑇 - Mod 𝑓 / 𝑆 𝑇 × 𝑆 𝑇 ↩ → TrMnd P , S . Validity proof:
By validity of
Rule ∗ ( 𝑇 , 𝑆 , 𝑆 ) . Remark 9.5.
Thanks to Definition 5.18, we then get a register for the proof-irrelevanttransition monads of Proposition 9.3 from the register
TrModMnd .10.
Computing initial algebras in the presence of equations
In the previous sections, we have introduced a few registers for monads and functors, whosevalidity (and monadicity) proofs have been deferred. In this section, we deal with theseproofs, and more. Indeed, in applications, it will be important to be able to compute initialalgebras of signatures in these registers. Or even better, for monadic registers, to computethe monads induced by forgetful functors.For endofunctorial registers, this is easy, thanks to the well-known characterisation ofthe free monad generated by an endofunctor. Here below, we characterise the underlyingmonad and initial algebra for suitable signatures in our registers featuring equations, namelythe registers • ES C of equational systems (Definition 5.37), • ModMnd ( P ) of equational modular signatures (Definition 6.16), and • SPModFun ( P ) of equational premodular signatures (Definition 7.8).For this, we introduce a refinement of finitariness, called friendliness , in § § As mentioned before, the category of finitary
Set -valued 𝑇 -modules is a presheaf category, and thus has(strong epi)-mono factorisations. Reflexive coequalisers of friendly monoids.
The monads underlying our regis-ters with equations will all easily be proved to be coequalisers 𝑇 E ⇒ 𝑇 D ։ 𝑇 A of finitarymonads on some category C . Our goal is to delineate sufficient conditions under which suchcoequalisers may be computed pointwise. Roughly, this will work if both monads 𝑇 E and 𝑇 D preserve reflexive coequalisers. Because (finitary) monads are monoids in the categoryof (finitary) endofunctors, we can even state the result in this more general setting – thiswill be helpful when we generalise it (see Lemma 10.15 below). Preservation of reflexivecoequalisers plays a fundamental role in the study of algebraic theories [3]. As we will useit a lot, let us give it a name. Definition 10.1.
A functor is friendly when it is finitary and preserves reflexive coequalis-ers.
Remark 10.2.
By [3, Theorem 7.7], when the considered categories are cocomplete, thisis equivalent to preserving all sifted colimits.
Definition 10.3.
An object 𝑋 of a monoidal category is ⊗ -friendly when the functor 𝑋 ⊗ − is friendly. Proposition 10.4.
In any endofunctor category [ C , C ] 𝑓 , viewed as monoidal for the com-position tensor product, because colimits of functors are computed pointwise, a finitary end-ofunctor is friendly iff it is ⊗ -friendly. Notation 10.5.
By the proposition, in all of our use cases, ⊗ -friendliness and friendlinessare synonymous, hence we use the latter for simplicity. Definition 10.6.
A monoidal category is friendly when it is convenient and all objectsare friendly.
Example 10.7. • The composition monoidal structure on finitary endofunctors on a locally finitely pre-sentable category is convenient, though not friendly in general. By Proposition 10.4, thefriendly objects are precisely the endofunctors preserving reflexive coequalisers. • On categories of the form
Set P for some set P , though, by [3, Corollary 6.30], all finitaryendofunctors are friendly, hence [ Set P , Set P ] 𝑓 is friendly. Theorem 10.8.
For any convenient monoidal category C , the forgetful functor Mon ( C ) → C creates reflexive coequalisers of friendly objects. More concretely, given a reflexive pair 𝑋 ⇒ 𝑌 of monoid morphisms, if 𝑋 and 𝑌 are friendly, then the coequaliser in C lifts uniquelyto a cocone of monoids, which is again a coequaliser.Proof. Monoids are the algebras of the “free monoid” monad, say (−) ★ , and a forgetful func-tor from monad algebras always creates those colimits that the monad preserves (Propo-sition 2.18). It thus suffices to show that (−) ★ preserves reflexive coequalisers of friendlyobjects.Let thus 𝑋 ⇒ 𝑌 ։ 𝑍 denote a reflexive coequaliser, with 𝑋 and 𝑌 friendly. Then,because the tensor preserves colimits on the left, 𝑍 is again friendly. Furthermore, 𝑍 ★ is theinitial algebra of the endofunctor 𝐻 𝑍 = 𝐼 + 𝑍 ⊗ − . Now 𝐻 𝑍 is the coequaliser of 𝐻 𝑋 ⇒ 𝐻 𝑌 ,i.e., ( 𝐼 + 𝑋 ⊗ −) ⇒ ( 𝐼 + 𝑌 ⊗ −) .Now, 𝐻 𝑋 , 𝐻 𝑌 , and 𝐻 𝑍 are friendly so by induction we prove that 𝐻 𝑛𝑋 ( ) ⇒ 𝐻 𝑛𝑌 ( ) ։ 𝐻 𝑛𝑍 ( ) is again a reflexive coequaliser (using [12, Lemma 4.2]). By interchange of colimits,we obtain that 𝑋 ★ ⇒ 𝑌 ★ ։ 𝑍 ★ is also an coequaliser, as desired. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 39
Initial algebras for equational systems.
In this section, we want to apply the pre-vious theorem to characterise the induced monad and initial algebra for equational systems.But first, as promised in § Proposition 10.9.
There exists a bijective correspondence E ↦→ E ′ between equationalsystems in our sense and in Fiore and Hur’s.Furthermore, for any equational system E = ( C : Σ ⊲ Γ ⊢ 𝐿 = 𝑅 ) , the forgetful functor E -alg → C is isomorphic to Fiore and Hur’s E ′ -alg → C . Remark 10.10.
In fact, Fiore and Hur [23] give a slightly more general notion where C maynot be locally finitely presentable, and Σ and Γ may not be finitary, with a more complexconstruction of free E -algebras. Proof.
Let us recall that a
Fiore-Hur equational system consists of a locally finitelypresentable category C , finitary endofunctors Σ and Γ , and functors 𝐿 ′ , 𝑅 ′ : Σ -alg → Γ -algover C . The category E ′ -alg of models for a Fiore-Hur equational system E ′ = ( C : Σ ⊲ Γ ⊢ 𝐿 ′ = 𝑅 ′ ) is the equaliser in CAT of 𝐿 ′ and 𝑅 ′ .Now, for any equational system E = ( C : Σ ⊲ Γ ⊢ 𝐿 = 𝑅 ) , the monad morphism ˜ 𝐾 : ( Σ + Γ ) ★ → Σ ★ induced by any metaterm 𝐾 : Γ → Σ ★ is mapped by Street’s correspondenceProposition 2.27 to a morphism ˇ˜ 𝐾 : Σ -alg → ( Σ + Γ ) -alg of monadic functors over C , andthus, postcomposing with ( Σ + Γ ) -alg → Γ -alg, to a morphism 𝐾 ′ : Σ -alg → Γ -alg in Monadic 𝑓 / C . Thus, E gives rise to the Fiore-Hur equational system E ′ = ( C : Σ ⊲ Γ ⊢ 𝐿 ′ = 𝑅 ′ ) .This correspondence is bijective, which proves the first statement.Finally, by construction, a Σ -algebra 𝑋 is an E -algebra iff 𝐿 ′ 𝑋 = 𝑅 ′ 𝑋 , so that E -alg is theequaliser in CAT of 𝐿 ′ , 𝑅 ′ : Σ -alg → Γ -alg, as desired.Let us now return to monadicity and characterising free algebras for equational systems.In order to be able to apply Theorem 10.8, we should show that the monads 𝑇 D and 𝑇 E underlying the relevant parallel pair D ⇒ E in Monadic 𝑓 / C are indeed friendly. What helpsus here is that these monads are free on an friendly endofunctor, as we now show. We againstate this in the abstract context of a convenient monoidal category. Proposition 10.11.
In any convenient monoidal category, the free monoid on a friendlyobject is again friendly.Proof.
We in fact prove the more general result that if 𝑋 ∈ C preserves D -colimits for agiven category D , in the sense that 𝑋 ⊗ − preserves D -colimits, then so does 𝑋 ★ . Indeed,let 𝑋 ∈ C preserve D -colimits. Then, 𝑋 ★ is the initial algebra of the (finitary) endofunctor 𝐻 = 𝐼 + 𝑋 ⊗ − , so it is obtained as the colimit of the chain 𝐻 𝑛 ( ) = 𝐻 ◦ . . . ◦ 𝐻 ( ) . Now,objects preserving D -colimits are easily seen to be stable under colimits, so it is enough toshow that 𝐻 𝑛 ( ) preserves D -colimits, for each 𝑛 . It is cleary the case for 𝑛 =
0. Suppose itis the case for 𝐻 𝑛 ( ) , and let colim 𝑖 𝑍 𝑖 be a D -colimit. Then we have: 𝐻 𝑛 + ( ) ⊗ colim 𝑖 𝑍 𝑖 = 𝐻 ( 𝐻 𝑛 ( )) ⊗ colim 𝑖 𝑍 𝑖 = ( 𝐼 + 𝑋 ⊗ 𝐻 𝑛 ( )) ⊗ colim 𝑖 𝑍 𝑖 (cid:27) colim 𝑖 𝑍 𝑖 + 𝑋 ⊗ 𝐻 𝑛 ( ) ⊗ colim 𝑖 𝑍 𝑖 (cid:27) colim 𝑖 𝑍 𝑖 + colim 𝑖 ( 𝑋 ⊗ 𝐻 𝑛 ( ) ⊗ 𝑍 𝑖 ) (cid:27) colim 𝑖 ( 𝑍 𝑖 + 𝑋 ⊗ 𝐻 𝑛 ( ) ⊗ 𝑍 𝑖 ) (cid:27) colim 𝑖 ( ( 𝐼 + 𝑋 ⊗ 𝐻 𝑛 ( )) ⊗ 𝑍 𝑖 ) (cid:27) colim 𝑖 ( 𝐻 𝑛 + ( ) ⊗ 𝑍 𝑖 ) . In particular, we obtain:
Theorem 10.12.
Let E = ( C : Σ ⊲ Γ ⊢ 𝐿 = 𝑅 ) be any equational system. Then: (i) The forgetful functor E -alg → C is finitary monadic. (ii) The finitary monad E ★ underlying the forgetful functor E -alg → C is the coequaliser(in Mnd 𝑓 ( C ) ) of ˜ 𝐿, ˜ 𝑅 : ( Σ + Γ ) ★ ⇒ Σ ★ .Furthermore, if Σ and Γ are friendly (in particular when C is Set P for some set P ), wehave: (iii) The above coequaliser E ★ is created by the forgetful functor Mnd 𝑓 ( C ) → [ C , C ] 𝑓 (hence computed pointwise). (iv) The initial E -algebra is the coequaliser of ˜ 𝐿 , ˜ 𝑅 : ( Σ + Γ ) ★ ( ) ⇒ Σ ★ ( ) ,with its canonical Σ -algebra structure.Proof. By Proposition 10.9, recalling notation from its proof, the category E -alg is theequaliser of the non-reflexive pair below left. Σ -alg Γ -alg 𝐿 ′ 𝑅 ′ Σ -alg ( Σ + Γ ) -alg , ˇ˜ 𝐿 ˇ˜ 𝑅 which already entails monadicity by Corollary 2.32. But it is also an equaliser of the reflexivepair above right. The rest thus follows from Theorem 10.8 using Proposition 10.11. Example 10.13.
Let us recall Example 5.33, where we introduced an equational systemwhose algebras are sets equipped with an associative binary operation. Because we knowhow to compute coequalisers in sets, the theorem says that the free algebra on any 𝑋 ∈ Set is obtained by quotienting the free Σ -algebra Σ ★ ( 𝑋 ) , obtained by freely adding a binaryoperation to 𝑋 , under the following relation ∼ . We first construct the free ( Σ + Γ ) -algebra ( Σ + Γ ) ★ ( 𝑋 ) on 𝑋 , obtained by freely adding a binary operation and a ternary operation, say 𝑓 , to 𝑋 . We then define two maps 𝐿, 𝑅 : ( Σ + Γ ) ★ ( 𝑋 ) → Σ ★ ( 𝑋 ) , by recursively interpreting 𝑓 ( 𝑥, 𝑦, 𝑧 ) as ( 𝑥 + 𝑦 ) + 𝑧 , resp. 𝑥 + ( 𝑦 + 𝑧 ) . We finally define 𝑥 ∼ 𝑦 iff 𝑥 = 𝐿 ( 𝑧 ) and 𝑦 = 𝑅 ( 𝑧 ) forsome 𝑧 ∈ ( Σ + Γ ) ★ ( 𝑋 ) .10.3. Initial algebras for monoidal equational systems.
In this section, we charac-terise the underlying monad and initial algebra of monoidal equational systems, under mildadditional hypotheses.
Theorem 10.14.
Let E = ( C : Σ ⊲ Γ ⊢ 𝐿 = ⊗ 𝑅 ) be any monoidal equational system. Then: (i) The forgetful functor E -alg → Mon ( C ) is finitary monadic. (ii) The finitary monad E ★ underlying the forgetful functor E -alg → C is the coequaliserof 𝐿, 𝑅 : ( Σ + Γ ) ★ ⇒ Σ ★ in Mnd 𝑓 ( C ) , where we recall that, for any finitary, pointedstrong endofunctor 𝐹 , 𝐹 ★ denotes the “free 𝐹 -monoid” monad on C .If C , Σ , and Γ are friendly (which holds in particular when C is Set P for some set P ), then: (iii) The above coequaliser E ★ is created by the forgetful functor Mnd 𝑓 ( C ) → [ C , C ] 𝑓 ,i.e., for any 𝑋 ∈ C , E ★ ( 𝑋 ) is the coequaliser of 𝐿 𝑋 , 𝑅 𝑋 : ( Σ + Γ ) ★ ( 𝑋 ) ⇒ Σ ★ ( 𝑋 ) ,equipped with its canonical Σ -monoid structure. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 41 (iv)
The initial E -algebra is the coequaliser of 𝐿 , 𝑅 : ( Σ + Γ ) ∗ ( id ) ⇒ Σ ∗ ( id ) , equippedwith its canonical Σ -monoid structure.Proof. This will follow from Theorem 10.8 if we prove that both monads ( Σ + Γ ) ★ and Σ ★ are friendly (noting that the initial object is friendly in any convenient category). It thussuffices to show that both monads are friendly, which follows from the next lemma. Lemma 10.15.
For any finitary, pointed strong endofunctor 𝐹 on a friendly monoidalcategory C , if 𝐹 is friendly, then so is the “free 𝐹 -monoid” monad 𝐹 ★ .Proof. This is a direct generalisation of the proof of Proposition 10.11 (which correspondsto the case 𝐹 = ∅ ), using the fact that the free 𝐹 -monoid monad maps 𝑋 to the initialalgebra of 𝐴 ↦→ 𝐼 + 𝑋 ⊗ 𝐴 + 𝐹 ( 𝐴 ) , as recalled in Definition 5.48.10.4. Initial algebras for
ModMnd ( P ) . In this section, we characterise the underlyingmonad and initial algebra of equational modular signatures, i.e., signatures of the register
ModMnd ( P ) . We first establish monadicity for the register SModFun ( P ) without equa-tions, by compiling (in the sense of Definition 5.12) to the register PSEF [ Set P , Set P ] 𝑓 ofpointed strong endofunctors on [ Set P , Set P ] 𝑓 . We then extend this to the whole register ModMnd ( P ) , and finally deal with the characterisation, using friendliness.Let us first show that for any modular signature 𝑆 the forgetful functor 𝑆 -alg → Mnd 𝑓 ( Set P ) is monadic. For this, we recall that for all 𝑟 ∈ P there is an adjunction [ Set P , Set ] 𝑓 ⊥ [ Set P , Set P ] 𝑓 , (−) · y 𝑟 (−) 𝑟 where • y 𝑟 : Set P denotes the family with a single element over 𝑟 ∈ P , and • the left adjoint maps any 𝐹 : Set P → Set to the endofunctor ( 𝑋 ∈ Set P ) ↦→ 𝐹 ( 𝑋 ) · y 𝑟 , i.e., ( 𝐹 ( 𝑋 ) · y 𝑟 ) ( 𝑟 ) = 𝐹 ( 𝑋 ) and ( 𝐹 ( 𝑋 ) · y 𝑟 ) ( 𝑝 ) = ∅ when 𝑝 ≠ 𝑟 .Indeed, we have a natural isomorphism 𝐹 ( 𝑋 ) · y 𝑟 → 𝐺 ( 𝑋 ) 𝐹 ( 𝑋 ) → 𝐺 ( 𝑋 ) ( 𝑟 ) ============================= · This adjunction straightforwardly lifts to an adjunction
Mod ( Set P , Set ) ⊥
Mod ( Set P , Set P ) . (−) · y 𝑟 (−) 𝑟 (10.1)So by this adjunction, given any elementary 𝑑 (cid:27) ( 𝐹 ◦ 𝑇 ) ( 𝑝 ,..., 𝑝 𝑛 ) and 𝑟 ∈ P , a 𝑇 -modulemorphism ( 𝐹 ◦ 𝑇 ) ( 𝑝 ,..., 𝑝 𝑛 ) → 𝑇 𝑟 is the same as a ( Set P -valued) 𝑇 -module morphism ( 𝐹 ◦ 𝑇 ) ( 𝑝 ,..., 𝑝 𝑛 ) · y 𝑟 → 𝑇 ,in which we recognise an algebra structure. Let us state this formally. Definition 10.16.
For any modular signature 𝑆 , we define its associated pointed strongendofunctor Σ 𝑆 on [ Set P , Set P ] 𝑓 as follows. • For any elementary 𝑑 (cid:27) ( 𝐹 ◦ Θ ) ( 𝑝 ,..., 𝑝 𝑛 ) and 𝑟 ∈ P , let Σ ( 𝑑,𝑟 ) ( 𝑃 ) = ( 𝐹 ◦ 𝑃 ) ( 𝑝 ,..., 𝑝 𝑛 ) · y 𝑟 . • For a family 𝑆 = ( 𝑑 𝑖 , 𝑟 𝑖 ) , let Σ 𝑆 = Í 𝑖 ∈ 𝐼 Σ ( 𝑑 𝑖 ,𝑟 𝑖 ) . Remark 10.17.
Explicitly, letting C = [ Set P , Set P ] 𝑓 , we have for any ( 𝑑, 𝑟 ) : Σ ( 𝑑,𝑟 ) ( 𝑃 ) ( 𝑋 ) : = ( 𝐹 ( 𝑃 ( 𝑋 + Í 𝑖 y 𝑝 𝑖 ))) · y 𝑟 ,with pointed strength given at 𝑃 ∈ C , 𝑄 ∈ id / C , and 𝑋 ∈ Set P by applying 𝐹 ( 𝑃 (−)) · y 𝑟 tothe obvious morphism 𝑄 ( 𝑋 ) + Í 𝑖 y 𝑝 𝑖 → 𝑄 ( 𝑋 + Í 𝑖 y 𝑝 𝑖 ) . Proposition 10.18.
The assignment 𝑆 ↦→ Σ 𝑆 defines a compilation SModFun ( P ) → PSEF [ Set P , Set P ] 𝑓 . More concretely, for any modular signature 𝑆 = ( 𝑑 𝑖 , 𝑟 𝑖 ) 𝑖 ∈ 𝐼 , there exists an isomorphism 𝑆 -alg (cid:27) Σ 𝑆 - Mon of categories over
Mnd 𝑓 ( Set P ) .Proof. The
Set -valued module morphisms 𝜌 𝑖 : 𝑑 𝑖 ( 𝑋 ) → 𝑋 𝑟 𝑖 correspond by adjunction (10.1)to Set P -valued module morphisms ˜ 𝜌 𝑖 : 𝑑 𝑖 ( 𝑋 ) · y 𝑟 𝑖 → 𝑋 , hence by copairing to one Σ 𝑚𝑜𝑑𝑆 -algebra structure Σ 𝑚𝑜𝑑𝑆 ( 𝑋 ) → 𝑋 (recalling Definition 5.42), and thus to Σ 𝑆 -monoid structureon 𝑋 . This correspondence extends straightforwardly to morphisms, hence defining thedesired functor 𝑆 -alg → Σ 𝑆 - Mon over
Mnd 𝑓 ( Set P ) . Since it is bijective, the functor is anisomorphism. Corollary 10.19.
For any modular signature 𝑆 , the forgetful functor 𝑆 -alg → Mnd 𝑓 ( Set P ) is monadic, and furthermore the free 𝑆 -algebra on an endofunctor 𝑋 ∈ [ Set P , Set P ] 𝑓 is thefree Σ 𝑆 -monoid Σ ★𝑆 ( 𝑋 ) , as characterised in Proposition 5.47.In particular, the initial 𝑆 -algebra is Σ ★𝑆 ( ) (cid:27) Σ ∗ 𝑆 ( id ) . We now want to show that, for any equational modular signature ( 𝑆, 𝐸 ) , the forgetfulfunctor ( 𝑆, 𝐸 ) -alg → Mnd 𝑓 ( Set P ) is monadic. For this, we show that ( 𝑆, 𝐸 ) -alg is anequaliser of finitary monadic functors over Mnd 𝑓 ( Set P ) and apply Corollary 2.32. Thestarting point for this is to create an additional operation 𝑉 → Θ 𝑝 for each 𝑆 -equation 𝐿, 𝑅 : 𝑉 → Θ 𝑝 , as follows. Definition 10.20.
For any equational modular signature ( 𝑆, 𝐸 ) with 𝐸 = ( 𝐿 𝑖 , 𝑅 𝑖 : 𝑉 𝑖 → Θ 𝑝 𝑖 ) 𝑖 ∈ 𝐼 , let 𝑆 𝐸 denote the modular signature ( 𝑉 𝑖 , 𝑝 𝑖 ) 𝑖 ∈ 𝐼 . We further let Σ 𝐸 : = Σ 𝑆 𝐸 denotethe corresponding pointed strong endofunctor (Definition 10.16).For any 𝑆 -algebra 𝑇 and 𝐿 : 𝑉 → Θ 𝑝 , 𝐿 𝑇 : 𝑉 ( 𝑇 ) → 𝑇 𝑝 induces ( 𝑉 , 𝑝 ) -algebra structureon 𝑇 . Thus, for any family 𝐸 = ( 𝐿 𝑖 , 𝑅 𝑖 : 𝑉 𝑖 → Θ 𝑝 𝑖 ) 𝑖 ∈ 𝐼 of 𝑆 -equations the families ( 𝐿 𝑖 ) 𝑇 and ( 𝑅 𝑖 ) 𝑇 induce 𝑆 𝐸 -algebra structures 𝐿 𝐸 ( 𝑇 ) and 𝑅 𝐸 ( 𝑇 ) on 𝑇 , which together form functors 𝐿 𝐸 , 𝑅 𝐸 : 𝑆 -alg → 𝑆 𝐸 -algover Mnd 𝑓 ( Set P ) . Clearly: Proposition 10.21.
For any equational modular signature ( 𝑆, 𝐸 ) , ( 𝑆, 𝐸 ) -alg is the equaliserin CAT of 𝐿 𝐸 and 𝑅 𝐸 . By Proposition 10.18, 𝐿 𝐸 and 𝑅 𝐸 induce functors 𝐿 ′ 𝐸 , 𝑅 ′ 𝐸 : Σ 𝑆 - Mon → Σ 𝐸 - Mon over
Mnd 𝑓 ( Set P ) making the following square commute serially. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 43 𝑆 -alg 𝑆 𝐸 -alg Σ 𝑆 - Mon Σ 𝐸 - Mon (cid:27) (cid:27) 𝐿 𝐸 𝑅 𝐸 𝐿 ′ 𝐸 𝑅 ′ 𝐸 By Remark 5.50, 𝐿 ′ 𝐸 and 𝑅 ′ 𝐸 yield monad morphisms 𝐿 ′′ 𝐸 , 𝑅 ′′ 𝐸 : ( Σ + Γ ) ★ ⇒ Σ ★ with theobvious section, hence a monoidal equational system E 𝑆,𝐸 . This readily entails:
Corollary 10.22.
The assignment ( 𝑆, 𝐸 ) ↦→ E 𝑆,𝐸 : = ( Σ 𝑆 ⊲ Σ 𝐸 ⊢ 𝐿 ′′ 𝐸 = ⊗ 𝑅 ′′ 𝐸 ) induces a compilation ModFun ( P , S ) → MES [ Set P , Set P ] 𝑓 . More concretely, for any equational modular signature ( 𝑆, 𝐸 ) , we have an isomorphism ( 𝑆, 𝐸 ) -alg (cid:27) E 𝑆,𝐸 - Mon of categories over
Mnd 𝑓 ( Set P ) . As a result, we readily obtain by Theorem 10.14:
Corollary 10.23.
Let ( 𝑆, 𝐸 ) be any equational modular signature ( 𝑆, 𝐸 ) . Then: (i) The forgetful functor ( 𝑆, 𝐸 ) -alg → Mnd 𝑓 ( Set P ) is monadic. (ii) The finitary monad ( 𝑆, 𝐸 ) ★ underlying the forgetful functor ( 𝑆, 𝐸 ) -alg → [ Set P , Set P ] 𝑓 is the reflexive coequaliser in Mnd 𝑓 ( [ Set P , Set P ] 𝑓 ) of 𝐿 ′′ 𝐸 , 𝑅 ′′ 𝐸 : ( Σ 𝑆 + Σ 𝐸 ) ★ ⇒ Σ ★𝑆 . (iii) The above coequaliser is created by the forgetful functor
Mnd 𝑓 ( [ Set P , Set P ] 𝑓 ) → [[ Set P , Set P ] 𝑓 , [ Set P , Set P ] 𝑓 ] 𝑓 (hence computed pointwise). (iv) The initial ( 𝑆, 𝐸 ) -algebra is the coequaliser of ( 𝐿 ′′ 𝐸 ) , ( 𝑅 ′′ 𝐸 ) : ( Σ 𝑆 + Σ 𝐸 ) ∗ ( id ) ⇒ Σ ∗ 𝑆 ( id ) ,equipped with its canonical 𝑆 -algebra structure.Proof. In this case, all objects of [ Set P , Set P ] 𝑓 are friendly by [3, Corollary 6.30].10.5. Initial algebras for
PModFun ( P , S ) . In this section, we prove monadicity of theregister
PModFun ( P , S ) of equational premodular signatures, and characterise underlyingmonads and initial algebras. For this, we proceed essentially as in the previous section, butmore simply since the intricacies related to Σ -monoids do not arise. We are thus able tocompile • SPModFun ( P , S ) to the register EF [ Set P , Set S ] 𝑓 of endofunctors on [ 𝑆𝑒𝑡 P , Set S ] 𝑓 , and • PModFun ( P , S ) to the register ES [ Set P , Set S ] 𝑓 of equational systems over [ Set P , Set S ] 𝑓 . Definition 10.24.
For any premodular signature 𝑆 , we define its associated endofunctor Σ 𝑆 on [ Set P , Set S ] 𝑓 as follows. • For any elementary 𝑑 (cid:27) ( 𝐹 ◦ h I , Θ i) ( 𝑝 ,..., 𝑝 𝑛 ) and 𝜎 ∈ S , let Σ ( 𝑑,𝜎 ) ( 𝑃 ) = ( 𝐹 ◦ h id , 𝑃 i) ( 𝑝 ,..., 𝑝 𝑛 ) · y 𝜎 . • For a family 𝑆 = ( 𝑑 𝑖 , 𝜎 𝑖 ) , let Σ 𝑆 : = Í 𝑖 ∈ 𝐼 Σ ( 𝑑 𝑖 ,𝜎 𝑖 ) . Remark 10.25.
Explicitly, we have for any ( 𝑑, 𝜎 ) : Σ ( 𝑑,𝜎 ) ( 𝑃 ) ( 𝑋 ) : = ( 𝐹 ( 𝑋 + Í 𝑖 y 𝑝 𝑖 , 𝑃 ( 𝑋 + Í 𝑖 y 𝑝 𝑖 ))) · y 𝜎 . Proposition 10.26.
The assignment 𝑆 ↦→ Σ 𝑆 defines a compilation SPModFun ( P , S ) → EF [ Set P , Set S ] 𝑓 . More concretely, for any premodular signature 𝑆 = ( 𝑑 𝑖 , 𝜎 𝑖 ) 𝑖 ∈ 𝐼 , there exists an isomorphism 𝑆 -alg (cid:27) Σ 𝑆 -alg of categories over [ Set P , Set S ] 𝑓 .Proof. As in the proof of Proposition 10.18, by the adjunction
PMod ( P , S , Set ) ⊥
PMod ( P , S , Set S ) , (−) · y 𝑟 (−) 𝑟 the Set -valued premodule morphisms 𝜌 𝑖 : 𝑑 𝑖 ( 𝑋 ) → 𝑋 𝜎 𝑖 correspond by adjunction (10.1)to Set S -valued module morphisms ˜ 𝜌 𝑖 : 𝑑 𝑖 ( 𝑋 ) · y 𝜎 𝑖 → 𝑋 , hence by copairing to Σ 𝑆 -algebrastructure Σ 𝑆 ( 𝑋 ) → 𝑋 . This correspondence extends straightforwardly to morphisms, hencedefining the desired functor 𝑆 -alg → Σ 𝑆 -alg over [ Set P , Set S ] 𝑓 . Since it is bijective, thefunctor is an isomorphism. Corollary 10.27.
For any premodular signature 𝑆 , the forgetful functor 𝑈 𝑆 : 𝑆 -alg →[ Set P , Set S ] 𝑓 is monadic. Furthermore, the free 𝑆 -algebra on an endofunctor 𝑋 ∈ [ Set P , Set S ] 𝑓 is the free Σ 𝑆 -algebra Σ ★𝑆 ( 𝑋 ) , as characterised in Proposition 5.27. We now want to show that, for any equational modular signature ( 𝑆, 𝐸 ) , the forgetfulfunctor ( 𝑆, 𝐸 ) -alg → [ Set P , Set S ] 𝑓 is monadic. For this, we could exhibit ( 𝑆, 𝐸 ) -alg as anequaliser of finitary monadic functors over [ Set P , Set S ] 𝑓 and apply Corollary 2.32. But infact, perhaps more conveniently, we also may compile into equational systems.The starting point for this is to create an additional operation 𝑉 → Θ 𝑝 for each 𝑆 -equation 𝐿, 𝑅 : 𝑉 → Θ 𝑝 , as follows. Definition 10.28.
For any equational premodular signature ( 𝑆, 𝐸 ) with 𝐸 = ( 𝐿 𝑖 , 𝑅 𝑖 : 𝑉 𝑖 → Θ 𝑝 𝑖 ) 𝑖 ∈ 𝐼 , let 𝑆 𝐸 denote the premodular signature ( 𝑉 𝑖 , 𝑝 𝑖 ) 𝑖 ∈ 𝐼 . We further let Σ 𝐸 : = Σ 𝑆 𝐸 denotethe corresponding endofunctor (Definition 10.16).For any 𝑆 -algebra 𝑇 and 𝐿 : 𝑉 → Θ 𝑝 , 𝐿 𝑇 : 𝑉 ( 𝑇 ) → 𝑇 𝑝 induces ( 𝑉 , 𝑝 ) -algebra structureon 𝑇 . Thus, for any family 𝐸 = ( 𝐿 𝑖 , 𝑅 𝑖 : 𝑉 𝑖 → Θ 𝑝 𝑖 ) 𝑖 ∈ 𝐼 of 𝑆 -equations the families ( 𝐿 𝑖 ) 𝑇 and ( 𝑅 𝑖 ) 𝑇 induce 𝑆 𝐸 -algebra structures 𝐿 𝐸 ( 𝑇 ) and 𝑅 𝐸 ( 𝑇 ) on 𝑇 , which together form functors 𝐿 𝐸 , 𝑅 𝐸 : 𝑆 -alg → 𝑆 𝐸 -algover [ Set P , Set S ] 𝑓 . Clearly, this shows: Proposition 10.29.
For any equational modular signature ( 𝑆, 𝐸 ) , ( 𝑆, 𝐸 ) -alg is the equaliserin CAT of 𝐿 𝐸 and 𝑅 𝐸 . By Proposition 10.26, 𝐿 𝐸 and 𝑅 𝐸 induce functors 𝐿 ′ 𝐸 , 𝑅 ′ 𝐸 : Σ 𝑆 -alg → Σ 𝐸 -alg over [ Set P , Set S ] 𝑓 making the following square commute serially. ODULES OVER MONADS AND OPERATIONAL SEMANTICS 45 𝑆 -alg 𝐸 -alg Σ 𝑆 -alg Σ 𝐸 -alg (cid:27) (cid:27) 𝐿 𝐸 𝑅 𝐸 𝐿 ′ 𝐸 𝑅 ′ 𝐸 This readily entails:
Corollary 10.30.
The assignment ( 𝑆, 𝐸 ) ↦→ E 𝑆,𝐸 : = ( Σ 𝑆 ⊲ Σ 𝐸 ⊢ 𝐿 ′ 𝐸 = 𝑅 ′ 𝐸 ) induces a compilation PModFun ( P , S ) → ES [ Set P , Set S ] 𝑓 . More concretely, for any equational premodular signature ( 𝑆, 𝐸 ) , we have an isomorphism ( 𝑆, 𝐸 ) -alg (cid:27) E 𝑆,𝐸 -alg of categories over [ Set P , Set S ] 𝑓 . As a result, we readily obtain by Theorem 10.12:
Corollary 10.31.
Let ( 𝑆, 𝐸 ) be any equational premodular signature ( 𝑆, 𝐸 ) . Then: (i) The forgetful functor ( 𝑆, 𝐸 ) -alg → [ Set P , Set S ] 𝑓 is monadic. (ii) The finitary monad ( 𝑆, 𝐸 ) ★ underlying the forgetful functor ( 𝑆, 𝐸 ) -alg → [ Set P , Set S ] 𝑓 is the reflexive coequaliser in Mnd 𝑓 ( [ Set P , Set S ] 𝑓 ) of 𝐿 ′ 𝐸 , 𝑅 ′ 𝐸 : ( Σ 𝑆 + Σ 𝐸 ) ★ ⇒ Σ ★𝑆 . (iii) The above coequaliser is created by the forgetful functor
Mnd 𝑓 ( [ Set P , Set S ] 𝑓 ) →[[ Set P , Set S ] 𝑓 , [ Set P , Set S ] 𝑓 ] 𝑓 (hence computed pointwise). (iv) The initial ( 𝑆, 𝐸 ) -algebra is the coequaliser of ( 𝐿 ′ 𝐸 ) , ( 𝑅 ′ 𝐸 ) : ( Σ 𝑆 + Σ 𝐸 ) ★ ( ) ⇒ Σ ★𝑆 ( ) ,equipped with its canonical 𝑆 -algebra structure. Applications
In this section, we recast the announced languages as transition monads, and for each ofthem we design a signature in
TrModMnd . One exception is Positive GSOS systems: forthem, we go further, by recasting them as the signatures of a subregister of
TrModMnd .11.1.
The call-by-value, simply-typed, big-step 𝝀 -calculus. Recall from § 𝜆 -calculus forms a transition monad, where wetake P = S to be the set of types (generated from some fixed set of type constants). Themonad 𝑇 over Set P is given by values, the source state functor 𝑆 is given by applicationbinary trees, and the second state functor 𝑆 is the identity.Let us now design a signature for this transition monad. Let 𝐹 : Set P → Set S bespecified by the signature of PModFun ( P , S ) consisting of two families of operations app 𝑡,𝑡 ′ : Θ 𝑡 → 𝑡 ′ × Θ 𝑡 → Θ 𝑡 ′ and 𝑣𝑎𝑙 𝑡 : I 𝑡 → Θ 𝑡 . Our signature for call-by-value, simply-typed, big-step 𝜆 -calculus is presented in the following table Monad andstate functors
𝑇 𝑆 𝑆 𝜆 𝑡,𝑡 ′ : ( 𝐹 𝑡 ′ ◦ Θ ) ( 𝑡 ) → Θ 𝑡 → 𝑡 ′ 𝐹 IdRules 𝑣𝑎𝑙 𝑡 ( 𝑣 ) { 𝑣 𝑒 { 𝜆 𝑡,𝑡 ′ ( 𝑒 ) 𝑒 { 𝑤 𝑒 [ 𝑤 ] { 𝑣 app 𝑡,𝑡 ′ ( 𝑒 , 𝑒 ) { 𝑣 where • −[−] : ( 𝑆 𝑇 ) ( 𝑡 ) 𝑡 ′ × 𝑇 𝑡 → ( 𝑆 𝑇 ) 𝑡 ′ denotes the substitution morphism; • 𝑆 = 𝐹 and 𝑆 = Id are specified by easy signatures as in Remark 7.11; • the rules should be understood as families of rules indexed by suitable types.In a bit more detail, the first rule is indexed by the type 𝑡 of 𝑣 . The second one is indexedby two types 𝑡 and 𝑡 ′ . There are five metavariables, 𝑒 , 𝑒 , 𝑒 , 𝑣 , and 𝑤 . We thus take 𝑉 : = ( 𝑆 𝑇 ) 𝑡 → 𝑡 ′ × ( 𝑆 𝑇 ) 𝑡 × ( 𝑆 𝑇 ) ( 𝑡 ) 𝑡 ′ × 𝑇 𝑡 ′ × 𝑇 𝑡 . The ¯ 𝝀𝝁 -calculus. Recall from § 𝜆𝜇 -calculus [32, 52] forms a transitionmonad with P = = { p , s } , where p stands for “programs” and s for “stacks”. The placetakermonad 𝑇 on Set P is given by programs and stacks. The set of transition types is S = = { c , p , s } , where c stands for “commands”, and both state functors 𝑆 , 𝑆 : Set P → Set S aregiven by triples of a command (as a pair of a program and a stack), a program, and a stack.Let us repeat the grammar for the reader’s convenience.Commands 𝑐 F h 𝑒 | 𝜋 i Programs 𝑒 F 𝑥 | 𝜇𝛼.𝑐 | 𝜆𝑥.𝑒 Stacks 𝜋 F 𝛼 | 𝑒 · 𝜋, Transitions are generated by the congruence rules and the following two rules h 𝜇𝛼.𝑐 | 𝜋 i → 𝑐 [ 𝛼 ↦→ 𝜋 ] h 𝜆𝑥.𝑒 | 𝑒 ′ · 𝜋 i → h 𝑒 [ 𝑥 ↦→ 𝑒 ′ ] | 𝜋 i .Let us see how to specify this transition monad using our register. The state functorhas been specified in Remark 7.11. The monad is specified by operations 𝜇 : Θ ( s ) p × Θ ( s ) s → Θ p 𝜆 : Θ ( p ) p → Θ p · : Θ p × Θ s → Θ s , with no equation.The transition rules are almost as usual: h 𝜇 h 𝑒 | 𝜋 ′ i| 𝜋 i { h 𝑒 [ 𝜋 ] , 𝜋 ′ [ 𝜋 ]i h 𝜆 ( 𝑒 ) | 𝑒 ′ · 𝜋 i { h 𝑒 [ 𝑒 ′ ] | 𝜋 i The first rule has metavariable module 𝑉 : = 𝑇 ( s ) p × 𝑇 ( s ) s × 𝑇 s , the argument being ( 𝑒, 𝜋 ′ , 𝜋 ) .The second rule has 𝑉 : = 𝑇 ( p ) p × 𝑇 p × 𝑇 s . Let us finish by listing the various congruence rules.Commands: 𝑒 { 𝑒 ′ h 𝑒 | 𝜋 i { h 𝑒 ′ | 𝜋 i 𝜋 { 𝜋 ′ h 𝑒 | 𝜋 i { h 𝑒 | 𝜋 ′ i Programs: h 𝑒 | 𝜋 i { h 𝑒 ′ | 𝜋 ′ i 𝜇 h 𝑒 | 𝜋 i { 𝜇 h 𝑒 ′ | 𝜋 ′ i 𝑒 { 𝑒 ′ 𝜆 ( 𝑒 ) { 𝜆 ( 𝑒 ′ ) Stacks: 𝑒 { 𝑒 ′ 𝑒 · 𝜋 { 𝑒 ′ · 𝜋 𝜋 { 𝜋 ′ 𝑒 · 𝜋 { 𝑒 · 𝜋 ′ ODULES OVER MONADS AND OPERATIONAL SEMANTICS 47
The 𝝅 -calculus. Recall from § 𝜋 -calculus [47] also forms a transition monadswith P = = { c , p } ( c for “channels”, p for “processes”). The placetaker monad is trivialon channels, and is defined on processes by the usual grammar 𝑃, 𝑄 F | ( 𝑃 | 𝑄 ) | 𝜈𝑎.𝑃 | ¯ 𝑎 h 𝑏 i .𝑃 | 𝑎 ( 𝑏 ) .𝑃 ,where 𝑎 and 𝑏 range over channel names, and 𝑏 is bound in 𝑎 ( 𝑏 ) .𝑃 and in 𝜈𝑏.𝑃 . Processesare identified when related by the smallest context-closed equivalence relation ≡ satisfying0 | 𝑃 ≡ 𝑃 𝑃 | 𝑄 ≡ 𝑄 | 𝑃 𝑃 | ( 𝑄 | 𝑅 ) ≡ ( 𝑃 | 𝑄 ) | 𝑅 ( 𝜈𝑎.𝑃 ) | 𝑄 ≡ 𝜈𝑎. ( 𝑃 | 𝑄 ) ,where in the last equation 𝑎 should not occur free in 𝑄 . Transitions are then given by therules ¯ 𝑎 h 𝑏 i .𝑃 | 𝑎 ( 𝑐 ) .𝑄 −→ 𝑃 | ( 𝑄 [ 𝑐 ↦→ 𝑏 ]) 𝑃 −→ 𝑄𝑃 | 𝑅 −→ 𝑄 | 𝑅 𝑃 −→ 𝑄𝜈𝑎.𝑃 −→ 𝜈𝑎.𝑄 . Let us recall that we denote any object 𝑋 ∈ Set P by 𝑋 = ( 𝑋 c , 𝑋 p ) , so that we have 𝑇 ( 𝑋 ) = ( 𝑋 c , 𝑇 ( 𝑋 ) p ) ∈ Set P . Furthermore, transitions relate processes, so we have S = 𝑆 ( 𝑋 ) = 𝑆 ( 𝑋 ) = 𝑋 p .Let us see how to specify this transition monad using our register. The state functorhas been specified in Remark 7.11. The placetaker monad 𝑇 is specified by operations0 : 1 → Θ p | : Θ p × Θ p → Θ p 𝜈 : Θ ( c ) p → Θ p 𝑜𝑢𝑡 : Θ c × Θ p → Θ p 𝑖𝑛 : Θ c × Θ ( c ) p → Θ p with equations 0 | 𝑃 ≡ 𝑃 𝑃 | 𝑄 ≡ 𝑄 | 𝑃 𝑃 | ( 𝑄 | 𝑅 ) ≡ ( 𝑃 | 𝑄 ) | 𝑅 𝜈 ( 𝑃 ) | 𝑄 ≡ 𝜈 ( 𝑃 | w c ( 𝑄 )) , al-most copied verbatim from the standard presentation above, where w c ( 𝑄 ) denotes the actionof 𝑇 ( 𝑋 ) → 𝑇 ( 𝑋 + y c ) on 𝑄 . Finally, the transition rules are 𝑜𝑢𝑡 ( 𝑎, 𝑏, 𝑃 ) | 𝑖𝑛 ( 𝑎, 𝑄 ) { 𝑃 | ( 𝑄 [ 𝑏 ]) 𝑃 { 𝑄𝑃 | 𝑅 { 𝑄 | 𝑅 𝑃 { 𝑄𝜈 ( 𝑃 ) { 𝜈 ( 𝑄 ) .In particular, the third rule has as metavariable module 𝑉 : = ( Θ ( c ) p ) .11.4. A register for Positive GSOS systems.
Finally, let us recall that Positive GSOSrules have the shape 𝑥 𝑖 𝑎 𝑖, 𝑗 −−−→ 𝑦 𝑖, 𝑗 𝑜 𝑝 ( 𝑥 , . . . , 𝑥 𝑛 ) 𝑐 −→ 𝑒 ,where the variables 𝑥 𝑖 and 𝑦 𝑖, 𝑗 are all distinct, 𝑜 𝑝 ∈ 𝑂 is an operation with arity 𝑛 , and 𝑒 is an expression potentially depending on all the variables.We saw in § • P =
1, because we are in an untyped setting, • S = • 𝑇 denotes the term monad, • 𝑆 ( 𝑋 ) = 𝑋 , and • 𝑆 ( 𝑋 ) = A × 𝑋 , where A denotes the set of labels.Let us now define a register GSOS + for specifying positive GSOS systems [15]. Thisis a subregister of our register TrModMnd , for untyped ( P = S =
1) transition monads.Let us recall that signatures in this register consist of tuples ( Σ 𝑇 , Σ , Σ , Σ Trans ) , where 𝑇 = spec ( Σ 𝑇 ) , 𝑆 = spec ( Σ ) , 𝑆 = spec ( Σ ) , and Σ Trans is a signature in
Rule ∗ ( 𝑇 , 𝑆 , 𝑆 ) .In order to describe this subregister, we have to describe its class of signatures, andthen assign to each such signature a tuple ( Σ 𝑇 , Σ , Σ , Σ Trans ) as above. A signature of the register
GSOS + consist of • three sets 𝑂 (for operations), A (for labels), and 𝑅 (for rules), • for each element 𝑜 of 𝑂 , a number 𝑚 𝑜 (the arity), • for each rule, – an operation 𝑜 ∈ 𝑂 (for the source of the conclusion), – a label 𝑐 ∈ A (the label of the conclusion), – for each 𝑖 ≤ 𝑚 𝑜 , ∗ a number 𝑛 𝑖 (the number of premises for this argument), ∗ for each 𝑗 ≤ 𝑛 𝑖 , an element 𝑎 𝑖 𝑗 of A (for the label of the premise), ∗ a term 𝑒 in the syntax generated by 𝑂 , potentially depending on 𝑚 𝑜 + Í 𝑖 𝑛 𝑖 variables.We now describe the tuple ( Σ 𝑇 , Σ , Σ , Σ Trans ) associated to a signature as above: • the signatures for both state functors have been given in Remark 7.11; • the signature for the underlying monad is Í 𝑜 ∈ 𝑂 Θ 𝑚 𝑜 → Θ (following § . . . 𝑉 𝑖 { ( 𝑎 𝑖, 𝑗 , 𝑉 𝑖, 𝑗 ) . . .𝑜 𝑝 𝑜 ( 𝑉 , . . . , 𝑉 𝑚 𝑜 ) { ( 𝑐, 𝑒 ) in our fibre signature Σ Trans (in the register
Rule ∗ ( 𝑇 , 𝑆 , 𝑆 ) ).11.5. The differential 𝝀 -calculus. Recall from § 𝜆 -calculus syntaxis defined by 𝑒, 𝑓 , 𝑔 F 𝑥 | 𝜆𝑥.𝑒 | 𝑒 h 𝑈 i | 𝐷𝑒 · 𝑓 (terms) 𝑈, 𝑉 F | 𝑒 + 𝑈 (multiterms),where terms and multiterms are considered equivalent up to the following equations. 𝑒 + 𝑒 ′ + 𝑈 = 𝑒 ′ + 𝑒 + 𝑈 𝐷 ( 𝐷𝑒 · 𝑓 ) · 𝑔 = 𝐷 ( 𝐷𝑒 · 𝑔 ) · 𝑓 . Based on unary multiterm substitution 𝑒 [ 𝑥 ↦→ 𝑈 ] and partial derivation 𝜕𝑒𝜕𝑥 · 𝑈 , thetransition relation is defined as the smallest context-closed relation satisfying the rulesbelow, ( 𝜆𝑥.𝑒 ) h 𝑈 i → 𝑒 [ 𝑥 ↦→ 𝑈 ] 𝐷 ( 𝜆𝑥.𝑒 ) · 𝑓 → 𝜆𝑥. (cid:18) 𝜕𝑒𝜕𝑥 · 𝑓 (cid:19) where 𝜆 is linearly extended to multiterms: 𝜆𝑥. ( 𝑒 + . . . + 𝑒 𝑛 ) is notation for 𝜆𝑥.𝑒 + . . . + 𝜆𝑥.𝑒 𝑛 .We saw that this all forms a transition monad with one placetaker type and one tran-sition type ( P = S = TrModMnd .A signature in this register consists of signatures for the state functors and monad, togetherwith a signature for the transition module.
Signature for the placetaker monad
Recalling that ! denote the finite multiset functor,the monad 𝑇 of differential 𝜆 -calculus is specified by operations the arities 𝜆 : Θ ( ) → Θ −h−i : Θ × ! Θ → Θ 𝐷 − · − : Θ × Θ → Θ with one equation: 𝐷 ( 𝐷𝑒 · 𝑓 ) · 𝑔 ≡ 𝐷 ( 𝐷𝑒 · 𝑔 ) · 𝑓 . (11.1)By using ! Θ as the arity for the argument of partial derivation, we directly identify mul-titerms as finite multisets, which explains why we do not need any further equation forenforcing order irrelevance of + . ODULES OVER MONADS AND OPERATIONAL SEMANTICS 49
Signature for the state functors
Our state functors are 𝑆 = Id and 𝑆 = !, which arespecified by easy signatures in the sense of Remark 7.11. Signature for transitions
Specifying the transition rules requires the following lemma.
Lemma 11.1.
There exist 𝑇 -module morphisms 𝜎 : 𝑇 ( ) × ! 𝑇 → ! 𝑇 and 𝛿 : 𝑇 ( ) × ! 𝑇 → ! 𝑇 ( ) ,respectively called unary multiterm substitution and partial derivation , satisfying theequations of [52, Definition 6.3 and 6.4] .Proof sketch. By the characterisation of Corollary 10.23, 𝑇 is a quotient of the initial Σ 𝑆 -monoid 𝑍 by (11.1). We thus first define both operations from 𝑍 ( ) by induction follow-ing [52, Definition 6.3 and 6.4], then check that both obtained morphisms coequalise therelevant parallel pair to extend them to morphisms from 𝑇 ( ) . Finally, we check that both ob-tained morphisms are indeed module morphisms, which follows from [52, Lemma 6.10].Now that both auxiliary operations 𝜎 and 𝛿 are defined, the main transition rules are 𝜆 ( 𝑡 ) h 𝑈 i { 𝜎 ( 𝑡, 𝑈 ) 𝐷 ( 𝜆 ( 𝑡 )) · 𝑢 { 𝜆 ( 𝛿 ( 𝑡, 𝑢 )) , where we implicitly coerce 𝜆 : 𝑇 ( ) → 𝑇 into a morphism ! 𝑇 ( ) → ! 𝑇 .Furthermore, because reduction in the differential 𝜆 -calculus is context-closed, we needto include the following congruence rules, detailed in [52, Definition 6.18]: 𝑡 { 𝑈𝜆 ( 𝑡 ) { 𝜆 ( 𝑈 ) 𝑡 { 𝑈𝐷𝑡 · 𝑠 { 𝐷𝑈 · 𝑠 𝑠 { 𝑈𝐷𝑡 · 𝑠 { 𝐷𝑡 · 𝑈𝑡 { 𝑈𝑡 h 𝑆 i { 𝑈 h 𝑆 i 𝑡 { 𝑈𝑠 h 𝑡 + 𝑉 i { 𝑠 h 𝑈 + 𝑉 i where, as for 𝜆 above, we implicitly coerce some module morphisms to 𝑇 into modulemorphisms to ! 𝑇 , also lifting some of their arguments from 𝑇 to ! 𝑇 , namely we use 𝐷 (−) · − : ! 𝑇 × ! 𝑇 → ! 𝑇 −h−i : ! 𝑇 × ! 𝑇 → ! 𝑇 + : ! 𝑇 × ! 𝑇 → ! 𝑇 .
A few comments are in order: • The first morphism is only used in cases where one of its arguments is a singleton multiset. • In the second case, the function argument is merely duplicated across all copies, i.e., ( 𝑒 + . . . + 𝑒 𝑛 ) h 𝑈 i = 𝑒 h 𝑈 i + . . . + 𝑒 𝑛 h 𝑈 i . • In the last case, + merely denotes standard multiset union.12. Conclusion and perspectives
We have introduced transition monads as a generalisation of reduction monads, and demon-strated that they cover relevant new examples. We have introduced a register of signaturesfor specifying them. Let us briefly assess the scope of our register for transition monads, ormore generally of the notion of transition monad itself.All combinations of call-by-value vs. call-by-name, small-step vs. big-step, or simply-typed vs. untyped variants of 𝜆 -calculus should be handled smoothly.Simple imperative languages like IMP [54, Chapter 2] may also be organised into transi-tion monads, at least in a trivial way since, in the absence of first-class functions, reduction is generally defined on closed programs. A less trivial treatment might be obtained, how-ever, by designing a reduction relation for open programs. E.g., the reduction relation couldnaturally include steps like if 𝑥 = 𝑥 + then 𝑐 else 𝑐 −→ 𝑐 .Languages whose transition rules involve some kind of evaluation contexts, like ML [45,Chapter 10], 𝜆 -calculi with let rec [10], or the substitution calculus [1], should also fit intothe framework, although with a bit more work.A first class of languages which clearly cannot be organised naturally as transitionmonads is those whose transitions involve non-free modules. Example 12.1.
The standard labelled transition system for 𝜋 -calculus [47, Table 1.5 p38]includes an input transition 𝑎 ( 𝑥 ) .𝑃 𝑎 ( 𝑦 ) −−−→ 𝑃 [ 𝑥 ↦→ 𝑦 ] in which 𝑦 may be fresh. Letting 𝑇 denote the monad for syntax as in § 𝑇 -module 𝑇 c × 𝑇 ( c ) p + 𝑇 c × 𝑇 p + . . . , the showed terms respectively modelling the input of afresh and of a known channel.Extending the register PModFun ( P , S ) of § §
1, this is the price to pay for its simplicity. What is missing, in comparisonwith previous work like [7], is a kind of Grothendieck construction for signatures/registers.This works smoothly in most examples. However, in cases like the differential 𝜆 -calculus,this would require extending the definition of unary multiterm substitution and partialderivation (Lemma 11.1) to all models of the syntax. And this appears to leave somedesign choices open, which might be a reflection of the diversity of categorical semantics fordifferential 𝜆 -calculus [16, 21, 19, 37].In the longer term, we plan to refine our register in a way ensuring that the gener-ated transition system satisfies important properties like congruence of useful behaviouralequivalences, confluence, or type soundness. In this direction, a result on congruence ofapplicative bisimilarity for a simpler register has recently been obtained by Borthelle etal. [18]. Finally, quantitative (e.g., probabilistic [13]) operational semantics would be worthinvestigating in our setting. References [1] Beniamino Accattoli. A fresh look at the lambda-calculus (invited talk). In Geuvers [29], pages 1:1–1:20. doi:10.4230/LIPIcs.FSCD.2019.1 .[2] Ji˘r´ı Ad´amek and Ji˘r´ı Rosicky.
Locally Presentable and Accessible Categories . Cambridge UniversityPress, 1994. doi:10.1017/CBO9780511600579 .[3] J. Ad´amek, J. Rosick´y, and E. M. Vitale.
Algebraic Theories: A Categorical Introduc-tion to General Algebra . Cambridge Tracts in Mathematics. Cambridge University Press, 2010. doi:10.1017/CBO9780511760754 .[4] Benedikt Ahrens. Initiality for typed syntax and semantics.
Journal of Formalized Reasoning , 8(2):1–155, 2015. doi:10.6092/issn.1972-5787/4712 .[5] Benedikt Ahrens. Modules over relative monads for syntax and semantics.
Mathematical Structures inComputer Science , 26:3–37, 2016. doi:10.1017/S0960129514000103 .[6] Benedikt Ahrens, Andr´e Hirschowitz, Ambroise Lafont, and Marco Maggesi. Modular specification ofmonads through higher-order presentations. In Geuvers [29]. doi:10.4230/LIPIcs.FSCD.2019.6 .[7] Benedikt Ahrens, Andr´e Hirschowitz, Ambroise Lafont, and Marco Maggesi. Reduction monads andtheir signatures.
PACMPL , 4(POPL):31:1–31:29, 2020. doi:10.1145/3371099 . ODULES OVER MONADS AND OPERATIONAL SEMANTICS 51 [8] Thorsten Altenkirch, James Chapman, and Tarmo Uustalu. Monads need not be endofunctors.
LogicalMethods in Computer Science , 11(1), 2015. doi:10.2168/LMCS-11(1:3)2015 .[9] Thorsten Altenkirch, Peter Morris, Fredrik Nordvall Forsberg, and Anton Setzer. A categorical seman-tics for inductive-inductive definitions. In Andrea Corradini, Bartek Klin, and Corina Cˆırstea, editors,
Proc. 4th International Conference on Algebra and Coalgebra in Computer Science , volume 6859 of
LNCS , pages 70–84. Springer, 2011. doi:10.1007/978-3-642-22944-2\_6 .[10] Zena M. Ariola and Stefan Blom. Skew confluence and the lambda calculus with letrec. 117(1-3):95–168,2002. doi:10.1016/S0168-0072(01)00104-X .[11] Nathanael Arkor and Marcelo Fiore. Algebraic models of simple type theories: A polynomial approach.In Hermanns et al. [33], pages 88–101. doi:10.1145/3373718.3394771 .[12] Michael Barr and Charles Wells. Toposes, triples, and theories.
Reprints in Theory and Applications ofCategories , 12, 2005. Originally published by: Springer, 1985.[13] Falk Bartels. GSOS for probabilistic transition systems: (extended abstract).
Electronic Notes in The-oretical Computer Science , 65(1):29–53, 2002. CMCS ’2002, Coalgebraic Methods in Computer Science. doi:10.1016/S1571-0661(04)80358-X .[14] Robert Oswald Blackwell, University of New South Wales. School of Mathematics, and University of NewSouth Wales. Some existence theorems in the theory of doctrines, 1976. Thesis (Ph. D.)–University ofNew South Wales, 1976.[15] Bard Bloom, Sorin Istrail, and Albert R. Meyer. Bisimulation can’t be traced.
J. ACM , 42(1):232–268,1995. doi:10.1145/200836.200876 .[16] Richard Blute, J. Robin B. Cockett, and Robert A. G. Seely. Differential categories.
MathematicalStructures in Computer Science , 16(6):1049–1083, 2006. doi:10.1017/S0960129506005676 .[17] Francis Borceux.
Handbook of Categorical Algebra 2: Categories and Structures . Cambridge UniversityPress, 1994.[18] Peio Borthelle, Tom Hirschowitz, and Ambroise Lafont. A cellular Howe theorem. In Hermanns et al.[33], pages 273–286. doi:10.1145/3373718.3394738 .[19] Thomas Ehrhard. An introduction to differential linear logic: proof-nets, models and antiderivatives.
Mathematical Structures in Computer Science , 28(7):995–1060, 2018. doi:10.1017/S0960129516000372 .[20] Thomas Ehrhard and Laurent Regnier. The differential lambda-calculus.
Theoretical Computer Science ,309(1–3):1–41, 2003. doi:10.1016/S0304-3975(03)00392-X .[21] Marcelo Fiore. Differential structure in models of multiplicative biadditive intuitionistic lin-ear logic. In Simona Ronchi Della Rocca, editor,
Proc. 8th International Conference onTyped Lambda Calculi and Applications , volume 4583 of
LNCS , pages 163–177. Springer, 2007. doi:10.1007/978-3-540-73228-0\_13 .[22] Marcelo Fiore. Second-order and dependently-sorted abstract syntax. In
Proc. 23rd Symposium on Logicin Computer Science , pages 57–68. IEEE, 2008. doi:10.1109/LICS.2008.38 .[23] Marcelo Fiore and Chung-Kil Hur. On the construction of free algebras for equational systems.
Theo-retical Computer Science , 410(18):1704–1729, 2009. doi:10.1016/j.tcs.2008.12.052 .[24] Marcelo Fiore, Gordon Plotkin, and Daniele Turi. Abstract syntax and variable bind-ing. In
Proc. 14th Symposium on Logic in Computer Science , pages 193–202. IEEE, 1999. doi:10.1109/LICS.1999.782615 .[25] Marcelo Fiore and Philip Saville. List objects with algebraic structure. In Dale Miller, editor,
Proc. 2nd International Conference on Formal Structures for Computation and Deduction , vol-ume 84 of
LIPIcs , pages 16:1–16:18. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2017. doi:10.4230/LIPIcs.FSCD.2017.16 .[26] Marcelo Fiore and Sam Staton. A congruence rule format for name-passing process calculi from mathe-matical structural operational semantics. In
Proc. 21st Symposium on Logic in Computer Science , pages49–58. IEEE, 2006. doi:10.1109/LICS.2006.7 .[27] Marcelo Fiore and Daniele Turi. Semantics of name and value passing. In
Proc. 16th Symposium onLogic in Computer Science , pages 93–104. IEEE, 2001. doi:10.1109/LICS.2001.932486 .[28] Richard Garner. Combinatorial structure of type dependency.
CoRR , abs/1402.6799, 2014. arXiv:1402.6799 .[29] Herman Geuvers, editor.
Proc. 4th International Conference on Formal Structures for Computation andDeduction , volume 131 of
Leibniz International Proceedings in Informatics (LIPIcs) . Schloss Dagstuhl–Leibniz-Zentrum f¨ur Informatik, 2019. [30] J.A. Goguen, J.W. Thatcher, and E.G. Wagner. An initial algebra approach to the specification, cor-rectness and implementation of abstract data types. In R. Yeh, editor,
Current Trends in ProgrammingMethodology, IV: Data Structuring , pages 80–144. Prentice-Hall, 1978.[31] Makoto Hamana. Term rewriting with variable binding: An initial algebra approach. In
Proc.5th International Conference on Principles and Practice of Declarative Programming
ACM, 2003. doi:10.1145/888251.888266 .[32] Hugo Herbelin.
S´equents qu’on calcule: de l’interpr´etation du calcul des s´equents comme calcul delambda-termes et comme calcul de strat´egies gagnantes.
PhD thesis, Paris Diderot University, France,1995. URL: https://tel.archives-ouvertes.fr/tel-00382528 .[33] Holger Hermanns, Lijun Zhang, Naoki Kobayashi, and Dale Miller, editors.
Proc. 35th ACM/IEEESymposium on Logic in Computer Science
ACM, 2020. doi:10.1145/3373718 .[34] Andr´e Hirschowitz, Tom Hirschowitz, and Ambroise Lafont. Modules over monads and operationalsemantics. volume 167 of
Leibniz International Proceedings in Informatics (LIPIcs) , pages 12:1–12:23.Schloss Dagstuhl–Leibniz-Zentrum f¨ur Informatik, 2020. doi:10.4230/LIPIcs.FSCD.2020.12 .[35] Andr´e Hirschowitz and Marco Maggesi. Modules over monads and linearity. In
WoLLIC , volume 4576of
LNCS , pages 218–237. Springer, 2007. doi:10.1007/3-540-44802-0\_3 .[36] Tom Hirschowitz. Cartesian closed 2-categories and permutation equivalence in higher-order rewriting.
Logical Methods in Computer Science , 9(3), 2013. doi:10.2168/LMCS-9(3:10)2013 .[37] Martin Hyland and Christine Tasson. The linear-non-linear substitution 2-monad. Submitted. URL: .[38] G. M. Kelly. A unified treatment of transfinite constructions for free algebras, free monoids, colimits,associated sheaves, and so on.
Bulletin of the Australian Mathematical Society , 22:1–83, 1980.[39] Joachim Kock. Notes on polynomial functors. Working notes, 2009. URL: http://mat.uab.es/~kock/cat/polynomial.pdf .[40] Stephen Lack. On the monadicity of finitary monads.
Journal of Pure and Applied Algebra , 140:65–73,1997.[41] Ambroise Lafont.
Signatures and models for syntax and operational semantics in the presence of variablebinding . PhD thesis, ´Ecole Nationale Superieure Mines – Telecom Atlantique Bretagne Pays de la Loire– IMT Atlantique, 2019. arXiv:1910.09162 .[42] S. Lassen.
Higher Order Operational Techniques in Semantics , chapter Relational reasoning about con-texts, pages 91–135. Cambridge University Press, 1998.[43] Saunders Mac Lane.
Categories for the Working Mathematician . Number 5 in Graduate Texts in Math-ematics. Springer, 2nd edition, 1998.[44] Luca Paolini and Simona Ronchi Della Rocca. Call-by-value solvability.
RAIRO - Theor. Inf. andApplic. , 33(6):507–534, 1999. doi:DOI:10.1051/ita:1999130 .[45] Benjamin C. Pierce, editor.
Advanced Topics in Types and Programming Languages . MIT Press, 2004.[46] Jan Reiterman. A left adjoint construction related to free triples.
Journal of Pure and Applied Algebra ,10:57–71, 1977. doi:10.1016/0022-4049(77)90028-7 .[47] Davide Sangiorgi and David Walker.
The 𝜋 -calculus - a theory of mobile processes . Cambridge UniversityPress, 2001.[48] Gavin J. Seal. Tensors, monads and actions. Theory and Applications of Categories , 28(15):403–434,2013.[49] Sam Staton. General structural operational semantics through categorical logic. In
Proc. 23rd Sympo-sium on Logic in Computer Science , pages 166–177. IEEE, 2008. doi:10.1109/LICS.2008.43 .[50] Ross Street. The formal theory of monads.
Journal of Pure and Applied Algebra , 2:149–168, 1972.[51] Daniele Turi and Gordon D. Plotkin. Towards a mathematical operational semantics. In
Proc. 12thSymposium on Logic in Computer Science , pages 280–291, 1997. doi:10.1109/LICS.1997.614955 .[52] Lionel Vaux. 𝜆 -calcul diff´erentiel et logique classique : interactions calculatoires . PhD thesis, Universit´eAix-Marseille 2, 2007.[53] Mark Weber. Generic morphisms, parametric representations and weakly cartesian monads. Theory andApplications of Categories , 13:191–234, 2004.[54] Glynn Winskel.