High-level signatures and initial semantics

We present a device for specifying and reasoning about syntax for datatypes, programming languages, and logic calculi. More precisely, we consider a general notion of ‘signature’ for specifying syntactic constructions. Our signatures subsume classical algebraic signatures (i.e., signatures for languages with variable binding, such as the pure lambda calculus) and extend to much more general examples. In the spirit of Initial Semantics, we deﬁne the ‘syntax generated by a signature’ to be the initial object—if it exists—in a suitable category of models. Our notions of signature and syntax are suited for compositionality and provide, beyond the desired algebra of terms, a well-behaved substitution and the associated inductive/recursive principles. Our signatures are ‘general’ in the sense that the existence of an associated syntax is not automatically guaranteed. In this work we identify, via the notion of presentation of a signature , a large class of signatures that do generate a syntax. One key feature of presentations is that they are highly compositional, in the sense that complex presentations can be obtained by assembling simpler ones. This paper builds upon ideas


Initial Semantics
The concept of characterising data through an initiality property is standard in computer science, where it is known under the terms Initial Semantics and Algebraic Specification [27], and has been popularised by the movement of Algebra of Programming [9].This concept offers the following methodology to define a formal language3 : 1. Introduce a notion of signature.

2.
Construct an associated notion of model.Such models should form a category.

3.
Define the syntax generated by a signature to be its initial model, when it exists.4. Find a satisfactory sufficient condition for a signature to generate a syntax 4 .
The models of a signature should be understood as domain of interpretation of the syntax generated by the signature: initiality of the syntax should give rise to a convenient recursion principle.
For a notion of signature to be satisfactory, it should satisfy the following conditions: it should extend the notion of algebraic signature, and complex signatures should be built by assembling simpler ones, thereby opening room for compositionality properties.
In the present work, we consider a general notion of signature-together with its associated notion of model-which is suited for the specification of untyped programming languages with variable binding.On the one hand, our signatures are fairly more general than those introduced in some of the seminal papers on this topic [16,21,17], which are essentially given by a family of lists of natural numbers indicating the number of variables bound in each subterm of a syntactic construction (we call them 'algebraic signatures' below).On the other hand, the existence of an initial model in our setting is not automatically guaranteed.
One main result of this paper is a sufficient condition on a signature to ensure such an existence.Our condition is still satisfied far beyond the algebraic signatures mentioned above.Specifically, our signatures form a cocomplete category and our condition is preserved by colimits (Section 7).Examples are given in Section 9.
Our notions of signature and syntax enjoy modularity in the sense introduced by [19]: indeed, we define a 'total' category of models where objects are pairs consisting of a signature together with one of its models; and in this total category of models, merging two extensions of a syntax corresponds to building an amalgamated sum.

XX:3
The present work improves on a previous attempt [24] in two main ways: firstly, it gives a much simpler condition for the existence of an initial model; secondly, it provides computer-checked proofs for all the main statements.

Computer-checked formalization
The intricate nature of our main results made it desirable to provide a mechanically checked proof of that result, in conjunction with a human-readable summary of the proof.
Our computer-checked proof is based on the UniMath library [32], which itself is based on the proof assistant Coq [31].The main reasons for our choice of proof assistant are twofold: firstly, the logical basis of the Coq proof assistant, dependent type theory, is well suited for abstract algebra, in particular, for category theory.Secondly, a suitable library of category theory, ready for use by us, had already been developed [5].
The formalization consists of about 8,000 lines of code, and can be consulted on https: //github.com/UniMath/largecatmodules.A guide is given in the README.
For the purpose of this article, we refer to a fixed version of our library, with the short hash cee7580.This version compiles with version bcc8344 of UniMath.
Throughout the article, statements are accompanied by their corresponding identifiers in the formalization.These identifiers are also hyperlinks to the online documentation stored at https://initialsemantics.github.io/doc/cee7580/index.html.

Related work
The idea that the notion of monad is suited for modelling substitution concerning syntax (and semantics) has been retained by many contributions on the subject (see e.g.[10,19,30,8]).In particular, Matthes and Uustalu [30] introduce a very general notion of signature and, subsequently, Ghani, Uustalu, and Hamana [19] consider a form of colimits (namely coends) of such signatures.Their treatment rests on the technical device of strength 5 , and so did our preliminary version of the present work [24].Notably, the present version simplifies the treatment by avoiding the consideration of strengths.Any signature with strength gives rise to a signature in our sense, cf.Proposition 21.Research on signatures with strength is actively developed, see also [6] for a more recent account.
We should mention several other mathematical approaches to syntax (and semantics).Fiore, Plotkin, and Turi [16] develop a notion of substitution monoid.Following [7], this setting can be rephrased in terms of relative monads and modules over them [3].Accordingly, our present contribution could probably be customised for this 'relative' approach.
The work by Fiore with collaborators [16,14,15] and the work by Uustalu with collaborators [30,19] share two traits: firstly, the modelling of variable binding by nested abstract syntax, and, secondly, the reliance on tensorial strengths in the specification of substitution.In the present work, variable binding is modelled using nested abstract syntax; however, we do without strengths.
Gabbay and Pitts [17] employ a different technique for modelling variable binding, based on nominal sets.We do not see yet how our treatment of more general syntax carries over to nominal techniques.
Yet another approach to syntax is based on Lawvere Theories.This is clearly illustrated in the paper [26], where Hyland and Power also outline the link with the language of monads and put in an historical perspective.
Finally, let us mention the classical approach based on Cartesian closed categories recently revisited and extended by T. Hirschowitz [25].

Organisation of the paper
Section 2 gives a succinct account of the notion of module over a monad, which is the crucial tool underlying our definition of signatures.Our categories of signatures and models are described in Sections 3 and 4 respectively.In Section 5, we give our definition of a syntax, and we present our first main result, a modularity result about merging extensions of syntax.In Section 6, we show through examples how recursion can be recovered from initiality.Our notion of presentation of a signature appears in Section 7. There, we also state our second main result: presentable signatures generate a syntax.The proof of that result is given in Section 8. Finally, in Section 9, we give examples of presentable signatures.

Publication history
This is a revision of the conference paper [4] presented at Computer Science Logic (CSL) 2018.Besides several minor changes to improve overall readability, the following content has been added: A comparison between signatures with strength and our signatures (Proposition 21); An analogue of Lambek's Lemma (Lemma 30), as well as an example of a signature that is not representable (Non-example 27); A variant of one of the main results (Theorem 36); A fix in Example 6.4 counting the redexes of a lambda-term; A more uniform treatment of several examples-both new and previously presented-in Section 9.1; Explicit statements about the use of the axioms of choice and excluded middle; Hyperlinks to an online documentation of the source code of our formalisation.

Categories of modules over monads
The main mathematical notion underlying our signatures is that of module over a monad.
In this section, we recall the definition and some basic facts about modules over a monad in the specific case of the category Set of sets, although most definitions are generalizable.See [23] for a more extensive introduction on this topic.

Modules over monads
A monad (over Set) is a monoid in the category Set −→ Set of endofunctors of Set, i.e., a triple R = (R, µ, η) given by a functor R : Set −→ Set, and two natural transformations µ : R • R −→ R and η : I −→ R such that the following equations hold: Given two monads R = (R, η, µ) and R = (R , η , µ ), a morphism f : R −→ R of monads is given by a natural transformation f : R −→ S between the underlying functors such that Let R be a monad.

Definition 1 (Modules).
A left R-module is given by a functor M : Set −→ Set equipped with a natural transformation ρ M : M • R −→ M , called module substitution, which is compatible with the monad composition and identity: There is an obvious corresponding definition of right R-modules that we do not need to consider in this paper.From now on, we will write 'R-module' instead of 'left R-module' for brevity.

Example 2.
Every monad R is a module over itself, which we call the tautological module.For any functor F : Set −→ Set and any R-module M : Set −→ Set, the composition F • M is an R-module (in the evident way).For every set W we denote by W : Set −→ Set the constant functor W := X → W . Then W is trivially an R-module since W = W • R. Let M 1 , M 2 be two R-modules.Then the product functor M 1 × M 2 is an R-module (see Proposition 4 for a general statement).Definition 3 (Linearity).We say that a natural transformation of R-modules τ : M −→ N is linear 6 if it is compatible with module substitution on either side: We take linear natural transformations as morphisms among modules.It can be easily verified that we obtain in this way a category that we denote Mod(R).
Limits and colimits in the category of modules can be constructed pointwise: Proposition 4 (LModule_Colims_of_shape, LModule_Lims_of_shape). Mod(R) is complete and cocomplete.

The total category of modules
We already introduced the category Mod(R) of modules with fixed base R. It is often useful to consider a larger category which collects modules with different bases.To this end, we need first to introduce the notion of pullback.Definition 5 (Pullback).Let f : R −→ S be a morphism of monads and M an S-module.
6 Given a monoidal category C, there is a notion of (left or right) module over a monoid object in C (see, e.g., [11,Section 4.1] for details).The term 'module' comes from the case of rings: indeed, a ring is just a monoid in the monoidal category of Abelian groups.Similarly, our monads are just the monoids in the monoidal category of endofunctors on Set, and our modules are just modules over these monoids.Accordingly, the term 'linear(ity)' for morphisms among modules comes from the paradigmatic case of rings. 7The term 'pullback' is standard in the terminology of Grothendieck fibrations (see Proposition 7).

XX:6
High-level signatures and initial semantics Definition 6 (The total module category).We define the total module category R Mod(R), or Mod for short, as follows8 : its objects are pairs (R, M ) of a monad R and an R-module M .a morphism from (R, M ) to (S, N ) is a pair (f, m) where f : R −→ S is a morphism of monads, and m : M −→ f * N is a morphism of R-modules.
The category Mod comes equipped with a forgetful functor to the category of monads, given by the projection (R, M ) → R.
Proposition 7 (cleaving_bmod).The forgetful functor Mod → Mon is a Grothendieck fibration with fibre Mod(R) over a monad R. In particular, any monad morphism f : R −→ S gives rise to a functor given on objects by Definition 5.

Derivation
For our purposes, important examples of modules are given by the following general construction.Let us denote the final object of Set as * .
Definition 9 (Derivation).For any R-module M , the derivative of M is the functor where i X : X −→ X + * and * : * −→ X + * are the obvious maps.
Derivation is a cartesian endofunctor on the category Mod(R) of modules over a fixed monad R. In particular, derivation can be iterated: we denote by M (k) the k-th derivative of M .
The substitution σ allows us to interpret the derivative M as the 'module M with one formal parameter added'.
Abstracting over the module turns the substitution morphism into a natural transformation that is the unit of the following adjunction: Proposition 13 (deriv_adj).The endofunctor of Mod(R) mapping M to the R-module M × R is left adjoint to the derivation endofunctor, the unit being the substitution morphism σ.

3
The category of signatures In this section, we give our notion of signature.The destiny of a signature is to have actions in monads.An action of a signature Σ in a monad R should be a morphism from a module Σ(R) to the tautological one R.For instance, in the case of the signature Σ of a binary operation, we have Σ(R which we denote by Σ × Υ.For instance, Θ 2 = Θ × Θ is the signature of any (first-order) binary operation, and, more generally, Θ n is the signature of n-ary operations. 5. Given two signatures Σ and Υ, the assignment R → Σ(R) + Υ(R) yields a signature which we denote by Σ + Υ.For instance, Θ 2 + Θ 2 is the signature of a pair of binary operations.
This last example explains why we do not need to distinguish here between 'arities'usually used to specify a single syntactic construction-and 'signatures'-usually used to specify a family of syntactic constructions; our signatures allow us to do both (via Proposition 19 for families that are not necessarily finitely indexed).
Elementary signatures are of a particularly simple shape: Definition 10) is a signature, which we denote by Θ (s) , or by Θ in the specific case of s = (1).Signatures of this form are said elementary.

High-level signatures and initial semantics
Limits and colimits of signatures can be easily constructed pointwise: Proposition 19 (Sig_Lims_of_shape, Sig_Colims_of_shape, Sig_isDistributive).The category of signatures is complete and cocomplete.Furthermore, it is distributive: for any signature Σ and family of signatures An algebraic signature is a (possibly infinite) coproduct of elementary signatures.
These signatures are those which appear in [16].For instance, the algebraic signature of the lambda-calculus is Σ LC = Θ 2 + Θ .
To conclude this section, we explain the connection between signatures with strength (on the category Set) and our signatures.
Signatures with strength were introduced in [30] (even though they were not given an explicit name there).The relevant definitions regarding signatures with strength are summarized in [6], to which we refer the interested reader.
We recall that a signature with strength [6, Definition 4] is a pair of an endofunctor H : [C, C] → [C, C] together with a strength-like datum.Here, we only consider signatures with strength over the base category C := Set.Given a signature with strength H, we also refer to the underlying endofunctor on the functor category [Set, Set] as A morphism of signatures with strength [6, Definition 5] is a natural transformation between the underlying functors that is compatible with the strengths in a suitable sense.Together with the obvious composition and identity, these objects and morphisms form a category SigStrength [6].
Any signature with strength H gives rise to a signature H [24,Section 7].This signature associates, to a monad R, an R-module whose underlying functor is H(U R), where U R is the functor underlying the monad R. Similarly, given two signatures with strength H 1 and H 2 , and a morphism α : H 1 → H 2 of signatures with strength, we associate to it a morphism of signatures α : H1 → H2 .This morphism sends a monad R to a module morphism α(R) : H1 (R) −→ H2 (R) whose underlying natural transformation is given by α(U R), where, as before, U R is the functor underlying the monad R.These maps assemble into a functor: Proposition 21 (sigWithStrength_to_sig_functor).The maps sketched above yield a functor (−) : SigStrength −→ Sig.

Categories of models
We define the notions of model of a signature and action of a signature in a monad.
Definition 22 (Models and actions).Given a signature Σ, we build the category Mon Σ of models of Σ as follows.Its objects are pairs (R, r) of a monad R equipped with a module morphism r : Σ(R) → R, called action of Σ in R. In other words, a model of Σ is a monad R equipped with an action of Σ in R 9 .A morphism from (R, r) to (S, s) is a morphism of monads m : R → S compatible with the actions, in the sense that the following diagram of R-modules commutes: Here, the horizontal arrows come from the actions, the left vertical arrow comes from the functoriality of signatures, and m : R −→ m * S is the morphism of monads seen as morphism of R-modules.This is equivalent to asking that the square of underlying natural transformations commutes, i.e., m • r = s • Σ(m).
Example 23.The usual app : LC 2 −→ LC is an action of the elementary signature Θ 2 in the monad LC of syntactic lambda calculus.The usual abs : LC −→ LC is an action of the elementary signature Θ in the monad LC.Then [app, abs] : LC 2 + LC −→ LC is an action of the algebraic signature of the lambda calculus Θ 2 + Θ in the monad LC.
Proposition 24.These morphisms, together with the obvious composition, turn Mon Σ into a category which comes equipped with a forgetful functor to the category of monads.
In the formalisation, this category is recovered as the fiber category over Σ of the displayed category [5] of models, see rep_disp.We have also formalized a direct definition (rep_ fiber_category) and shown that the two definitions yield isomorphic categories: catiso_ modelcat.
Definition 25 (Pullback).Let f : Υ −→ Σ be a morphism of signatures and (R, r) a model of Σ.The linear morphism Υ(R) The induced model of Υ is called pullback10 of (R, r) along f and denoted by f * (R, r).

Syntax
We are primarily interested in the existence of an initial object in the category Mon Σ of models of a signature Σ.We call such an essentially unique object the syntax generated by Σ.

Representations of a signature
Definition 26.If Mon Σ has an initial object, this object is essentially unique; we say that it is a representation of Σ and call it the syntax generated by Σ, denoted by Σ.By abuse of notation, we also denote by Σ the monad underlying the model Σ.
If an initial model for Σ exists, we say that Σ is representable 11 .
In this work, we aim to identify signatures that are representable.This is not automatic: below, we give a signature that is not representable.Afterwards, we give suitable sufficient criteria for signatures to be representable.
Non-example 27.Let P denote the powerset functor and consider the signature P • Θ (see Example 15, Item 2): it associates, to any monad R, the module P • R that sends a set X to the powerset P(RX) of RX.This signature is not representable.
Instead of giving a direct proof of the fact that P • Θ is not representable, we deduce it as a simple consequence of a stronger result that we consider interesting in itself: an analogue of Lambek's Lemma, given in Lemma 30.
The following preparatory lemma explains how to construct new models of a signature Σ from old ones: The injection Id → Σ(R) + Id together with the natural transformation give the endofunctor Σ(R) + Id the structure of a monad.Moreover, this monad can be given the following Σ-action: The natural transformation [r, η] :

Lemma 30 (iso_mod_id_model). If Σ is representable, then the morphism of Σ-models
We go back to considering the signature Σ := P • Θ. Suppose that Σ is representable.From Lemma 30 it follows that P ΣX + X ∼ = ΣX.In particular, we have an injective map from P ΣX to ΣX-contradiction.
On the other hand, as a starting point, we can identify the following class of representable signatures:

Theorem 31 (algebraic_sig_representable). Algebraic signatures are representable.
This result is proved in a previous work [22,Theorems 1 and 2].The construction of the syntax proceeds as follows: an algebraic signature induces an endofunctor on the category of endofunctors on Set.Its initial algebra (constructed as the colimit of the initial chain) is given the structure of a monad with an action of the algebraic signature, and then a routine verification shows that it is actually initial in the category of models.The computer-checked proof uses the construction of a monad from an algebraic signature formalized in [6].
In Section 7, we show a more general representability result: Theorem 35 states that presentable signatures, which form a superclass of algebraic signatures, are representable.

Modularity
In this section, we study the problem of how to merge two syntax extensions.Our answer, a 'modularity' result (Theorem 32), was stated already in the preliminary version [24, Section 6], there without proof.
Suppose that we have a pushout square of representable signatures, Intuitively, the signatures Σ 1 and Σ 2 specify two extensions of the signature Σ 0 , and Σ is the smallest extension containing both these extensions.Modularity means that the corresponding diagram of representations, / / Σ is a pushout as well-but we have to take care to state this in the 'right' category.The right category for this purpose is the following total category Σ Mon Σ , or Mon for short, of models: An object of Mon is a triple (Σ, R, r) where Σ is a signature, R is a monad, and r is an action of Σ in R.
It is easily checked that the obvious composition turns Mon into a category.Now for each signature Σ, we have an obvious inclusion from the fiber Mon Σ into Mon, through which we may see the syntax Σ of any representable signature as an object in Mon.Furthermore, a morphism i : Σ 1 −→ Σ 2 of representable signatures yields a morphism i * := Σ1 −→ Σ2 in Mon.Hence our pushout square of representable signatures as described above yields a square in Mon.
Theorem 32 (pushout_in_big_rep). Modularity holds in Mon, in the sense that given a pushout square of representable signatures as above, the associated square in Mon is a pushout again.
The proof uses, in particular, the following fact: Lemma 33 (rep_cleaving).The projection π : Mon → Sig is a Grothendieck fibration.In particular, given a morphism f : Υ −→ Σ of signatures, the pullback map defined in Definition 25 extends to a functor Note that Theorem 32 does not say that a pushout of representable signatures is representable again; it only tells us that if all of the signatures in a pushout square are representable, then the syntax generated by the pushout is the pushout of the syntaxes.In general, we do not know whether a colimit (or even a binary coproduct) of representable signatures is representable again.
In Section 7 we study presentable signatures, which we show to be representable.The subcategory of presentable signatures is closed under colimits.

Recursion
We now show through examples how certain forms of recursion can be derived from initiality.

Example: Translation of intuitionistic logic into linear logic
We start with an elementary example of translation of syntaxes using initiality, namely the translation of second-order intuitionistic logic into second-order linear logic [20, page 6].The syntax of second-order intuitionistic logic can be defined with one unary operator ¬, three binary operators ∨, ∧ and ⇒, and two binding operators ∀ and ∃.The associated (algebraic) signature is Σ LJ = Θ+3×Θ 2 +2×Θ .As for linear logic, there are four constants , ⊥, 0, 1, two unary operators ! and ?, five binary operators &, `, ⊗, ⊕, and two binding operators ∀ and ∃.The associated (algebraic) signature is By universality of the coproduct, a model of Σ LJ is given by a monad R with module morphisms: and similarly, we can decompose an action of Σ LL into as many components as there are operators.
The definition of r α is then straightforward to devise, following the recursive clauses given on the right: The induced action of Σ LJ in the monad ΣLL yields the desired translation morphism o : ΣLJ → ΣLL .Note that variables are automatically preserved by the translation because o is a monad morphism.

Example: Computing the set of free variables
As above, we denote by PX the powerset of X.The union gives us a composition operator P(PX) → PX defined by u → s∈u s, which yields a monad structure on P.

XX:13
We now define an action of the signature of lambda calculus Σ LC in the monad P. We take the binary union operator ∪ : P × P → P as action of the application signature Θ × Θ in P; this is a module morphism since binary union distributes over union of sets.Next, given S ∈ P(X + * ) we define Maybe −1 X (S) = S ∩ X.This defines a morphism of modules Maybe −1 : P → P; a small calculation using a distributivity law of binary intersection over union of sets shows that this natural transformation is indeed linear.It can hence be used to model the abstraction signature Θ in P.
Associated to this model of Σ LC in P we have an initial morphism free : LC → P.Then, for any t ∈ LC(X), the set free(t) is the set of free variables occurring in t.

Example: Computing the size of a term
We now consider the problem of computing the 'size' of a λ-term, that is, for any set X, a function s X : LC(X) −→ N such that To express this map as a morphism of models, we first need to find a suitable monad underlying the target model.The first candidate, the constant functor X → N, does not admit a monad structure; the problem lies in finding a suitable unit for the monad.(More generally, given a monad R and a set A, the functor X → R(X)×A does not admit a monad structure whenever A is not a singleton.) This problem hints at a different approach to the original question: instead of computing the size of a term (which is 0 for a variable), we compute a generalized size gs which depends on arbitrary (formal) sizes attributed to variables.We have gs : Here, unsurprisingly, we recognize the continuation monad (see also [28] for the use of continuation for implementing complicated recursion schemes using initiality) Now we can define gs through initiality by endowing the monad Cont N with a structure of Σ LC -model as follows.
The function α(m, n) = 1 + m + n induces a natural transformation thus an action for the application signature Θ × Θ in the monad Cont N .Next, given a set X and k : X → N, define k : X + { * } → N by k(x) = k(x) for all x ∈ X and k( * ) = 0.This induces a function which is the desired action of the abstraction signature Θ .Altogether, the transformations c app and c abs form the desired action of Σ LC in Cont N and thus give an initial morphism, i.e., a natural transformation ι : LC → Cont N which respects the Σ LC -model structure.Now let 0 X be the function that is constantly zero on X.Then the sought 'size' map s : X:Set LC(X) → N is given by s X (t) = ι X (t, 0 X ).

Example: Counting the number of redexes
We now consider an example of recursive computation: a function r such that r(t) is the number of redexes of the λ-term t of LC(X).Informally, the equations defining r are r(x) = 0, (x variable) In order to compute recursively the number of β-redexes in a term, we need to keep track, not only of the number of redexes in subterms, but also whether the head construction of subterms is the abstraction; in the affirmative case we use the value 1 and 0 otherwise.Hence, we define a Σ LC -action on the monad W := Cont N×{0,1} .We denote by π 1 , π 2 the projections that access the two components of the product N × {0, 1}.
For any set X and function k : X → N × {0, 1}, let us denote by k : X + { * } → N × {0, 1} the function which sends x ∈ X to k(x) and * to (0, 0).Now, consider the function Then c abs is an action of the abstraction signature Θ in W . Next, we specify an action c app : W × W → W of the application signature Θ × Θ: Given a set X, consider the function Then c app is an action of the abstraction signature Θ × Θ in W .

Presentations of signatures and syntaxes
In this section, we identify a superclass of algebraic signatures that are still representable: we call them presentable signatures.
Definition 34.Given a signature Σ, a presentation12 of Σ is given by an algebraic signature Υ and an epimorphism of signatures p : Υ −→ Σ.In that case, we say that Σ is presented by p : Υ −→ Σ.
A signature for which a presentation exists is called presentable.
Unlike representations, presentations for a signature are not essentially unique; indeed, signatures can have many different presentations.
Remark.By definition, any construction which can be encoded through a presentable signature Σ can alternatively be encoded through any algebraic signature 'presenting' Σ.
The former encoding is finer than the latter in the sense that terms which are different in the latter encoding can be identified by the former.In other words, a certain amount of semantics is integrated into the syntax.
The main desired property of our presentable signatures is that, thanks to the following theorem, they are representable: Theorem 35 (PresentableisRepresentable).Any presentable signature is representable.
The proof is discussed in Section 8.
Using the axiom of choice, we can prove a stronger statement: Theorem 36 (is_right_adjoint_functor_of_reps_from_pw_epi_choice).We assume the axiom of choice.Let Σ be a signature, and let p : Υ −→ Σ be a presentation of Σ.Then the functor p * : Mon Σ −→ Mon Υ has a left adjoint.
In the proof of Theorem 36, the axiom of choice is used to show that endofunctors on Set preserve epimorphisms.
Theorem 35 follows from Theorem 36 since the left adjoint p ! : Mon Υ −→ Mon Σ preserves colimits, in particular, initial objects.However, Theorem 35 is proved in Section 8 without appealing to the axiom of choice: there, only some specific endofunctor on Set is considered, for which preservation of epimorphisms can be proved without using the axiom of choice.
Definition 37. We call a syntax presentable if it is generated by a presentable signature.

Next, we give important examples of presentable signatures:
Theorem 38.The following hold: 1. Any algebraic signature is presentable.

The product of two presentable signatures is presentable (har_ binprodR_ isPresentable
in the case when one of them is Θ).
Proof.Items 1-2 are easy to prove.For Item 3, if Σ 1 and Σ 2 are presented by i Υ i and Corollary 39.Any colimit of algebraic signatures is representable.

Proof of Theorem 35
In this section, we prove Theorem 35.This proof is mechanically checked in our library; the reader may thus prefer to look at the formalised statements in the library.Note that the proof of Theorem 35 rests on the more technical Lemma 44 below.
Proposition 40 (epiSig_equiv_pwEpi_SET).Epimorphisms of signatures are exactly pointwise epimorphisms.Using this characterization of epimorphisms, the proof follows from the fact that colimits are computed pointwise in the category of signatures.
Another important ingredient will be the following quotient construction for monads.Let R be a monad preserving epimorphisms, and let ∼ be a 'compatible' family of relations on (the functor underlying) R, that is, for any X : Set 0 , ∼ X is an equivalence relation on RX such that, for any f : X → Y , the function R(f ) maps related elements in RX to related elements in RY .Taking the pointwise quotient, we obtain a quotient π : R → R in the functor category, satisfying the usual universal property.We want to equip R with a monad structure that upgrades π : R → R into a quotient in the category of monads.In particular, this means that we need to fill in the square with a suitable µ : R • R −→ R satisfying the monad laws.But since π, and hence π • π, is epi as R preserves epimorphisms, this is possible when any two elements in RRX that are mapped to the same element by π • π (the left vertical morphism) are also mapped to the same element by π • µ (the top-right composition).It turns out that this is the only extra condition needed for the upgrade.We summarize the construction in the following lemma: Lemma 41 (projR_monad).Given a monad R preserving epimorphisms, and a compatible relation ∼ on R such that for any set X and x, y ∈ RRX, we have that if Then we can construct the quotient π : R → R in the category of monads, satisfying the usual universal property.
Note that the axiom of choice implies that epimorphisms have a retraction, and thus that any endofunctor on Set preserves epimorphisms.Definition 42.An epi-signature is a signature Σ that preserves the epimorphicity in the category of endofunctors on Set: for any monad morphism f : R −→ S, if U (f ) is an epi of functors, then so is U (Σ(f )).Here, we denote by U the forgetful functor from monads resp.modules to endofunctors.
We are now in a position to state and prove the main technical lemma: Lemma 44 (push_initiality).Let Υ be representable, such that both Υ and Υ( Υ) preserve epimorphisms (as noted above, this condition is automatically fulfilled if one assumes the axiom of choice).Let F : Υ → Σ be a morphism of signatures.Suppose that Υ is an epi-signature and F is an epimorphism.Then Σ is representable.

Sketch of the proof.
As before, we denote by Υ the initial Υ-model, as well as-by abuse of notation-its underlying monad.For each set X, we consider the equivalence relation ∼ X on Υ(X) defined as follows: for all x, y ∈ Υ(X) we stipulate that x ∼ X y if and only if i X (x) = i X (y) for each (initial) morphism of Υ-models i : Υ → F * S with S a Σ-model and F * S the Υ-model induced by F : Υ → Σ.
Per Lemma 41, as Υ preserves epimorphisms, we obtain the quotient monad, which we call Υ/F , and the epimorphic projection π : Υ → Υ/F .We now equip Υ/F with a Σ-action, and show that the induced model is initial, in four steps: In this section, we show that, besides algebraic signatures, there are other interesting examples of signatures which are presentable, and which hence can be safely added to any presentable signature.Safely here means that the resulting signature is still presentable.

Post-composition with a presentable functor
Definition 46.Let G : Set → Set be a functor.A presentation of G is a pair consisting of a polynomial functor F : Set → Set and an epimorphism p : F → G.The functor G is called presentable if there is a presentation of G.
Proposition 47.Given a presentable functor G, the signature G • Θ is presentable.

Proposition 48. Here we assume the axiom of excluded middle. An endofunctor on Set is presentable if and only if it is finitary (i.e., it preserves filtered colimits).
Proof.This is a corollary of Proposition 5.2 of [2], since ω-accessible functors are exactly the finitary ones.
We now give several examples of presentable signatures obtained from presentable functors.

Example: Adding a syntactic commutative binary operator, e.g., parallel-or
Consider the functor square : Set → Set mapping a set X to X × X; it is polynomial.The associated signature square • Θ encodes a binary operator, such as the application of the lambda calculus.Sometimes such binary operators are asked to be commutative; a simple example of such a commutative binary operator is the addition of two numbers.
Another example, more specific to formal computer languages, is a 'concurrency' operator P | Q of a process calculus, such as the π-calculus, for which it is natural to require commutativity as a structural congruence relation: Such a commutative binary operator can be specified via the following presentable signature: we denote by S 2 : Set → Set the endofunctor that assigns, to each set X, the set (X × X)/(x, y) ∼ (y, x) of unordered pairs of elements of X.This functor is presented by the obvious projection square → S 2 .By Proposition 47, the signature S 2 • Θ is presentable; it encodes a commutative binary operator.

Example: Adding a maximum operator
Let list : Set → Set be the functor associating, to any set X, the set list(X) of (finite) lists with entries in X; specifically, it is given on objects as X → n∈N X n .
We now consider the syntax of a "maximum" operator, acting, e.g., on a list of natural numbers: max : list(N) → N It can be specified via the algebraic signature list • Θ.
However, this signature is 'rough' in the sense that it does not take into account some semantic aspects of a maximum operator, such as invariance under repetition or permutation of elements in a list.
For a finer encoding, consider the functor P fin : Set → Set associating, to a set X, the set P fin (X) of its finite subsets.This functor is presented by the epimorphism list → P fin .
By Proposition 47, the signature P fin • Θ is presentable; it encodes the syntax of a 'maximum' operator accounting for invariance under repetition or permutation of elements in a list.

Example: Adding an application à la Differential LC
Let R be a commutative (semi)ring.To any set S, we can associate the free R-module R S ; its elements are formal linear combinations s∈S a s s of elements of S with coefficients a s from R; with a s = 0 almost everywhere.Ignoring the R-module structure on R S , this assignment induces a functor R _ : Set → Set with the obvious action on morphisms.for simplicity, we restrict our attention to the semiring (N, +, ×).
This functor is presentable: a presentation is given by the polynomial functor list : Set → Set, and the epimorphism By Proposition 47, this yields a presentable signature, which we call N Θ .The Differential Lambda Calculus (DLC) [12] of Ehrhard and Regnier is a lambda calculus with operations suitable to express differential constructions.The calculus is parametrized by a semiring R; again we restrict to R = (N, +, ×).
DLC has a binary 'application' operator, written (s)t, where s ∈ T is an element of the inductively defined set T of terms and t ∈ N T is an element of the free (N, +, ×)-module.This operator is thus specified by the presentable signature Θ × N Θ .

Example: Adding a syntactic closure operator
Given a quantification construction (e.g., abstraction, universal or existential quantification), it is often useful to take the associated closure operation.One well-known example is the universal closure of a logic formula.Such a closure is invariant under permutation of the fresh variables.A closure can be syntactically encoded in a rough way by iterating the closure with respect to one variable at a time.Here our framework allows a refined syntactic encoding which we explain below.
Let us start with binding a fixed number k of fresh variables.The elementary signature Θ (k) already specifies an operation that binds k variables.However, this encoding does not reflect invariance under variable permutation.To enforce this invariance, it suffices to quotient the signature Θ (k) with respect to the action of the group S k of permutations of the set k, that is, to consider the colimit of the following one-object diagram: where σ ranges over the elements of S k .We denote by S (k) Θ the resulting signature presented by the projection Θ (k) → S (k) Θ.By universal property of the quotient, a model of it consists of a monad R with an action m : R (k) → R that satisfies the required invariance.Now, we want to specify an operation which binds an arbitrary number of fresh variables, as expected from a closure operator.One rough solution is to consider the coproduct k S (k) Θ.However, we encounter a similar inconvenience as for Θ (k) .Indeed, for each k > k, each term already encoded by the signature S (k) Θ may be considered again, encoded (differently) through S (k ) Θ.
Fortunately, a finer encoding is provided by the following simple colimit of presentable signatures.The crucial point here is that, for each k, all natural injections from Θ (k) to Θ (k+1) induce the same canonical injection from S (k) Θ to S (k+1) Θ.We thus have a natural colimit for the sequence k → S (k) Θ and thus a signature colim k S (k) Θ which, as a colimit of presentable signatures, is presentable.(Theorem 38, Item 2).
Accordingly, we define a total closure on a monad R to be an action of the signature colim k S (k) Θ in R. It can easily be checked that a model of this signature is a monad R together with a family of module morphisms (e k : R (k) → R) k∈N compatible in the sense that for each injection i : k → k the following diagram commutes:

Example: Adding an explicit substitution
Explicit substitution was introduced by Abadi et al. [1] as a theoretical device to study the theory of substitution and to describe concrete implementations of substitution algorithms.In this section, we explain how we can extend any presentable signature with an explicit substitution construction, and we offer some refinements from a purely syntactic point of view.In fact, we will show three solutions, differing in the amount of 'coherence' which is handled at the syntactic level (e.g., invariance under permutation and weakening).We follow the approach initiated by Ghani, Uustalu, and Hamana in [19].
Let R be a monad.We have already considered (see Lemma 12) the (unary) substitution σ R : R × R → R.More generally, we have the sequence of substitution operations subst p : R (p) × R p −→ R. ( We say that subst p is the p-substitution in R; it simultaneously replaces the p extra variables in its first argument with the p other arguments, respectively.(Note that subst 1 is the original σ R ).We observe that, for fixed p, the group S p of permutations on p elements has a natural action on R (p) × R p , and that subst p is invariant under this action.
Thus, if we fix an integer p, there are two ways to internalise subst p in the syntax: we can choose the elementary signature Θ (p) × Θ p , which is rough in the sense that the above invariance is not reflected; and, alternatively, if we want to reflect the permutation invariance syntactically, we can choose the quotient Q p of the above signature by the action of S p .
By universal property of the quotient, a model of our quotient Q p is given by a monad R with an action m : R (p) × R p → R satisfying the desired invariance.
Before turning to the encoding of the entire series (subst p ) p∈N , we recall how, as noticed already in [19], this series enjoys further coherence.In order to explain this coherence, we start with two natural numbers p and q and the module R (p) × R q .Pairs in this module are almost ready for substitution: what is missing is a map u : I p −→ I q .But such a map can be used in two ways: letting u act covariantly on the first factor leads us into R (q) × R q where we can apply subst q ; while letting u act contravariantly on the second factor leads us into R (p) × R p where we can apply subst p .The good news is that we obtain the same result.More precisely, the following diagram is commutative: Note that in the case where p equals q and u is a permutation, we recover exactly the invariance by permutation considered earlier.
Abstracting over the numbers p, q and the map u, this exactly means that our series factors through the coend p:N R (p) × R p , where covariant (resp.contravariant) occurrences of the bifunctor have been underlined (resp.overlined), and the category N is the full subcategory of Set whose objects are natural numbers.Thus we have a canonical morphism isubst R : Abstracting over R, we obtain the following: Definition 49.The integrated substitution isubst : is the signature morphism obtained by abstracting over R the linear morphisms isubst R .
Thus, if we want to internalise the whole sequence (subst p ) p:N in the syntax, we have at least three solutions: we can choose the algebraic signature p:N Θ (p) × Θ p which is rough in the sense that the above invariance and coherence is not reflected; we can choose the presentable signature p:N Q p , which reflects the invariance by permutation, but not more; and finally, if we want to reflect the whole coherence syntactically, we can choose the presentable signature Thus, whenever we have a presentable signature, we can safely extend it by adding one or the other of the three above signatures, for a (more or less coherent) explicit substitution.
Ghani, Uustalu, and Hamana already studied this problem in [19].Our solution proposed here does not require the consideration of a strength.

Example: Adding a coherent fixed-point operator
In the same spirit as in the previous section, we define, in this section, for each n ∈ N, a notion of n-ary fixed-point operator in a monad; a notion of coherent fixed-point operator in a monad, which assigns, in a 'coherent' way, to each n ∈ N, an n-ary fixed-point operator.
We furthermore explain how to safely extend any presentable syntax with a syntactic coherent fixed-point operator.
There is one fundamental difference between the integrated substitution of the previous section and our coherent fixed points: while every monad has a canonical integrated substitution, this is not the case for coherent fixed-point operators.
Let us start with the unary case.
Definition 50.A unary fixed-point operator for a monad R is a module morphism f from R to R that makes the following diagram commute, where σ is the substitution morphism defined in Lemma 12.
Accordingly, the signature for a syntactic unary fixpoint operator is Θ , ignoring the commutation requirement (which we plan to address in a future work by extending our framework with equations).
Let us digress here and examine what the unary fixpoint operators are for the lambda calculus, more precisely, for the monad LC βη of the lambda-calculus modulo β-and ηequivalence.How can we relate the above notion to the classical notion of fixed-point combinator?Terms are built out of two constructions, app : LC βη × LC βη → LC βη and abs : LC βη → LC βη .A fixed-point combinator is a term Y satisfying, for any (possibly open) term t, the equation app(t, app(Y, t)) = app(Y, t).
Given such a combinator Y , we define a module morphism Ŷ : LC βη → LC βη .It associates, to any term t depending on an additional variable * , the term Ŷ (t) := app(Y, abs t).This term satisfies t[ Ŷ (t)/ * ] = Ŷ (t), which is precisely the diagram of Definition 50 that Ŷ must satisfy to be a unary fixed-point operator for the monad LC βη .Conversely, we have: Proposition 51.Any fixed-point combinator in LC βη comes from a unique fixed-point operator.
Proof.We construct a bijection between the set LC βη ∅ of closed terms on the one hand and the set of module morphisms from LC βη to LC βη satisfying the fixed-point property on the other hand.
A closed lambda term t is mapped to the morphism u → t u := app(t, abs u).We have already seen that if t is a fixed-point combinator, then t is a fixed-point operator.
A small calculation shows that Y → Ŷ and f → Y f are inverse to each other.
Definition 53.Given a monad R, we define a coherent fixed-point operator on R to be a module morphism from n:N n × (R (n) ) n to R where, for every n ∈ N, the n-th component is a (rough) 14 n-ary fixpoint operator.Now, the natural signature for a syntactic coherent fixed-point operator is n:N n × (Θ (n) ) n .Thus, given a presentable signature Σ, we can safely extend it with a syntactic coherent fixed-point operator by adding the presentable signature to Σ.

Conclusions and future work
We have presented notions of signature and model of a signature.A representation of a signature is an initial object in its category of models-a syntax.We have defined a class of presentable signatures, which contains traditional algebraic signatures, and which is closed under various operations, including colimits.One of our main results says that any presentable signature is representable.Despite the fact that the constructions in Section 8 make heavy use of quotients, there is no need to appeal to the axiom of choice.While a previous version of our formalisation did use the axiom of choice to show that certain functors preserve epimorphisms, we managed subsequently to prove this without using the axiom of choice.This analysis, and subsequent reworking, of the proof was significantly helped by the formalisation.
One difference to other work on Initial Semantics, e.g., [30,18,13,15], is that we do not rely on the notion of strength.However, a signature endofunctor with strength as used in the aforementioned articles can be translated to a high-level signature as presented in this work (Proposition 21).
We plan to generalize our representability criterion to encompass explicit join (see [30]); to generalize our notions of signature and models to (simply-)typed syntax; and to provide a systematic approach to equations for our notion of signature and models.

Example 15 . 1 . 2 . 3 . 4 .
Hence a signature assigns, to each monad R, a module over R in a functorial way.Definition 14.A signature is a section of the forgetful functor from the category Mod to the category Mon.Now we give our basic examples of signatures.The assignment R → R yields a signature, which we denote by Θ.For any functor F : Set −→ Set and any signature Σ, the assignment R → F • Σ(R) yields a signature which we denote F • Σ.The assignment R → * R , where * R denotes the final module over R, yields a signature which we denote by * .Given two signatures Σ and Υ, the assignment R → Σ(R) × Υ(R) yields a signature

Remark 17 .
The product of two elementary signatures is elementary.Definition 18.A morphism between two signatures Σ 1 , Σ 2 : Mon −→ Mod is a natural transformation m : Σ 1 −→ Σ 2 which, post-composed with the projection Mod −→ Mon, becomes the identity.Signatures form a subcategory Sig of the category of functors from Mon to Mod.

Definition 29 .
that is, it commutes suitably with the Σ-actions of Diagram (2) in the source and r : Σ(R) −→ R in the target.Given a model M of Σ, we denote by M the Σ-model constructed in Lemma 28, and by M : M −→ M the morphism of models defined there.

Proof.
In any category, a morphism f : a → b is an epimorphism if and only if the following diagram is a pushout diagram ([29, Exercise III.4.4]) :