Algebraic Language Theory for Eilenberg--Moore Algebras
aa r X i v : . [ c s . F L ] J un Algebraic Language Theory forEilenberg–Moore Algebras
Achim Blumensath ∗ Contents
There are various approaches to formal language theory, each having its ownstrengths and weaknesses. We are here interested in the algebraic approach – inparticular, in its use in characterising subclasses of regular languages, like theclass of first-order definable languages.The initial algebraic theory was developed for languages of finite words. It hassubsequently been generalised, first to infinite words (see, e.g., [19]) and then tofinite trees (e.g., [11]). More recently, also a framework for dealing with infinitetrees was developed [8, 4, 9, 5, 6, 2]. Each of these four theories comes in severaldifferent variants, depending on which notion of a language or a logic they weredesigned for. As usual when such a wealth of slightly different settings has beendeveloped, people have started to consolidate and unify them. One well-knownproposal of this kind, based on the formalism of Eilenberg–Moore algebras, was ∗ Work partially supported by the Czech Science Foundation, grant No. GA17-01035S denseness and M -compositionality, which we will introduce below). This in turn providesinsight into how far the methods used can be extended and where their limitsare.Finally, in a concrete case there are often several possible variations of thedefinitions that more-or-less work equally well. Knowing which of them general-ises helps one to evaluate their respective merits.Besides hopefully improving upon the presentation, the main contributionsof the present article lie in two areas. Firstly, we present the first framework thatdoes support algebras with infinitely many sorts, which is required when onewants to cover the concrete frameworks that have been introduced for languagesof infinite trees. While it turns out that many results and proofs go through forinfinitely many sorts with nearly no changes, there are also a few places belowwhere we are forced to make substantial adjustments. In particular, we introducethe notion of a dense morphism of monads in Section 4 to prove the existenceof syntactic algebras, and we have to modify the definition of a pseudo-varietyin Section 5 by adding closure under so-called sort-accumulation points. Secondly, the existing frameworks concentrate on the algebraic and language-theoretic side of things, while mostly ignoring the connections to logic. This israther unfortunate, as logic is one of the main application areas for algebraiclanguage theory. We will therefore devote a substantial part of the article to theconnection between the algebraic theory and the study of logics.The overview of the article is as follows. In Section 2 we set up the basictoolkit of monads and Eilenberg–Moore algebras which our algebraic frameworkis based on. Our preparations continue in Section 3 with the development of atheory of quotients and congruences for such algebras.Our algebraic framework is set up in Sections 4–6. The central notions ofa syntactic congruence and a syntactic algebra are introduced in Section 4.Equipped with these tools, we study pseudo-varieties in Section 5 and deriveour version of the Variety Theorem. The corresponding version of Reiterman’sTheorem is then presented in Section 6.The second part of the article consists of Sections 7–9. We start by collectinga few basic notions from logic in Section 7. Section 8 contains the connection tolanguage theory in terms of algebras whose products are definable in a certainsense. Finally in Section 9, we show how one can apply our framework to studymonadic second-order logic and first-order logic over infinite trees.2
Monads and algebras
We assume that the reader is reasonably familiar with basic notions of categorytheory. But in order to make the article more accessible to readers from otherfields, we have tried not to rely on any concepts that are not covered by theusual introductory text books. As a consequence we will explicitly define anyof the more specialised notions needed below – such as that of a monad or acopresentable object.Let me also make a philosophical remark. In this article I have tried to strikea balance between the level of generality of the framework and the technicaloverhead entailed by it. For this reason, many of the results below will not bestated in the most general form possible. Instead, I have adopted a level ofgenerality that covers (most of) the intended applications while not obscuringthe proofs by pointless technicalities. In particular, the framework below is notpresented in a purely category-theoretical language, but in a mixture of settheory and category theory.In formal language theory one studies sets of labelled objects like words,trees, traces, pictures, (hyper-)graphs, and so on. To capture all these varioussettings we start by introducing an operation M mapping a given set A of labelsto the set M A of all A -labelled objects. A language in this context is thensimply a subset K ⊆ M A . For instance, for languages of finite words we candefine M A := A + . To accommodate more complicated settings like trees, itwill be convenient to work not with plain sets but with many-sorted ones. For agiven set Ξ of sorts, an Ξ -sorted set is a family A = ( A ξ ) ξ ∈ Ξ of plain sets. Then M maps a Ξ -sorted set A of labels to a Ξ -sorted set M A = ( M ξ A ) ξ ∈ Ξ of A -labelled objects. For instance, when working with infinite words it is convenient touse two sorts Ξ = { , ∞} where sort represent the ‘finite’ elements and sort ∞ the ‘infinite’ ones. The operation M maps A = h A , A ∞ i to M A = h M A, M ∞ A i where M A := A +1 and M ∞ A := A +1 A ∞ ∪ A ω . Our intended applications consist in deriving characterisation results for variouslogics. To be able to handle logics that are not closed under negation, it willturn out to be necessary to be slightly more general and consider ordered many-sorted sets, that is, Ξ -sorted sets A = ( A ξ ) ξ ∈ Ξ where each sort A ξ is equippedwith a partial order. Such sets form a category Pos Ξ if we take as morphismsthe order-preserving Ξ -sorted functions, that is, a morphism f : A → B consistsof a family f = ( f ξ ) ξ ∈ Ξ of functions where each component f ξ : A ξ → B ξ isorder-preserving. We will frequently identify a sorted set A = ( A ξ ) ξ ∈ Ξ with itsdisjoint union A = · S ξ ∈ Ξ A ξ . Using this point of view, a morphism f : A → B corresponds to a sort-preserving and order-preserving function between thecorresponding disjoint unions.Before continuing let us introduce a bit of terminology. From this point on,we will use the terms ‘set’ and ‘function’ as a short-hand for ’ordered Ξ -sortedset’ and ‘order-preserving Ξ -sorted function’. If we mean any other sort of setor function, we will mention this explicitly. We call a set A ∈ Pos Ξ unordered if its ordering is trivial, i.e., any two distinct elements are incomparable. Fora property P , we say that A is sort-wise P if each set A ξ has property P . Inparticular, sort-wise finite means that every A ξ is finite.3f course, the operation M alone does not provide sufficient structure tobuild a meaningful theory. Usually, the objects in a formal language are subjectto various composition operations, like concatenation of words, substitution forterms, etc.. To capture such operations we will employ the category-theoreticalnotion of a monad. Note that, in the cases of interest where M A is a set of A -labelled objects of some kind, every function f : A → B induces an operation M f : M A → M B which applies the function f to each label. This turns M intoa functor Pos Ξ → Pos Ξ .There are two other ingredients we will need. Firstly, the concatenationoperation in question is often of the form flat : MM A → M A , that is, it takes an M A -labelled object s ∈ MM A and assembles the appearing labels into a singleelement of M A . We call flat( s ) the flattening of s . Secondly, there is usuallya singleton operation sing : A → M A that takes a label a ∈ A and producesan object with a single position which is labelled by a . For instance, in thecase of words flat : ( A + ) + → A + is simply the concatenation operation and sing : A → A + produces -letter words. flat( h w , . . . , w n i ) := w . . . w n , for w , . . . , w n ∈ A + , sing( a ) := h a i , for a ∈ A .
Usually, the flattening operation is associative, which makes the functor M intoa monad. Definition 2.1. A monad consists of a functor M : Pos Ξ → Pos Ξ that isequipped with two natural transformations flat : M ◦ M ⇒ M and sing : Id ⇒ M (where Id is the identity functor) satisfying the following equations. flat ◦ sing = id , flat ◦ M sing = id , flat ◦ flat = flat ◦ M flat . M A MM A M A M A MMM A MM A MM A M A singid M singflat id flat M flat flatflat y In algebraic language theory one equips the sets M A with an algebraic struc-ture of some kind and then uses homomorphisms M A → B into some otheralgebra B to describe languages K ⊆ M A . If M is a monad, there is a canonicalway to define this algebraic structure: we can equip a set A with a product op-eration of the form π : M A → A . For instance, for words this product takes theform π : A + → A , i.e., it multiplies a sequence of elements into a single element.Hence, π can be seen as a semigroup product of variable arity. But note thatnot every operation π : A + → A is of the form π ( h a , . . . , a m i ) = a · a · · · · · a m for some semigroup product · : A × A → A . If we want to exactly capture thenotion of a semigroup, we have to impose additional conditions on π . It turnsout, there are two such conditions: associativity requires that π ( π ( w ) , . . . , π ( w m )) = π ( w . . . w m ) , for all w , . . . , w m ∈ A + , π ( h a i ) = a , for a ∈ A .
These two conditions can be phrased more concisely as π ◦ M π = π ◦ flat and π ◦ sing = id . This leads us to the following definition.
Definition 2.2.
Let M : Pos Ξ → Pos Ξ be a monad.(a) An Eilenberg-Moore algebra for M , or M -algebra for short, is a pair A = h A, π i consisting of a set A and a function π : M A → A satisfying π ◦ M π = π ◦ flat ,π ◦ sing = id . The first of these equations is called the associative law for π , the second one the unit law. M A A MM A M A π M π flat π (b) A morphism ϕ : A → B of M -algebras is a function ϕ : A → B commut-ing with the respective products in the sense that ϕ ◦ π = π ◦ M ϕ . A B M A M B ϕπ M ϕ π (c) We denote the category of all M -algebras and their morphisms by Alg ( M ) . y As a further example, let us take a look at the functor M h A , A ∞ i := h A +1 , A +1 A ∞ ∪ A ω i for infinite words. In this case an M -algebra has two product functions π : A +1 → A and π ∞ : A +1 A ∞ ∪ A ω → A ∞ . The laws of an M -algebra ensure that π corresponds to a semigroup product A × A → A and π ∞ correspond to the additional products A × A ∞ → A ∞ and A ω → A ∞ of an ω -semigroup. Hence, in this case M -algebras are nothingbut ω -semigroups.There is a natural way to turn a set of the form M A into an M -algebra: wecan chose the function flat : MM A → M A as the product. It turns out thatalgebras of this form are exactly the free algebras. Proposition 2.3.
For each ranked set A , there exists a free M -algebra over A .It has the form h M A, flat i .Proof. The fact that flat : MM A → M A is the free M -algebra is a standardresult in category theory. As the functor M is a monad, it is left adjoint to theforgetful functor Alg ( M ) → Pos Ξ which maps a M -algebra B to its universe B M -algebra B andevery function f : A → B , there exists a unique morphism ϕ : M A → B suchthat ϕ ◦ sing = f .In order to obtain non-trivial results we have to put some mild restrictionson the kind of monad M we consider. In the applications we have in mind, M isalways a polynomial functor of the form M A = X i<λ A D i , for some cardinal λ and unordered sets D i ∈ Set Ξ . For instance, for the wordfunctor M A = A + , we can take λ = ℵ and D i = { , . . . , i } . Similarly, if weconsider languages of trees, we can fix an enumeration ( t i ) i<λ of all unlabelledtrees and choose for D i the set of vertices of t i .For the results in this article, we do not need to assume that M is polynomial.Two weaker properties suffices. To state these, we have to introduce a bit ofterminology. Definition 2.4.
Let M : Pos Ξ → Pos Ξ be a functor.(a) The lift of a relation R ⊆ A × B is the relation R M ⊆ M A × M B consistingof all pairs h s, t i such that s = M p ( u ) and t = M q ( u ) , for some u ∈ M R , where p : A × B → A and q : A × B → B are the two projections.(b) We say that M uses the standard ordering if the ordering of M A is thelift ≤ M of the ordering ≤ of A .(c) We say that M preserves injectivity/surjectivity/bijectivity if it mapsinjective/surjective/bijective functions to functions of the same kind. y For our framework we require the following properties of M , which are clearlyshared by every polynomial functor. Convention.
In the following we will always tacitly assume that M : Pos Ξ → Pos Ξ is a monad which preserves surjectivity and bijectivity and which uses thestandard ordering. An example of a functor that does not fit into this framework would be thefunctor P mapping a set A to its power set.Let us derive a first consequence of our assumptions. A frequent problem wewill have to deal with is the fact that in Pos Ξ not every surjective morphism hasa right inverse. Therefore, we will sometimes be forced to make a detour throughthe category Set Ξ by ignoring the order of the sets involved. For simplicity, wewill treat Set Ξ as a full subcategory of Pos Ξ via the following embedding. Definition 2.5. (a) Let V : Pos Ξ → Pos Ξ be the functor mapping a set A withorder ≤ to the same set, but with the trivial order = , and let ι : V ⇒ Id thenatural transformation induced by the identity maps.(b) A functor M : Pos Ξ → Pos Ξ is order agnostic if there exists a naturalisomorphism δ : M ◦ V ⇒ V ◦ M satisfying6 ι = ι ◦ δ and V sing = δ ◦ sing . M A VM A MV A V A ι M ιδ V sing sing y Intuitively, being order agnostic means that M does not make essential use ofthe ordering of a set A when producing M A . The ordering of A has no influenceon which elements M A contains, only on the ordering between them. Lemma 2.6. If M satisfies the above assumption, it is order agnostic.Proof. We start by showing that each set of the form MV A has the trivial order.Hence, suppose that s, t ∈ MV A with s ≤ t . As M uses the standard ordering,we can find some u ∈ M ∆ with s = M p ( u ) and t = M q ( u ) , where ∆ ⊆ A × A is the ordering of V A and p, q : A × A → A are the two projections. Note that ∆ = { h a, a i | a ∈ A } is the diagonal. Consequently, we have p ( d ) = q ( d ) , for all d ∈ ∆ , which implies that s = M p ( u ) = M q ( u ) = t .It follows that VMV A = MV A and the respective identity maps providemorphisms i : MV A → VMV A and j : V A → VV A that are inverse to thefunctions ι : VMV A → MV A and ι : VV A → V A . We claim that the morphism δ := VM ι ◦ i : MV A → VM A is the desired natural transformation. First, notethat δ is bijective, as i and ι are bijective and both V and M preserve bijectivity.Since the domain MV A and the codomain VM A both use the trivial order, δ therefore has an inverse. To conclude the proof it is hence sufficient to showthat the following diagram commutes. M A VM A MV A VMV A VV A V A ι M ιδ iι VM ι V sing V sing sing ιj Since V ι = ι it follows that ι ◦ δ = ι ◦ VM ι ◦ i = M ι ◦ ι ◦ i = M ι and δ ◦ sing = VM ι ◦ i ◦ sing = VM ι ◦ i ◦ sing ◦ ι ◦ j = VM ι ◦ i ◦ ι ◦ V sing ◦ j = VM ι ◦ V sing ◦ j = V (sing ◦ ι ) ◦ j = V sing ◦ ( V ι ◦ j ) = V sing ◦ ( ι ◦ j ) = V sing . We start by developing a theory of congruences for M -algebras. Most of thearguments in this section are quite standard, but we did not find them worked7ut for EilenbergâĂŞMoore algebras anywhere in the literature. We begin bylooking at quotients of ordered sets. Then we will turn to M -algebras. Definition 3.1.
Let A be an ordered set and ⊑ ⊆ A × A a preorder with ≤ ⊆ ⊑ .(a) The kernel of a function f : A → B is the relation ker f := { h a, a ′ i ∈ A × A | f ( a ) ≤ f ( a ′ ) } . (b) For a ∈ A and X ⊆ A , we set ⇑ a := { b ∈ A | b ≥ a } and ⇑ X := [ a ∈ X ⇑ a . (c) The set of ⊑ -classes is A/ ⊑ := { [ a ] ⊑ | a ∈ A } where [ a ] ⊑ := { b ∈ A | b ⊑ a and a ⊑ b } . We equip it with the ordering [ a ] ⊑ ≤ [ b ] ⊑ : iff a ⊑ b . (d) The quotient map q : A → A/ ⊑ maps a ∈ A to [ a ] ⊑ .(e) We say that ⊑ has finitary index if, for each sort ξ ∈ Ξ , the quotient A ξ / ⊑ is finite. y A very useful tool to construct quotients is the following lemma from uni-versal algebra.
Lemma 3.2 (Factorisation Lemma) . Let f : A → B and g : A → C be functionsand assume that f is surjective. Then g = h ◦ f , for some h : B → C , if andonly if ker f ⊆ ker g . Moreover, the function h is unique, if it exists.Proof. The uniqueness of h follows from the surjectivity of f , since surjectivefunctions are epimorphisms: h ◦ f = g = h ′ ◦ f implies h = h ′ . Hence, it remainsto consider existence. ( ⇒ ) If g = h ◦ f , then f ( a ) ≤ f ( b ) implies g ( a ) = h ( f ( a )) ≤ h ( f ( b )) = g ( b ) . ( ⇐ ) Suppose that ker f ⊆ ker g . As f is surjective, it has a right inverse r (in Set Ξ , r might not be monotone). We claim that h := g ◦ r is the desiredfunction.For monotonicity, suppose that a ≤ b in B . Then f ( r ( a )) = a ≤ b = f ( r ( b )) implies h r ( a ) , r ( b ) i ∈ ker f ⊆ ker g . Consequently, h ( a ) = g ( r ( a )) ≤ g ( r ( b )) = h ( b ) .
8o show that g = h ◦ f , set e := r ◦ f . For a ∈ A , it follows that f ( e ( a )) = ( f ◦ r ◦ f )( a ) = f ( a ) . Hence, h a, e ( a ) i , h e ( a ) , a i ∈ ker f ⊆ ker g , which implies that g ( a ) = g ( e ( a )) .Thus g = g ◦ e = g ◦ r ◦ f = h ◦ f . In order to lift the statement of the Factorisation Lemma from functions tomorphisms, it is sufficient to prove that, if f and g are morphisms of M -algebras,so is h . Lemma 3.3.
Let f : A → B and g : A → C be morphisms of M -algebras and h : B → C a function such that g = h ◦ f . If f is surjective, then h is also amorphism of M -algebras.Proof. Note that h ◦ π ◦ M f = h ◦ f ◦ π = g ◦ π = π ◦ M g = π ◦ M h ◦ M f . Since f is surjective, so is M f . Therefore, the above equation implies that h ◦ π = π ◦ M h , i.e., that h is a morphism of M -algebras.In Set Ξ there also exists a dual to the statement of the Factorisation Lemma,but in Pos Ξ this version only holds in special cases as, in general, surjectivefunctions do not have right inverses. Let us record the following version whichwe will use a few times below. Lemma 3.4.
Let ϕ : M X → B and ψ : A → B be morphisms of M -algebraswhere X is an unordered set. If ψ is surjective, there exists some morphism ˆ ϕ : M X → A such that ϕ = ψ ◦ ˆ ϕ . M X A B ˆ ϕ ϕψ Proof. If ψ is surjective, we can pick, for every x ∈ X some element f ( x ) ∈ ψ − ( ϕ (sing( x ))) . This defines a function f : X → A with ψ ◦ f = ϕ ◦ sing (which is trivially monotone as X is unordered). As M X is freely generated bythe range of sing , we can extend f to a unique morphism ˆ ϕ : M X → A with ˆ ϕ ◦ sing = f . It follows that ψ ◦ ˆ ϕ ◦ sing = ψ ◦ f = ϕ ◦ sing . As the range of sing generates M X , this implies that ψ ◦ ˆ ϕ = ϕ .Next, let us define quotients for algebras instead of sets. Definition 3.5.
Let A be an M -algebra and ⊑ ⊆ A × A a preorder with ≤ ⊆ ⊑ .(a) For s, t ∈ M A , we set s ⊑ M t : iff M q ( s ) ≤ M q ( t ) , q : A → A/ ⊑ is the quotient map.(b) Let A be an M -algebra. The preorder ⊑ ⊆ A × A is a congruence ordering on A if s ⊑ M t implies π ( s ) ⊑ π ( t ) . (c) If ⊑ is a congruence ordering on A , we define the quotient A / ⊑ as thealgebra with universe A/ ⊑ and product π ( s ) := [ π ( s ′ )] ⊑ for s ′ ∈ ( M q ) − ( s ) , where q : A → A/ ⊑ the quotient map. y Remark.
It is straightforward to show that ⊑ M ⊆ ⊑ M . For most monads M ,these two relations are actuall equal, but our assumptions on M are not quitestrong enough to prove this in general. Proposition 3.6.
Let ⊑ be a congruence ordering on an M -algebra A . Thequotient A / ⊑ is a well-defined M -algebra and the quotient map q : A → A / ⊑ isa morphism of M -algebras.Proof. We have to check several properties.(a) To see that q is monotone, note that a ≤ b ⇒ a ⊑ b ⇒ q ( a ) ≤ q ( b ) . (b) To show that the product of A / ⊑ is well-defined, consider an element s ∈ M ( A/ ⊑ ) . Since M q is surjective, there exists at least one element s ′ ∈ ( M q ) − ( s ) that we can use to define π ( s ) . Now suppose that there are twosuch elements s ′ , s ′′ ∈ ( M q ) − ( s ) . As ⊑ is a congruence ordering, the equation M q ( s ′ ) = M q ( s ′′ ) then implies that π ( s ′ ) ⊑ π ( s ′′ ) and vice versa. Consequently, [ π ( s ′ )] ⊑ = [ π ( s ′′ )] ⊑ , as desired.(c) Next we prove that π ◦ M q = q ◦ π . Once we have shown that A / ⊑ isindeed an M -algebra, it then follows that q is a morphism. For the proof, let s ∈ M A . Then π ( M q ( s )) = [ π ( s )] ⊑ = q ( π ( s )) , where the first step holds by definition of the product.(d) For monotonicity of π , consider elements s, t ∈ M ( A/ ⊑ ) with s ≤ t .Fixing s ′ ∈ ( M q ) − ( s ) and t ′ ∈ ( M q ) − ( t ) , it follows that M q ( s ′ ) = s ≤ t = M q ( t ′ ) ⇒ s ′ ⊑ M t ′ ⇒ π ( s ′ ) ⊑ π ( t ′ ) ⇒ π ( s ) = q ( π ( s ′ )) ≤ q ( π ( t ′ )) = π ( t ) . (e) It remains to check the two axioms of an M -algebra. For the unit law,note that sing : Id ⇒ M is a natural transformation. Hence, we have sing ◦ q = M q ◦ sing . Together with (c) and the definition of the product it follows that π (sing([ a ] ⊑ )) = π ( M q (sing( a ))) = [ π (sing( a ))] ⊑ = [ a ] ⊑ . π ◦ M π ◦ MM q = π ◦ M q ◦ M π = q ◦ π ◦ M π = q ◦ π ◦ flat= π ◦ M q ◦ flat = π ◦ flat ◦ MM q . Fixing s ∈ MM A/ ⊑ and s ′ ∈ ( MM q ) − ( s ) , it therefore follows that π ( M π ( s )) = π ( M π ( MM q ( s ′ ))) = π (flat( MM q ( s ′ ))) = π (flat( s )) . As usual, we have defined our notion of a congruence such that congruencescorrespond to kernels of morphisms. We will establish this correspondence inProposition 3.8 below. But before doing so, let us take a closer look at theauxiliary relation ⊑ M . Lemma 3.7.
Let ⊑ be a preorder on A with ≤ ⊆ ⊑ . Then M ⊑ = h M p , M p i − [ ⊑ M ] , where p , p : A × A → A are the two projections.Proof. Let p ′ , p ′ : A/ ⊑ × A/ ⊑ → A/ ⊑ be the two projections, q : A → A/ ⊑ the quotient map, and let R be the ordering on A/ ⊑ and S the one on M ( A/ ⊑ ) .We consider the following diagram M ( A × A ) M ⊑ M ( A/ ⊑ × A/ ⊑ ) M ≤ M ( A/ ⊑ ) × M ( A/ ⊑ ) ≤ M M A × M A ⊑ M h M p , M p ih M p , M p i M ( q × q ) M ( q × q ) h M p ′ , M p ′ ih M p ′ , M p ′ i M q × M q M q × M q where the vertical arrows denote the respective inclusion maps. Let us firstexplain why this diagram commutes. Since in each square the vertical maps areinclusions and the top map is a restriction of the bottom one, it is sufficient toshow that the horizontal map maps the first of the given subsets to the secondone. That is, we have to show that M ( q × q )[ M ⊑ ] ⊆ M R , h M p ′ , M p ′ i [ M R ] ⊆ S , ( M q × M q )[ ⊑ M ] ⊆ S .
The first inclusion follows from the fact that q × q maps ⊑ to R by simplyapplying the functor M ; the second one holds since M uses the standard ordering;and the last inclusion follows immediately from the definition of ⊑ M .11o conclude the proof, note that we have even the stronger statements M ⊑ = M ( q × q ) − [ M R ] , M R = h M p ′ , M p ′ i − [ S ] , ⊑ M = ( M q × M q ) − [ S ] , and that h M p ′ , M p ′ i ◦ M ( q × q ) = ( M q × M q ) ◦ h M p , M p i . Hence, M ⊑ = M ( q × q ) − (cid:2) h M p ′ , M p ′ i − [ S ] (cid:3) = h M p , M p i − (cid:2) ( M q × M q ) − [ S ] (cid:3) = h M p , M p i − [ ⊑ M ] . We obtain the following characterisation of congruence orderings.
Proposition 3.8.
Let A be an M -algebra and ⊑ ⊆ A × A a preorder thatcontains the ordering of A . Let p , p : A × A → A be the two projections. Thefollowing conditions are equivalent. (1) ⊑ is a congruence ordering on A . (2) ⊑ = ker ϕ , for some morphism ϕ : A → B . (3) u ∈ M ⊑ implies π ( M p ( u )) ⊑ π ( M p ( u )) . (4) ⊑ induces a subalgebra of A × A .Proof. (1) ⇒ (2) The quotient map q : A → A / ⊑ has kernel ⊑ .(2) ⇒ (1) Clearly, a ≤ b implies ϕ ( a ) ≤ ϕ ( b ) . Thus, ≤ ⊆ ⊑ . For the othercondition, consider two elements s, t ∈ M A with s ⊑ M t . By definition, thismeans that M q ( s ) ≤ M q ( t ) where q : A → A / ⊑ is the quotient map. As q issurjective, we can use the Factorisation Lemma to find a function f : A/ ⊑ → B with ϕ = f ◦ q . By monotonicity of f and π , it follows that ϕ ( π ( s )) = π ( M ϕ ( s )) = π ( M f ( M q ( s ))) ≤ π ( M f ( M q ( t ))) = π ( M ϕ ( t )) = ϕ ( π ( t )) . Consequently, h π ( s ) , π ( t ) i ∈ ker ϕ = ⊑ .(4) ⇒ (3) Let u ∈ M ⊑ . Then (cid:10) π ( M p ( u )) , π ( M p ( u )) (cid:11) = (cid:10) p ( π ( u )) , p ( π ( u )) (cid:11) = π ( u ) ∈ ⊑ . Hence, π ( M p ( u )) ⊑ π ( M p ( u )) .(3) ⇒ (4) Let u ∈ M ⊑ . Then π ( M p ( u )) ⊑ π ( M p ( u )) implies that π ( u ) = (cid:10) p ( π ( u )) , p ( π ( u )) (cid:11) = (cid:10) π ( M p ( u )) , π ( M p ( u )) (cid:11) ∈ ⊑ . (3) ⇒ (1) To show that ⊑ is a congruence ordering, suppose that s ⊑ M t . ByLemma 3.7, there is some u ∈ M ⊑ with s = M p ( u ) and t = M p ( u ) . Hence itfollows by (3) that π ( s ) = π ( M p ( u )) ⊑ π ( M p ( u )) = π ( t ) . (1) ⇒ (3) Given u ∈ M ⊑ , Lemma 3.7 implies that M p ( u ) ⊑ M M p ( u ) .Hence, M ( q ◦ p )( u ) ≤ M ( q ◦ p )( u ) , where q : A → A / ⊑ is the quotient map.As the product π is monotone, it follows that π ( M ( q ◦ p )( u )) ≤ π ( M ( q ◦ p )( u )) . q ( π ( M p ( u ))) = π ( M ( q ◦ p )( u )) ≤ π ( M ( q ◦ p )( u )) = q ( π ( M p ( u ))) , which implies that π ( M p ( u )) ⊑ π ( M p ( u )) . Our main point of interest is to determine which sets K ⊆ M ξ Σ are definablein a given logic. We start by introducing some notions from language theory. Definition 4.1. (a) An alphabet is a finite unordered set Σ ∈ Pos Ξ . We denoteby Alph the category of all alphabets with functions as morphisms.(b) A language over the alphabet Σ is a subset K ⊆ M ξ Σ , for some sort ξ .(c) A family of languages is a function K mapping each alphabet Σ to aclass K [ Σ ] of languages over Σ .(d) A function f : M Σ → A recognises a language K ⊆ M ξ Σ if K = f − [ P ] ,for some upwards closed set P ⊆ A ξ .(e) Let f : Σ → Γ be a morphism of Alph . We call a morphism of the form M f : M Σ → M Γ a relabelling and, for a language K ⊆ M ξ Γ , we call the set ( M f ) − [ K ] := { s ∈ M ξ Σ | M f ( s ) ∈ K } an inverse relabelling of K . y Note that we always assume alphabets to be unordered. This is required forthe variety theorem in the next section. But sometimes it is useful to also workwith languages over ordered alphabets. We do so by simply forgetting the order.This leads to the following extension of the notion of a family of languages.
Definition 4.2.
Let K be a family of language. For a finite ordered set C , wedefine K [ C ] := (cid:8) M ι [ K ] (cid:12)(cid:12) K ∈ K [ V C ] (cid:9) , where V and ι are the operations from Definition 2.5. y One of our main tools will be the following relation associated with a lan-guage.
Definition 4.3.
Let A be an M -algebra.(a) A context is an element of M ( A + (cid:3) ) , where (cid:3) is considered as somespecial symbol of an arbitrary, but fixed sort ζ . For a context p ∈ M ξ ( A + (cid:3) ) and an element a ∈ A ζ , we define p [ a ] := σ a ( p ) ∈ A ξ where σ a : M ( A + (cid:3) ) → A is the unique morphism that extends the function s a : A + (cid:3) → A given by s a ( (cid:3) ) := a and s a ( c ) := c , for c ∈ A .
13n the case where A = M Σ is a free M -algebra, we will also consider elements p ∈ M ( Σ + (cid:3) ) as contexts, by identifying them with their image under M (sing+1) (the function sing + 1 maps a ∈ A to sing( a ) and (cid:3) to (cid:3) ).(b) The composition of two contexts p, q ∈ M ( A + (cid:3) ) is the context pq := ˆ p [ q ] ∈ M ( A + (cid:3) ) , where ˆ p := M (sing + 1)( p ) and ˆ p [ q ] is evaluated in the M -algebra M ( A + (cid:3) ) .(c) A derivative of a subset K ⊆ A ξ is a set of the form p − [ K ] := { a ∈ A ζ | p [ a ] ∈ K } , where p ∈ M ξ ( A + (cid:3) ) is a context.(d) The syntactic congruence of an upwards closed set K ⊆ A ξ is the relation a (cid:22) K b : iff ( p [ a ] ∈ K ⇒ p [ b ] ∈ K ) , for all p ∈ M ξ ( A + (cid:3) ) , for a, b ∈ A .(e) We call the quotient Syn( K ) := A / (cid:22) K the syntactic algebra of K andthe quotient map syn K : A → A / (cid:22) K the syntactic morphism of K .(f) We say that a language K has a syntactic algebra if (cid:22) K is a congruenceordering with finitary index. y Note that, in general, the syntactic congruence does not need to be a con-gruence ordering, the syntactic algebra not an M -algebra, and the syntacticmorphism not a morphism of M -algebras, but we will mainly be interested inthe case where they are. Hence the terminology. Lemma 4.4.
Let A be an M -algebra, K ⊆ A ξ upwards closed, a, b ∈ A , and p ∈ M ( A + (cid:3) ) . (a) a ≤ b implies p [ a ] ≤ p [ b ] . (b) a ≤ b implies a (cid:22) K b . (c) a (cid:22) K b implies p [ a ] (cid:22) K p [ b ] and a (cid:22) p − [ K ] b . Proof. (a) Let g : A + (cid:3) → A × A be the function where g ( (cid:3) ) := h a, b i and g ( c ) = h c, c i , for c ∈ A , let q, q ′ : A × A → A be the two projections, and set u := M g ( p ) . Then u ∈ M ≤ (where ≤ is the ordering of A ) and p [ a ] = π ( M q ( u )) and p [ b ] = π ( M q ′ ( u )) . Since M uses the standard ordering, this implies that p [ a ] ≤ p [ b ] .(b) Suppose that a ≤ b and let p ∈ M ( A + (cid:3) ) be a context. By (a), we have p [ a ] ≤ p [ b ] . Consequently, p [ a ] ∈ K implies p [ b ] ∈ K .(c) Suppose that a (cid:22) K b . To show that p [ a ] (cid:22) K p [ b ] , consider a context q with q [ p [ a ]] ∈ K . Then a (cid:22) K b and q [ p [ a ]] = ( qp )[ a ] ∈ K implies that q [ p [ b ]] =( qp )[ b ] ∈ K .To show that a (cid:22) p − [ K ] b , consider a context q with q [ a ] ∈ p − [ K ] . Then a (cid:22) K b and ( pq )[ a ] = p [ q [ a ]] ∈ K implies that ( pq )[ b ] = p [ q [ b ]] ∈ K . Thus q [ b ] ∈ p − [ K ] . 14ne consequence of this lemma is that the quotient A/ (cid:22) K does exist at leastas a set. Corollary 4.5.
Let A be an M -algebra and K ⊆ A ξ upwards closed. Then (cid:22) K is a preorder with ≤ ⊆ (cid:22) K .Proof. Reflexivity and transitivity of (cid:22) K follow immediately from the definition.The fact that (cid:22) K contains ≤ is part (a) of the preceding lemma. Lemma 4.6.
A morphism ϕ : M Σ → A of M -algebras recognises a language K ⊆ M ξ Σ if, and only if, ker ϕ ⊆ (cid:22) K .Proof. ( ⇐ ) We claim that K = ϕ − [ P ] where P := ⇑ ϕ [ K ] . Clearly, ϕ ( t ) ∈ P ,for all t ∈ K . Conversely, ϕ ( t ) ∈ P ⇒ ϕ ( s ) ≤ ϕ ( t ) , for some s ∈ K ⇒ s (cid:22) K t , for some s ∈ K ⇒ t ∈ K . ( ⇒ ) Suppose that K = ϕ − [ P ] , for an upwards closed set P , and let ϕ ( s ) ≤ ϕ ( t ) . To show that s (cid:22) K t , consider some context p ∈ M ( Σ + (cid:3) ) with p [ s ] ∈ K .Set ˆ p := M ( ϕ ◦ sing + 1)( p ) ∈ M ( A + (cid:3) ) . Then ˆ p [ ϕ ( s )] = ϕ ( p [ s ]) ∈ P . According to Lemma 4.4 (a), we further have ˆ p [ ϕ ( s )] ≤ ˆ p [ ϕ ( t )] . Together, it follows that ˆ p [ ϕ ( t )] = ϕ ( p [ t ]) ∈ P . Hence, p [ t ] ∈ K . A noteworthy consequence of this lemma is that the syntactic morphism ofa language K is the terminal object in the category of all morphisms recog-nising K . Theorem 4.7.
Let K ⊆ M ξ Σ be a language such that (cid:22) K is a congruenceordering. For every surjective morphism ϕ : M Σ → A recognising K , thereexists a unique morphism ̺ : A → Syn( K ) such that syn K = ̺ ◦ ϕ .Proof. Suppose that ϕ recognises K . By Lemma 4.6 we have ker ϕ ⊆ (cid:22) K = ker syn K . Therefore, we can use the Factorisation Lemma to find a unique function ̺ : A → Syn( K ) with syn K = ̺ ◦ ϕ . According to Lemma 3.3, this function ̺ is amorphism.Let us take a look at what kind of languages are recognised by a syntacticalgebra. Proposition 4.8.
Let K ⊆ M ξ Σ and L ⊆ M ζ Σ be languages such that K hasa syntactic algebra. The following statements are equivalent. (1) (cid:22) K ⊆ (cid:22) L (2) syn K : M Σ → Syn( K ) recognises L . Every morphism recognising K also recognises L . (4) L has the form [ i K, L , L , (cid:22) K ⊆ (cid:22) L and (cid:22) K ⊆ (cid:22) L implies (cid:22) K ⊆ (cid:22) L ∪ L and (cid:22) K ⊆ (cid:22) L ∩ L . For the first inclusion, suppose that s (cid:22) K t and let p be a context such that p [ s ] ∈ L ∪ L . Then there is some i < such that p [ s ] ∈ L i . Hence, s (cid:22) L i t implies p [ t ] ∈ L i ⊆ L ∪ L .Similarly, if s (cid:22) K t and p is a context with p [ s ] ∈ L ∩ L , then p [ s ] ∈ L and s (cid:22) L t implies p [ t ] ∈ L ,p [ s ] ∈ L and s (cid:22) L t implies p [ t ] ∈ L . Thus p [ t ] ∈ L ∩ L .(2) ⇒ (4) By definition of (cid:22) K , for every pair of elements a, b ∈ Syn ξ ( K ) with a (cid:2) b , we can fix some context p ab such that p ab [ s ] ∈ K and p ab [ t ] / ∈ K , for s ∈ syn − K ( a ) and t ∈ syn − K ( b ) . Set P := syn K [ L ] and let Q := Syn ξ ( K ) \ P be the complement. For t ∈ syn − K [ P ] and u ∈ syn − K [ Q ] , it follows that t (cid:14) K u implies p ab [ t ] ∈ K where a := syn K ( t ) and b := syn K ( u ) . Similarly, for t ∈ syn − K [ Q ] and s ∈ syn − K [ P ] , we have s (cid:14) K t implies p ab [ t ] / ∈ K where a := syn K ( s ) and b := syn K ( t ) . Taken together it follows that t ∈ syn − K [ P ] iff there is some a ∈ P with p ab [ t ] ∈ K for all b ∈ Q . Thus, L = syn − K [ P ] = [ a ∈ P \ b ∈ Q p − ab [ K ] . The next proposition describes languages recognised by syntactic algebrasvia arbitrary morphisms. 16 roposition 4.9. Let K ⊆ M ξ Σ be a language with a syntactic algebra. A lan-guage L ⊆ M ζ Γ is recognised by Syn( K ) if, and only if, L = ϕ − (cid:2) [ i A functor M : Pos Ξ → Pos Ξ is finitary if it commutes withdirected colimits, that is, if M (lim −→ D ) = lim −→ ( M ◦ D ) , for every directed diagram D : I → Pos Ξ . y Remark. (a) More concretely, M is finitary if M A is equal to the directed colimitof the diagram consisting of M C , for all finite C ⊆ A .(b) The word functor M A := A + is finitary as every finite word uses onlyfinitely many labels. The functor M h A , A ∞ i := h A +1 , A +1 A ∞ ∪ A ω i for infinite words, on the other hand, is not finitary as an infinite word can con-tain infinitely many different labels. Thus, in general A ω = S { C ω | C ⊆ A finite } . Proposition 4.11. Let A be a finitary M -algebra and K ⊆ A ξ a set. If M isfinitary, then (cid:22) K is a congruence ordering on A .Proof. We use the characterisation from Proposition 3.8 (3). Hence, fix u ∈ M (cid:22) K . We have to show that π ( M q ( u )) (cid:22) K π ( M q ( u )) , q , q : A × A → A are the two projections. As M is finitary, there existsa finite relation R ⊆ (cid:22) K such that u ∈ M R . Let h a , b i , . . . , h a m − , b m − i bean enumeration of R and set t k := M p k ( u ) , where p k ( h a i , b i i ) := ( a i if i ≥ k ,b i if i < k .r k := M p ′ k ( u ) , where p ′ k ( h a i , b i i ) := a i if i > k , (cid:3) if i = k ,b i if i < k . Then π ( t k ) = r k [ a k ] and π ( t k +1 ) = r k [ b k ] , and it follows by Lemma 4.4 that a k (cid:22) K b k implies π ( t k ) = r k [ a k ] (cid:22) K r k [ b k ] = π ( t k +1 ) . Consequently, π ( M q ( u )) = π ( t ) (cid:22) K · · · (cid:22) K π ( t m ) = π ( M q ( u )) , as desired.Unfortunately, not all the monads M used in applications are finitary. Inparticular those needed for languages of infinite words or infinite trees are not.Therefore, we have to extend the preceding proposition to a larger class offunctors. It turns out that, in all the known examples of a non-finitary functorswhere syntactic algebras exists, the functor in question is âĂŸruledâĂŹ in acertain sense by a subfunctor which is finitary. The precise definitions are asfollows. Definition 4.12. Let h M , µ , ε i and h M , µ , ε i be monads.(a) A natural transformation ̺ : M ⇒ M is a morphism of monads if ε = ̺ ◦ ε and µ ◦ ( ̺ ◦ M ̺ ) = ̺ ◦ µ . In this case we say that M is a reduct of M .(b) Let ̺ : M ⇒ M be a morphism of monads and A = h A, π i an M -algebra. The ̺ -reduct of A is the M -algebra h A, π ◦ ̺ A i . If ̺ is understood, wealso speak of an M -reduct of A .(c) A morphism ̺ : M ◦ ⇒ M of monads is dense over a class C of M -algebrasif, for all A ∈ C , C ⊆ A , and s ∈ M C , there exists s ◦ ∈ M ◦ C with π ( s ◦ ) = π ( s ) .(d) We say that a monad M is essentially finite over a class C if there existsa morphism ̺ : M ◦ ⇒ M such that M ◦ is finitary and ̺ is dense over the closureof C under binary products. y Example. Let us again consider the functor M h A , A ∞ i := h A +1 , A +1 A ∞ ∪ A ω i for infinite words and let M ◦ h A , A ∞ i := h A +1 , A +1 A ∞ ∪ A up1 i , where A up1 denotes the set of all ultimately periodic words in A ω . Then theinclusion map M ◦ ⇒ M is dense over the class of all finite ω -semigroups sincethe product of a finite ω -semigroup is completely determined by its restrictionto all ultimately periodic words. 18f M ◦ ⇒ M is dense over C , every M -algebra in C is uniquely determinedby its M ◦ -reduct. This will be used below to prove the existence of syntacticalgebras for essentially finitary monads. Lemma 4.13. Let ̺ : M ◦ ⇒ M be dense over a class C that is closed underbinary products. (a) Any two algebras in C with the same M ◦ -reduct are isomorphic. (b) Let ϕ : A ◦ → B ◦ be a morphism of M ◦ -algebras and assume that A ◦ and B ◦ are the M ◦ -reducts of two M -algebras A , B ∈ C . Then ϕ is also a morph-ism A → B of M -algebras. (c) A relation ⊑ is a congruence ordering on an M -algebra A ∈ C if, and onlyif, it is a congruence ordering on the M ◦ -reduct A ◦ of A .Proof. (a) Suppose that C contains two M -algebras A = h A, π i and A ′ = h A, π ′ i with the same M ◦ -reduct A ◦ = h A, π ◦ i . To show that π = π ′ , fix an element s ∈ M A . Set t := M d ( s ) ∈ M ∆ where ∆ := { h a, a i | a ∈ A } is the diagonal of A × A and d : A → ∆ the diagonal map. By assumption, the product A × A ′ belongs to C . As ̺ is dense, we can find some t ◦ ∈ M ◦ ∆ with π ◦ ( t ◦ ) = π ( t ) .Note that t ◦ ∈ M ◦ ∆ implies that M ◦ p ( t ◦ ) = M ◦ q ( t ◦ ) where p, q : A × A → A are the two projections. Consequently, π ( s ) = π ( M p ( t )) = p ( π ( t ))= p ( π ◦ ( t ◦ ))= π ◦ ( M ◦ p ( t ◦ ))= π ◦ ( M ◦ q ( t ◦ ))= q ( π ◦ ( t ◦ ))= q ( π ( t )) = π ′ ( M q ( t )) = π ′ ( s ) . (b) Fix s ∈ M A . To show that π ( M ϕ ( s )) = ϕ ( π ( s )) , we consider the graph G := { h a, ϕ ( a ) i | a ∈ A } of ϕ . Let i := h id , ϕ i : A → G be the natural bijection and set t := M i ( s ) ∈ M G .Since A × B ∈ C and ̺ is dense, we can find some t ◦ ∈ M ◦ G with π ( t ◦ ) = π ( t ) .Let p : A × B → A and q : A × B → B be the two projections. Note that ϕ = q ◦ i and q ( g ) = ϕ ( p ( g )) , for g ∈ G , which implies that M ◦ q ( t ◦ ) = M ◦ ( ϕ ◦ p )( t ◦ ) . Therefore, π ( M ϕ ( s )) = π ( M q ( t )) = q ( π ( t ))= q ( π ( t ◦ ))= π ( M ◦ q ( t ◦ ))= π ( M ◦ ( ϕ ◦ p )( t ◦ ))= ϕ ( p ( π ( t ◦ )))= ϕ ( p ( π ( t ))) = ϕ ( π ( M p ( t ))) = ϕ ( π ( s )) . (c) Clearly, every congruence ordering of A is also one of A ◦ . Conversely,suppose that ⊑ is a congruence ordering of A ◦ . We use the characterisation19rom Proposition 3.8 (3). Thus, let u ∈ M ⊑ . As the product A × A belongs to C and ̺ is dense over C , we can find some u ◦ ∈ M ◦ ⊑ with π ( u ◦ ) = π ( u ) . Byassumption, we have π ( M ◦ p ( u ◦ )) ⊑ π ( M ◦ p ( u ◦ )) , where p , p : A × A → A are the two projections. Since π ( M p i ( u )) = p i ( π ( u )) = p i ( π ( u ◦ )) = π ( M ◦ p i ( u ◦ )) , this implies that π ( M p ( u )) ⊑ π ( M p ( u )) , as desired. Theorem 4.14. Suppose that M is essentially finitary over C . If a language K ⊆ M ξ Σ is recognised by some morphism ϕ : M Σ → A with A ∈ C , then (cid:22) K is a congruence ordering on M Σ .Proof. Suppose that K = ϕ − [ P ] for P ⊆ A ξ . Let B ⊆ A be the subalgebrainduced by rng ϕ . By Proposition 4.11, (cid:22) P is a congruence ordering on the M ◦ -reduct A ◦ of A . Hence, Lemma 4.13 (c) implies that it is also a congruenceordering on A . Consequently, its restriction is one on B . (If (cid:22) P is the kernel ofsome morphism q , then its restriction to B is the kernel of q ◦ i , where i : B → A is the inclusion morphism.) Thus, (cid:22) P = ker syn P where syn P : B → Syn( P ) = B / (cid:22) P is the quotient morphism. We will show that (cid:22) K = ( ϕ × ϕ ) − [ (cid:22) P ] . It then follows that (cid:22) K = ker(syn P ◦ ϕ ) is also the kernel of a morphism and,thus, a congruence ordering. Hence, it remains to prove the claim. ( ⊇ ) Let f := ϕ ◦ sing + 1 : Σ + (cid:3) → B + (cid:3) be the function mapping c ∈ Σ to ϕ (sing( c )) and (cid:3) to (cid:3) . For s ∈ M Σ and p ∈ M ( Σ + (cid:3) ) , we have p [ s ] ∈ K iff M ϕ ( p [ s ]) ∈ P iff ( M f ( p ))[ M ϕ ( s )] ∈ P . If M ϕ ( s ) (cid:22) P M ϕ ( t ) it therefore follows that p [ s ] ∈ K ⇒ ( M f ( p ))[ M ϕ ( s )] ∈ P ⇒ ( M f ( p ))[ M ϕ ( t )] ∈ P ⇒ p [ t ] ∈ K , for all p ∈ M ( Σ + (cid:3) ) . Consequently, s (cid:22) K t . ( ⊆ ) Suppose that s (cid:22) K t and fix p ∈ M ( B + (cid:3) ) . The morphism M ( ϕ + 1) : M ( M Σ + (cid:3) ) → M ( B + (cid:3) ) is surjective since ϕ is surjective and M preservessurjectivity. Thus, we can fix some context ˆ p ∈ ( M ( ϕ + 1)) − ( p ) . It follows that p [ ϕ ( s )] ∈ P ⇒ ϕ (ˆ p [ s ]) ∈ P ⇒ ˆ p [ s ] ∈ K ⇒ ˆ p [ t ] ∈ K ⇒ ϕ (ˆ p [ t ]) ∈ P ⇒ p [ ϕ ( t )] ∈ P . Consequently, ϕ ( s ) (cid:22) P ϕ ( t ) . After these preparations, we come to the first of the central theorems of algebraiclanguage theory: the Variety Theorem. This theorem characterises which kind20f language families are amenable to the algebraic tools we develop. It relatessuch families of languages to classes of algebras recognising them.Before we can formally define the families and classes involved, we need tointroduce a bit of notation that allows us to transfer problems to a setting withonly finitely many sorts. Definition 5.1. Let ∆ ⊆ Ξ be a set of sorts and A a set.(a) We denote by A | ∆ the subset of A containing only the elements with asort in ∆ . (Depending on the circumstances, we will treat A | ∆ either as a set in Pos ∆ , or as a set in Pos Ξ that just happens to have no element with a sorts in Ξ \ ∆ .)(b) For a function f : A → B we denote the induced function A | ∆ → B | ∆ by f | ∆ .(c) The corresponding restriction of the functor M is defined by M | ∆ A := ( M ( A | ∆ )) | ∆ . (d) For an M -algebra A we denote by A | ∆ the M | ∆ -algebra with domain A | ∆ and product π ↾ M | ∆ A .(e) An M -algebra B is a sort-accumulation point of a class A of M -algebrasif, for every finite subset ∆ ⊆ Ξ , there is some algebra A ∈ A such that A | ∆ and B | ∆ are isomorphic as M | ∆ -algebras. y We will show below that there is a precise correspondence between the fol-lowing families of languages and classes of algebras. Definition 5.2. (a) A (positive) variety of languages is a family K of languagesthat is closed under (i) finite unions and intersections, (ii) inverse morphisms,and (iii) derivatives.(b) A class V of finitary M -algebras is a pseudo-variety if it is closed un-der (i) quotients, (ii) finitary subalgebras of arbitrary products, and (iii) sort-accumulation points. y Remark. (a) In the definition of a pseudo-variety, we could have used finite products instead of arbitrary ones.(b) The reason why we combine the operations of taking subalgebras andforming products into a single one is that, in general, the product of two finitaryalgebras need not be finitely generated (see [6] for a counterexample).The aim of this section is to establish a one-to-one correspondence betweenvarieties of languages and pseudo-varieties of M -algebras. The arguments aremostly standard, except for some adjustments needed to support infinitely manysorts. We start with the following observation. Lemma 5.3. Let V be a pseudo-variety and K ⊆ M ξ Σ a language with asyntactic algebra. Then K is recognised by some algebra A ∈ V if, and only if, Syn( K ) ∈ V .Proof. ( ⇐ ) is trivial since Syn( K ) recognises K . For ( ⇒ ) , consider a morphism ϕ : M Σ → A recognising K with A ∈ V . As V is closed under finitary subalgeb-ras, we may assume that ϕ is surjective. We can therefore use Theorem 4.7 tofind a morphism ̺ : A → Syn( K ) with syn K = ̺ ◦ ϕ . As syn K is surjective, sois ̺ . By closure of V under quotients, it follows that Syn( K ) ∈ V .21he first step in correlating varieties of languages and pseudo-varieties ofalgebras consists in following the observation. Proposition 5.4. If K is the family of languages recognised by the algebras ofa pseudo-variety V of M -algebras, then K is a variety of languages.Proof. We have to prove three closure properties.(1) We start with inverse morphisms. Suppose that K = ϕ − [ P ] for a morph-ism ϕ : M Γ → A with A ∈ V and P ⊆ A ξ . Let ψ : M Σ → M Γ be a morphism.Then ψ − [ K ] = ψ − [ ϕ − [ P ]] = ( ϕ ◦ ψ ) − [ P ] is recognised by the morphism ϕ ◦ ψ to A ∈ V .(2) Next, we consider closure under derivatives. Let K ∈ K and fix a con-text p . By assumption, there is a morphism ϕ : M Σ → A recognising K with A ∈ V . By Proposition 4.8, ϕ also recognises p − [ K ] . Hence, p − [ K ] ∈ K .(3) It remains to prove closure under finite intersections and unions. Clearly,the empty union ∅ and the empty intersection M Σ are recognised by any morph-ism. Thus, it is sufficient to consider binary unions and intersections. Considertwo morphisms ϕ : M Σ → A and ψ : M Σ → B with A , B ∈ V , and set K := ϕ − [ P ] and L := ψ − [ Q ] , for upwards closed P ⊆ A ξ and Q ⊆ B ξ . Then K ∩ L = h ϕ, ψ i − [ P × Q ] ,K ∪ L = h ϕ, ψ i − [( P × B ξ ) ∪ ( A ξ × Q )] are recognised by h ϕ, ψ i : M Σ → A × B . Let C be the subalgebra of A × B induced by the range of h ϕ, ψ i . Then C is finitary and C ∈ V .It remains to prove the converse direction of the correspondence. We startwith two lemmas. Lemma 5.5. Let q : A → B be a surjective morphism. Every language recog-nised by B is also recognised by A .Proof. Suppose that L = ψ − [ P ] where ψ : M Σ → B and P ⊆ B m is upwardsclosed. By Lemma 3.4, there exists a morphism ϕ : M Σ → A such that q ◦ ϕ = ψ .Setting Q := q − [ P ] , it follows that ϕ − [ Q ] = ϕ − [ q − [ P ]] = ( q ◦ ϕ ) − [ P ] = ψ − [ P ] = L . Lemma 5.6. Every language K ⊆ M ξ Σ that is recognised by a finitary sub-algebra C ⊆ Q i ∈ I A i of a product of finitary M -algebras A i is a finite positiveboolean combination of languages recognised by the factors A i .Proof. Let ϕ : M Σ → C be a morphism such that K = ϕ − [ P ] for some upwardsclosed P ⊆ C ⊆ Q i A iξ . Let p k : Q i A i → A k be the projection. By the way theordering of the product Q i A i is defined, we can pick, for every pair a, b ∈ Q i A iξ of elements with a (cid:2) b , some index h ∈ I such that p h ( a ) (cid:2) p h ( b ) . Let H ⊆ I bethe finite set of such indices h that correspond to pairs a, b ∈ C ξ . For s ∈ M ξ Σ and a ∈ C ξ , it follows that a (cid:2) ϕ ( s ) iff p h ( a ) (cid:2) p h ( ϕ ( s )) , for some h ∈ H , ϕ ( s ) ≥ a iff p h ( ϕ ( s )) ≥ p h ( a ) , for all h ∈ H . Consequently, K = ϕ − [ P ] = [ a ∈ P ϕ − [ ⇑ a ] = [ a ∈ P \ h ∈ H ( p h ◦ ϕ ) − [ ⇑ p h ( a )] . As the languages ( p h ◦ ϕ ) − [ ⇑ p h ( a )] are recognised by the morphism p h ◦ ϕ : M Σ → A h , the claim follows. Theorem 5.7. Let K be a variety of languages such that every language in K hasa syntactic algebra. A language K belongs to K if, and only if, it is recognised bysome algebra from the pseudo-variety V generated by the set { Syn( K ) | K ∈ K } .Proof. ( ⇒ ) Every language K ∈ K is recognised by Syn( K ) , which belongs to V . ( ⇐ ) Every algebra in V can be obtained from algebras of the form Syn( K ) with K ∈ K by a series of (i) quotients, (ii) finitary subalgebras of products, and(iii) sort-accumulation points. We prove the claim by induction on the number ofsuch operations we need to perform to obtain the given algebra. Hence, supposethat we have already proved the claim for all algebras in a subclass V ⊆ V .By Proposition 4.9, every language recognised by a syntactic algebra Syn( K ) with K ∈ K belongs to K . Consequently, Syn( K ) ∈ V . As K is a variety oflanguages, it follows by Lemmas 5.5 and 5.6 that every language L recognisedby an algebra that is obtained from algebras in V using operations of the form(i) and (ii) also belongs to K .For (iii), suppose that B is a sort-accumulation point of V and let ϕ : M Σ → B be a morphism recognising K = ϕ − [ P ] , for P ⊆ B ξ . Let ∆ ⊆ Ξ be the setconsisting of ξ and all sorts appearing in Σ . By assumption, there is an algebra A ∈ V with A | ∆ ∼ = B | ∆ . Let ψ : B | ∆ → A | ∆ be the corresponding isomorphismand let ˆ ϕ : M Σ → A be the morphism with ˆ ϕ (sing( c )) := ψ ( ϕ (sing( c ))) , for c ∈ Σ . Then ˆ ϕ − [ ψ [ P ]] = ϕ − [ P ] = K . Hence, K is recognised by an algebrain V , which implies that it belongs to K .As we have just seen, every pseudo-variety of algebras is associated with avariety of languages and every variety of languages is associated with a pseudo-variety of algebras. We conclude this section by proving that this correspondenceis one-to-one. As usual we start with a few lemmas. Lemma 5.8. Let A be an M -algebra, ∆ ⊆ Ξ a set of sorts such that theelements in A | ∆ generate A . If ⊑ ∆ is a congruence ordering of A | ∆ and ⊑ thesmallest congruence ordering of A containing ⊑ ∆ , then ⊑ ∩ ( A | ∆ × A | ∆ ) = ⊑ ∆ . Proof. By Proposition 3.8, we have ⊑ = π [ M ( ⊑ ∆ ∪ ≤ )] . Hence, consider a term u ∈ M ξ ( ⊑ ∆ ∪ ≤ ) with ξ ∈ ∆ . We have to show that π ( u ) ∈ ⊑ ∆ . Let p, q : A × A → A be the two projections. Since A | ∆ generates A ,there exists a function σ : ( A \ A | ∆ ) → M ( A | ∆ ) such that π ◦ σ = id .23et g : ( ⊑ ∆ ∪ ≤ ) → M ⊑ ∆ be the function where g ( h a, b i ) := ( h sing( a ) , sing( b ) i if h a, b i ∈ ⊑ ∆ h σ ( a ) , σ ( a ) i if h a, b i ∈ ≤ \ ⊑ ∆ . and set u ′ := M π ( M g ( u )) and w := flat( M g ( u )) . Then u ′ ≤ u and π ( w ) = π ( u ′ ) ≤ π ( u ) . Suppose that π ( u ) = h a, b i . Then π ( w ) = π ( u ′ ) = h a, c i , for some c ≤ b . Since w ∈ M | ∆ ⊑ ∆ and ⊑ ∆ is a congruence ordering on A | ∆ , we further have π ( w ) ∈⊑ ∆ . Consequently, a ⊑ ∆ c ≤ b implies a ⊑ ∆ b , and π ( u ) ∈ ⊑ ∆ . Lemma 5.9. Let A be a finitary M -algebra such that every language recognisedby A has a syntactic algebra. Then A belongs to a pseudo-variety V if, and onlyif, Syn( K ) ∈ V , for every language K recognised by A .Proof. ( ⇒ ) If K is recognised by A ∈ V , it follows by Lemma 5.3 that Syn( K ) ∈V . ( ⇐ ) Suppose that Syn( K ) ∈ V , for every language K recognised by A . As V is closed under sort-accumulation points, it is sufficient to show that, forevery finite set ∆ ⊆ Ξ there is some algebra B ∈ V with B | ∆ ∼ = A | ∆ . Hence, fix ∆ ⊆ Ξ . For a ∈ A | ∆ , we set K a := π − ( ⇑ a ) ∩ M A | ∆ . Let q := h syn K a i a ∈ A | ∆ : M A | ∆ → Y a ∈ A | ∆ Syn( K a ) be the quotient morphism and B the subalgebra of Q a Syn( K a ) induced by rng q . For s, t ∈ M | ∆ A , we have h s, t i ∈ ker q ⇒ s (cid:22) K a t , for all a ∈ A | ∆ ⇒ ( s ∈ K a ⇒ t ∈ K a ) , for all a ∈ A | ∆ ⇒ ( a ≤ π ( s ) ⇒ a ≤ π ( t )) , for all a ∈ A | ∆ ⇒ π ( s ) ≤ π ( t ) . Consequently, the Factorisation Lemma provides a function µ : B | ∆ → A | ∆ such that µ ◦ q = π ↾ M A | ∆ . Note that rng ( π ↾ M A | ∆ ) = A | ∆ implies that µ issurjective.Let ⊑ be the congruence ordering of B generated by ker µ and let ̺ : B → B / ⊑ be the corresponding quotient map. By Lemma 5.8, we have ker ̺ | ∆ = ⊑| ∆ = ker µ . Since µ is surjective, it follows that µ induces an isomorphism B / ⊑| ∆ ∼ = A | ∆ .Furthermore, by the closure properties of a pseudo-variety, we have B ∈ V and B / ⊑ ∈ V . 24 heorem 5.10 (Variety Theorem) . Let V be a pseudo-variety of M -algebrassuch that every language recognised by an algebra in V has a syntactic algebra,and let K be a variety of languages such that every language in K has a syntacticalgebra. The following statements are equivalent. (1) K consists of those languages that are recognised by some algebra in V . (2) K consists of all languages K with Syn( K ) ∈ V . (3) V consists of those algebras that only recognise languages in K . (4) V is the pseudo-variety generated by the set { Syn( K ) | K ∈ K } .Proof. (1) ⇔ (2) follows by Lemma 5.3 and (4) ⇒ (1) by Theorem 5.7.(2) ⇒ (3) If A ∈ V and K is recognised by A , it follows by Lemma 5.9 that Syn( K ) ∈ V . By (2), this implies that K ∈ K . Conversely, if A only recogniseslanguage in K , (2) implies that Syn( K ) ∈ V for all languages K recognised by A .By Lemma 5.9 it follows that A ∈ V .(3) ⇒ (4) Let V be the pseudo-variety generated by { Syn( K ) | K ∈ K } .For each K ∈ K , it follows by Proposition 4.9 that all languages recognisedby Syn( K ) belong to K . By assumption, this implies that Syn( K ) ∈ V . Con-sequently, we have V ⊆ V . Conversely, let A ∈ V . By assumption, every lan-guage recognised by A belongs to K . (In particular, each such language has asyntactic algebra.) Therefore, Lemma 5.9 implies that A ∈ V . The goal of this section is to derive an axiomatisation of pseudo-varieties in termsof systems of inequalities. We start by defining the kind of terms allowed in ouraxioms. A natural choice would be to take the elements of M X , for some set X ofvariables. But it turns out that this does not work. To capture the restriction to finitary M -algebras, we have to use a more general notion of a term. The classicresult by Reiterman [21] characterises the pseudo-varieties of finite semigroupsas exactly those axiomatisable by a set of profinite equations. Analogously, wehave to define profinitary M -terms for our version of this theorem. For this, wefollow the material in [15, 24], but with some adjustments that are needed tosupport infinitely many sorts.To explain how we arrive at the definition below, let us collect our require-ments on this set of terms. We are looking for a functor ˆ M mapping an (un-ordered) set X of variables to some set ˆ M X of ‘terms’. These terms should gen-eralise the ordinary terms from M X , i.e., we need an embedding ι : M X → ˆ M X .Furthermore, we should be able to ‘evaluate’ a term t ∈ ˆ M X in a given finitary M -algebra A with respect to a given ‘variable assignment’ β : X → A . Let usdenote the resulting value by val( t ; β ) . For ordinary terms t ∈ M X , this valueshould of course correspond to the value of t in A . Thus, val( ι ( t ); β ) = π ( M β ( t )) , where π ( M β ( t )) is the canonical extension of β : X → A to M X → A . Fur-thermore, val( t ; β ) should be compatible with morphisms of M -algebras. Thatis, val( t ; ϕ ◦ β ) = ϕ (val( t ; β )) , for every morphism ϕ : A → B . M X → A . In this category we consider the diagram of all β : M X → A where A is finitary and we take for ι : M X → ˆ M X the limit. The morphisms ˆ M X → A of the corresponding limiting cone can then be taken as our evaluationmaps. The formal construction is as follows. Definition 6.1. Let A ⊆ Alg ( M ) be a subcategory of M -algebras and X a set.We denote the comma category ( M X ↓ Alg ( M )) by C , the subcategory ( M X ↓ A ) by C , and the inclusion diagram by D : C → C .(a) We denote by ι A : M X → ˆ M A X the limit ι A := lim D of D , and thelimiting cone by (val A ( − ; β )) β ∈C . If A is the category of all finitary M -algebras,we drop the subscript and simply write ˆ M , ι , and val( − ; β ) .(b) We turn ˆ M A into a functor as follows. Given f : X → Y , the family (val( − ; β ◦ M f )) β (where β ranges over all morphisms β : M Y → A ∈ A ) formsa cone from ˆ M X to D . As the cone (val( − ; β )) β is limiting, there exists a uniquefunction f ′ : ˆ M X → ˆ M Y such that val( − ; β ◦ M f ) = val( − ; β ) ◦ f ′ , for all β : M Y → A ∈ A . We set ˆ M f := f ′ . y Remark. Another, more concise way to define ˆ M is as the codensity monad of theforgetful functor FAlg ( M ) → Pos Ξ which maps an M -algebra to its underlyingset, see [15, 24] for details.Let us start by checking that ˆ M A is well-defined and reasonably behaved. Lemma 6.2. The limit ι A : M X → ˆ M A X exists.Proof. First, note that the category Pos Ξ is complete. By Proposition 4.3.1of [12], this implies that so is Alg ( M ) . Now, let D : C → C be the diagramdefining ι A : M X → ˆ M A X and let U : C → Alg ( M ) be the forgetful functormapping β : M X → A to the codomain A . As Alg ( M ) is conplete, U ◦ D hasa limit T . Let ( λ β ) β the the corresponding limiting cone. As ( β ) β is a conefrom M X to U ◦ D , we obtain a unique morphism ϕ : M X → T such that λ β ◦ ϕ = β , for all β . It is now straightforward to check that ϕ : M X → T is thelimit of D and ( λ β ) β is the corresponding limiting cone. Lemma 6.3. Let A be a class of M -algebras, A , B ∈ A , β : M X → A , ϕ : A → B , and f : Y → X morphisms, and s, t ∈ ˆ M A X . (a) val A ( − ; β ) ◦ ι A = β (b) ϕ ◦ val A ( − ; β ) = val A ( − ; ϕ ◦ β ) (c) val A ( − ; β ) ◦ ˆ M A f = val A ( − ; β ◦ M f ) (d) If A is closed under subalgebras then, for every ˆ s ∈ ˆ M A X , there is some s ∈ M X with val A (ˆ s ; β ) = β ( s ) . (e) s ≤ t iff val A ( s ; α ) ≤ val A ( t ; α ) , for all α : M X → C ∈ A . roof. (a) By the definition of a cone, val A ( − ; β ) is a morphism from ι A : M X → ˆ M A X to β : M X → A . This is equivalent to (a).(b) In the comma category, ϕ : A → B corresponds to a morphism from β : M X → A to ϕ ◦ β : M X → B . Hence, (b) holds again by definition of acone.(c) holds be definition of ˆ M A f .(d) Let A be the subalgebra of A induced by the range of β , let i : A → A be the inclusion morphism, and let β : M X → A be the morphism suchthat β = i ◦ β . Note that A ∈ A since A is closed under subalgebras. Fix ˆ s ∈ ˆ M A X . By (a), we have rng val A ( − ; β ) ⊇ rng β which, by surjectivity of β ,implies that the two ranges are in fact equal. Hence, there is some s ∈ M X with β ( s ) = val A (ˆ s ; β ) . By (b), it follows that β ( s ) = i ( β ( s )) = i (val A (ˆ s ; β )) = val A (ˆ s ; i ◦ β ) = val A (ˆ s ; β ) . (e) One explicit way to define the limit ˆ M A X is to take all sequences ( a β ) β indexed by morphisms β : M X → A satisfying a γ = ϕ ( a β ) , for all ϕ : A → B with γ = ϕ ◦ β . Then the function val A ( − ; β ) is simply the projection to component a β . The or-dering of ˆ M A X is taken to be largest relation such that all projections val A ( − ; β ) are still monotone. That means that ( a β ) β ≤ ( b β ) β iff a β ≤ b β , for all β . Corollary 6.4. Let X be finite and f, g : C → ˆ M X functions. f = g iff val( − ; β ) ◦ f = val( − ; β ) ◦ g , for all β : M X → A . Proof. This statement holds generally for all limits (see, e.g., Proposition 2.6.4of [13]). For our special case, we can give a simple proof using Lemma 6.3 (e).By this lemma it follows that, for every c ∈ C , f ( c ) = g ( c ) iff val( f ( c ); β ) ≤ val( f ( c ); β ) , for all β : M X → A . Lemma 6.5. ˆ M A is a functor and ι A : M ⇒ ˆ M A a natural transformation.Proof. To see that ˆ M A is a functor, note that the uniqueness of the function f ′ in the definition of ˆ M A f implies that ˆ M A ( f ◦ g ) = ˆ M A f ◦ ˆ M A g .For the second claim, fix a function f : X → Y . For every β : M Y → A ∈ A ,Lemma 6.3 (c) implies that val( − ; β ) ◦ ˆ M f ◦ ι = val( − ; β ◦ M f ) ◦ ι = β ◦ M f = val( − ; β ) ◦ ι ◦ M f . Consequently, it follows by Corollary 6.4 that ˆ M f ◦ ι = ι ◦ M f Lemma 6.6. ˆ M A forms a monad where the unit map is ε := ι A ◦ sing and themultiplication µ : ˆ M A ◦ ˆ M A ⇒ ˆ M A is uniquely determined by the equations val( − ; β ) ◦ µ = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) , for all β . roof. To simplify notation, let us drop the subscript A . We define the multi-plication µ : ˆ M ◦ ˆ M ⇒ ˆ M as follows. For every morphism β : M X → A with A ∈ A , we have β = β ◦ π ◦ sing= π ◦ M β ◦ sing= π ◦ M val( − ; β ) ◦ M ι ◦ sing= val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) ◦ ι ◦ M ι ◦ sing . Furthermore, for two such morphisms α : M X → A and β : M X → B and amorphism ϕ : A → B with β = ϕ ◦ α , we have ϕ ◦ val (cid:0) − ; π ◦ M val( − ; α ) (cid:1) = val (cid:0) − ; ϕ ◦ π ◦ M val( − ; α ) (cid:1) = val (cid:0) − ; π ◦ M ϕ ◦ M val( − ; α ) (cid:1) = val (cid:0) − ; π ◦ M val( − ; ϕ ◦ α ) (cid:1) = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) . Consequently, the morphisms (cid:0) val (cid:0) − ; π ◦ M val( − ; β ) (cid:1)(cid:1) β form a cone from ι ◦ M ι ◦ sing : M X → ˆ M ˆ M X to the diagram ( M X ↓ A ) . As ι : M X → ˆ M X is the limit of this cone, thereexists a unique map µ : ˆ M ˆ M X → ˆ M X such that µ ◦ ι ◦ M ι ◦ sing = ι and val( − ; β ) ◦ µ = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) , for all β . Note that the first of these equations follows from the second one since, forevery β , val( − ; β ) ◦ µ ◦ ι ◦ M ι ◦ sing = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) ◦ ι ◦ M ι ◦ sing= π ◦ M val( − ; β ) ◦ M ι ◦ sing= π ◦ M β ◦ sing= β ◦ π ◦ sing= β = val( − ; β ) ◦ ι , which, by Corollary 6.4, implies that µ ◦ ι ◦ M ι ◦ sing = ι .Let us start by showing that these morphisms µ form a natural transforma-tion. Hence, fix a function f : X → Y . For every β : M Y → A , we have val( − ; β ) ◦ µ ◦ ˆ M ˆ M f = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) ◦ ˆ M ˆ M f = val (cid:0) − ; π ◦ M val( − ; β ) ◦ M ˆ M f (cid:1) = val (cid:0) − ; π ◦ M val( − ; β ◦ M f ) (cid:1) = val( − ; β ◦ M f ) ◦ µ = val( − ; β ) ◦ ˆ M f ◦ µ . 28y Corollary 6.4, this implies that µ ◦ ˆ M ˆ M f = ˆ M f ◦ µ .The fact that ε := ι ◦ sing is a natural transformation follows immediatelyfrom the facts that ι and sing are natural transformations. It therefore remainsto check the three axioms of a monad. For every β : M X → A , we have val( − ; β ) ◦ µ ◦ ε = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) ◦ ι ◦ sing= π ◦ M val( − ; β ) ◦ sing= val( − ; β ) ◦ π ◦ sing= val( − ; β ) , val( − ; β ) ◦ µ ◦ ˆ M ε = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) ◦ ˆ M ε = val (cid:0) − ; π ◦ M val( − ; β ) ◦ M ε (cid:1) = val (cid:0) − ; π ◦ M (cid:0) val( − ; β ) ◦ ι ◦ sing (cid:1)(cid:1) = val (cid:0) − ; π ◦ M (cid:0) β ◦ sing (cid:1)(cid:1) = val (cid:0) − ; β ◦ π ◦ M sing (cid:1) = val( − ; β ) , and val( − ; β ) ◦ µ ◦ ˆ M µ = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) ◦ ˆ M µ = val (cid:0) − ; π ◦ M val( − ; β ) ◦ M µ (cid:1) = val (cid:0) − ; π ◦ M (cid:0) val( − ; β ) ◦ µ (cid:1)(cid:1) = val (cid:0) − ; π ◦ M val (cid:0) − ; π ◦ M val( − ; β ) (cid:1)(cid:1) = val (cid:0) − ; π ◦ M val( − ; β ) (cid:1) ◦ µ = val( − ; β ) ◦ µ ◦ µ . By Corollary 6.4, this implies that µ ◦ ε = id , µ ◦ ˆ M ε = id , and µ ◦ ˆ M µ = µ ◦ µ . The next lemma states that, without loss of generality, we may assume thatthe morphisms β : M X → A are all surjective. This will be convenient in somesituations. Lemma 6.7. Let X be a finite set and A a pseudo-variety. (a) C = ( M X ↓ A ) is cofiltered. (b) In the definition of ˆ M A X , we can restrict the category C to the surjectivemorphisms without changing the result.Proof. (a) There are two axioms to check. First, let α : M X → A and β : M X → B be two objects of C . We have to find some γ : M X → C and morphisms ϕ : γ → α and ψ : γ → β . Set γ := h α, β i : M X → A × B , let C ⊆ A × B bethe subalgebra induced by rng γ , and let γ : M X → C be the corestriction of γ .Note that C is finitely generated (by the image of X ). Furthermore, for eachsort ξ ∈ Ξ , the set C ξ ⊆ A ξ × B ξ is finite. Hence, C ∈ A , γ ∈ C , and we havemorphisms p : γ → α and q : γ → β , where p : C → A and q : C → B are thetwo projections.For the second axioms, consider two morphisms ϕ, ψ : α → β with α : M X → A and β : M X → B in C . The set C := { a ∈ A | ϕ ( a ) = ψ ( a ) } A since, for s ∈ M C , we have ϕ ( π ( s )) = π ( M ϕ ( s )) = π ( M ψ ( s )) = ψ ( π ( s )) . For x ∈ X , we have ϕ ( α ( x )) = β ( x ) = ψ ( α ( x )) , which implies that α [ X ] ⊆ C . Hence, rng α ⊆ C . Let D ⊆ C be the subalgebrainduced by rng α , let α : M X → D be the corresponding corestriction of α ,and let i : C → A be the inclusion morphism. Since D is finitely generated (by α [ X ] ), we have D ∈ A . Furthermore, i : α → α satisfies ϕ ◦ i = ψ ◦ i .(b) Let C be the full subcategory of C = ( M X ↓ A ) consisting of allmorphisms β : M X → A that are surjective. By Lemma 2.11.2 of [13], it issufficient to prove the following two properties.(i) Every β ∈ C factorises through some β ∈ C .(ii) For all α, α ′ ∈ C , β ∈ C , and all morphisms ϕ : α → β and ϕ ′ : α ′ → β ,there is some γ ∈ C with morphisms ψ : γ → α and ψ ′ : γ → α ′ suchthat ϕ ◦ ψ = ϕ ′ ◦ ψ ′ .(i) Given β : M X → A , let A be the subalgebra of A induced by rng β , let i : A → A be the inclusion function, and β : M X → A be the corestrictionof β . Then β = i ◦ β . Since A is closed under finitary subalgebras, we have A ∈ A and β ∈ C .(ii) Consider α : M X → A , α ′ : M X → A ′ in C , β : M X → B in C ,and ϕ : α → β and ϕ ′ : α ′ → β . Let C be the subalgebra of A × A ′ inducedby the range of γ := h α, α ′ i : M X → A × A ′ . Then C ∈ A and γ ∈ C . Thetwo projections p : C → A and p ′ : C → A ′ are morphisms of C satisfying ϕ ◦ p = ϕ ′ ◦ p ′ .A particular consequence of point (b) in Lemma 6.7 is that we may assumethat all morphisms val( − ; β ) : ˆ M X → A of the limiting cone are surjective. Letus give a name to this property. Definition 6.8. Let C be a category like Pos Ξ or Alg ( M ) and D : I → C adiagram. We call a cone ( µ i ) i of D surjective if all components µ i are surject-ive. Similarly, the limit of D is surjective if the corresponding limiting cone issurjective. y The next statement holds more generally for all cofiltered limits, not onlysurjective ones (see the long version of [15] for a proof sketch). We will onlyprove the special case, as this is what we will need below. Proposition 6.9. Let A be a class of M -algebras and ∆ ⊆ Ξ a finite set ofsorts. The functor ˆ M A | ∆ preserves cofiltered surjective limits.Proof. To simplify notation, we will drop the subscript A . Let E : I → Pos Ξ bea cofiltered diagram of unordered sets with limit C and surjective limiting cone ( λ i ) i ∈ I , and let ( µ i ) i be the limiting cone for the diagram ˆ M ◦ E . We have toshow that ˆ M C ∼ = lim( ˆ M ◦ E ) . ( ˆ M λ i ) i ∈ I forms a cone from ˆ M C to the diagram ˆ M ◦ E . Since ( µ i ) i is limiting, there therefore exists a unique function ϕ : ˆ M C → lim ( ˆ M ◦ E ) such that µ i ◦ ϕ = ˆ M λ i , for all i ∈ I . ˆ M C lim ( ˆ M ◦ E ) ˆ M E ( i ) M C M E ( i ) A ϕ ˆ M λ i µ i val( − ; β ∗ i ) ι M λ i ι β ∗ i β We define the converse function ψ : lim ( ˆ M ◦ E ) → ˆ M C as follows. For everymorphism β : M C → A ∈ A and every index i ∈ I , we can use Lemma 3.4to find a function β ∗ i : M E ( i ) → A such that β = β ∗ i ◦ M λ i . (To see that wecan apply the lemma, note that C is unordered since it is a limit of unorderedsets, and that the functions M λ i are surjective since M preserves surjectivityand we have assumed that λ i is surjective.) By Lemma 3.3, the functions β ∗ i aremorphisms of M -algebras. To define the desired function ψ , consider an element s ∈ lim ( ˆ M ◦ E ) . For every morphism f : i → j of I , we have val( − ; β ∗ j ) ◦ µ j = val( − ; β ∗ j ) ◦ ˆ M Ef ◦ µ i = val( − ; β ∗ j ◦ M Ef ) ◦ µ i = val( − ; β ∗ i ) ◦ µ i . As I is cofiltered, it follows that the value a β := val( µ i ( s ); β ∗ i ) does not dependon the choice of the index i . Furthermore, for every morphism χ : β → γ of thecomma category ( M E ( i ) ↓ A ) , the fact that γ ∗ i ◦ M λ i = γ = χ ◦ β = χ ◦ β ∗ i ◦ M λ i implies, by surjectivity of M λ i , that γ ∗ i = χ ◦ β ∗ i . Consequently, we have a γ = val( µ i ( s ); γ ∗ i ) = val( µ i ( s ); χ ◦ β ∗ i ) = χ (val( µ i ( s ); β ∗ i )) = χ ( a β ) . Therefore, there exists a unique element t ∈ ˆ M C such that val( t ; β ) = a β , forall β : M C → A ∈ A . We set ψ ( s ) := t .It remains to show that the functions ϕ and ψ are inverses of each other. Bydefinition of ϕ and ψ , we have µ i ◦ ϕ = ˆ M λ i , val( − ; β ) ◦ ψ = val( − ; β ∗ i ) ◦ µ i ,β = β ∗ i ◦ M λ i . For every β : M C → A ∈ A , it therefore follows that val( − ; β ) ◦ ψ ◦ ϕ = val( − ; β ∗ i ) ◦ µ i ◦ ϕ = val( − ; β ∗ i ) ◦ ˆ M λ i = val( − ; β ∗ i ◦ M λ i ) = val( − ; β ) , ψ ◦ ϕ = id . Conversely, for every i ∈ I andevery α : M E ( i ) → A ∈ A , setting β := α ◦ M λ i , we have β ∗ i = α (by uniquenessof β ∗ i ) and val( − ; α ) ◦ µ i ◦ ϕ ◦ ψ = val( − ; β ∗ i ) ◦ µ i ◦ ϕ ◦ ψ = val( − ; β ∗ i ) ◦ ˆ M λ i ◦ ψ = val( − ; β ∗ i ◦ M λ i ) ◦ ψ = val( − ; β ) ◦ ψ = val( − ; β ∗ i ) ◦ µ i = val( − ; α ) ◦ µ i . By Corollary 6.4, it follows that µ i ◦ ϕ ◦ ψ = µ i , for all i ∈ I . An argumentanalogous to Corollary 6.4 shows that this implies that ϕ ◦ ψ = id .The reason we are interested in cofiltered surjective limits is the lemmabelow. Definition 6.10. An object A in a category C is finitely copresentable* if, forevery cofiltered diagram D : I → C with limit C and a surjective limiting cone ( λ i ) i ∈ I , and every morphism f : C → A , there exists an index k ∈ I and anessentially unique morphism g : D ( k ) → A such that f = g ◦ λ k . Essentiallyuniqueness here means that, if g ′ : D ( k ) → A is another morphism with f = g ′ ◦ λ k , then there exists an I -morphisms h : l → k with g ◦ Dh = g ′ ◦ Dh . y Remark. This differs from the usual definition of finite copresentability becauseof our requirement that the λ i are surjective. Hence the star in the name.The following is a variant of Lemma 3.2 from [1]. Lemma 6.11. Let C be an arbitrary category, M : C → C a functor preservingcofiltered surjective limits, and A an M -algebra with finitely copresentable* do-main A . Then A is finitely copresentable* in Alg ( M ) . To continue our investigation of the monad ˆ M A , we require some tools fromtopology. Definition 6.12. (a) We denote by Stone the category of (ordered) Stone spaces with continuous maps. (We do not require any connection between the topologyand the ordering. We could replace Stone by the subcategory of Priestley spaces where there is such a connection, but the difference will play no rôle in whatfollows below.)(b) For a functor M : Pos Ξ → Pos Ξ that has a canonical lifting to a functoron Stone Ξ , we write SAlg ( M ) for the category of M -algebras in Stone Ξ .(c) Let ( µ i ) i ∈ I be a cone where µ i : A → B i and each B i is a topologicalspace. The cone topology induced by ( µ i ) i is the topology on A which has aclosed subbasis consisting of all sets of the form µ − i [ K ] with i ∈ I and K ⊆ B i closed. If A is the limit of a diagram D : I → Pos Ξ and we do not specifya cone explicitly, we will always consider the cone topology induced by thecorresponding limiting cone. y We start by showing how to compute limits in Stone Ξ .32 emma 6.13. Let U : Stone Ξ → Pos Ξ be the forgetful functor and supposethat D : I → Stone Ξ is a diagram such that all sets D ξ ( i ) are non-empty.Then lim D is the space obtained by equipping the set lim ( U ◦ D ) with the conetopology.Proof. Let A := lim D and B := lim ( U ◦ D ) and let ( λ i ) i and ( µ i ) i be thecorresponding limiting cones. We start by showing that the cone topology on B is sort-wise compact and Hausdorff. Note that B ξ is the subset of Q i ∈ I D ξ ( i ) consisting of all families ( a i ) i such that a l = Df ( a k ) , for all I -morphisms f : k → l . Hence, B ξ = T f H f where H f := (cid:8) ( a i ) i ∈ Q i D ξ ( i ) (cid:12)(cid:12) Df ( a k ) = a l (cid:9) , for f : k → l . Since, for distinct a, b ∈ D ξ ( k ) , we can always find a clopen set C with a ∈ C and b / ∈ C , we can express H f as the intersection of all sets of the from (cid:0) µ − k [( Df ) − [ C ]] ∩ µ − l [ C ] (cid:1) ∪ (cid:0) µ − k [( Df ) − [ C ′ ]] ∩ µ − l [ C ′ ] (cid:1) , where C, C ′ range over all partitions of D ξ ( k ) into two clopen classes. It followsthat the sets H f are all closed. By the Theorem of Tychonoff, the product Q i D ξ ( i ) is compact. Consequently, B ξ = T f H f is a closed subset of a compactspace and, therefore, also compact.To show that the topology is zero-dimensional and Hausdorff, consider twodistinct elements a, b ∈ A . Then there is some index k ∈ I with µ k ( a ) = µ k ( b ) .As D ξ ( k ) is a Stone space, we can find two disjoint clopen sets C, C ′ with a ∈ C and b ∈ C ′ . Hence, µ − k [ C ] and µ − k [ C ′ ] are two disjoint clopen neighbourhoodsof, respectively, a and b .Since B is the limit in Pos Ξ , there exists a unique map f : A → B (in Pos Ξ ) such that λ i = µ i ◦ f , for all i . Similarly, there exists a unique morphism g : B → A of Stone Ξ such that µ i = λ i ◦ g . We can see that the function f is continuous as follows. Let C = µ − i [ K ] be a basic closed set K ⊆ B . Then f − [ C ] = ( µ i ◦ f ) − [ K ] = ( λ i ) − [ K ] . Hence, continuity of λ i implies that thepreimage f − [ C ] is open.Consequently, we can applying the same universality argument two moretimes to obtain f ◦ g = id and g ◦ f = id . Therefore, B and A with the conetopology are isomorphic as toplogical space.The following two results contain our key topology-based argument. Bothare taken from [22]: the first one is Proposition 1.1.4, the second one is Corol-lary 1.1.6. Proposition 6.14. Let D : I → Stone Ξ be a cofiltered diagram. If all spaces D ( i ) , i ∈ I , are sort-wise non-empty, so is the limit lim D . Lemma 6.15. Let D : I → Stone Ξ be a cofiltered diagram and ( µ i ) i a conefrom A ∈ Stone Ξ to D where each µ i : A → D ( i ) is surjective. The inducedmorphism ϕ : A → lim D is surjective. We will also make use of the following topological fact from [17]. Lemma 6.16. Every finite set with the discrete topology is finitely copresent-able* in Stone Ξ . roof. By Lemma vi.1.8 and Theoremm vi.2.3 of [17] the statement holds in Stone . As limits in Stone Ξ are computed for each sort separately, the claimfollows. Corollary 6.17. For every finite unordered set X and every finite set ∆ ⊆ Ξ of sorts, the ˆ M | ∆ -algebra ˆ M | ∆ X is finitely copresentable* in SAlg ( ˆ M | ∆ ) .Proof. By Lemma 6.16, the set X | ∆ is finitely copresentable* in Stone ∆ . As wehave shown in Propositon 6.9 that ˆ M | ∆ preserves surjective cofiltered limits, theclaim therefore follows by Lemma 6.11.Having collected the required tools from topology we can now continue withour investigation of the functor ˆ M A . Our main technical tool in the proofs belowis the following natural transformation relating the functors ˆ M A and ˆ M B , fordifferent classes A and B . The important case below will be where A is a pseudo-variety under consideration and B the class of all finitary M -algebras. Theorem 6.18. Let A ⊆ B ⊆ Alg ( M ) . (a) There exists a unique morphism ̺ : ˆ M B ⇒ ˆ M A of monads that makes thefollowing diagram commute, for all morphisms β : M X → A where A ∈ A and X is an unsorted set. ˆ M B X ˆ M A X M B X A ̺ val B ( − ; β ) val A ( − ; β ) ι B β (b) If A and B are closed under subalgebras and X is finite, then the inducedmorphism ̺ X : ˆ M B X → ˆ M A X is surjective.Proof. (a) For a given set X , the family (val B ( − ; β )) β ∈ ( M X ↓A ) forms a conefrom ˆ M B X to the diagram defining ˆ M A X . As the cone (val A ( − ; β )) β ∈ ( M X ↓A ) islimiting, there exists a unique map ̺ X : ˆ M B X → ˆ M A X such that val A ( − ; β ) ◦ ̺ X = val B ( − ; β ) , for all β : M X → A . As the equation val A ( − ; β ) ◦ ι A = β was already proved in Lemma 6.3 (a),it therefore remains to prove that the family ̺ := ( ̺ X ) X forms a morphism ofmonads. To see that it is a natural transformation, consider a function f : X → Y . Then val B ( − ; β ) ◦ ˆ M B f ◦ ̺ = val B ( − ; β ◦ M f ) ◦ ̺ = val A ( − ; β ◦ M f )= val A ( − ; β ) ◦ ˆ M A f = val B ( − ; β ) ◦ ̺ ◦ ˆ M A f . By Corollary 6.4, it follows that ˆ M B f ◦ ̺ = ̺ ◦ ˆ M A f , as desired.34o check the two axioms of a morphism of monads, let µ A and ε A be themultiplication and unit map of ˆ M A , and µ B and ε B those of ˆ M B . For every β : M X → A with A ∈ A , we have val A ( − ; β ) ◦ ̺ ◦ µ B = val B ( − ; β ) ◦ µ B = val B (cid:0) − ; π ◦ M val B ( − ; β ) (cid:1) = val A (cid:0) − ; π ◦ M val B ( − ; β ) (cid:1) ◦ ̺ = val A (cid:0) − ; π ◦ M val A ( − ; β ) ◦ M ̺ (cid:1) ◦ ̺ = val A (cid:0) − ; π ◦ M val A ( − ; β ) (cid:1) ◦ ˆ M ̺ ◦ ̺ = val A ( − ; β ) ◦ µ A ◦ ˆ M ̺ ◦ ̺ and val A ( − ; β ) ◦ ̺ ◦ ε B = val A ( − ; β ) ◦ ̺ ◦ ι B ◦ sing= val B ( − ; β ) ◦ ι B ◦ sing= β ◦ sing= val A ( − ; β ) ◦ ι A ◦ sing = val A ( − ; β ) ◦ ε A . By Corollary 6.4, it follows that ̺ ◦ µ B = µ A ◦ ˆ M ̺ ◦ ̺ and ̺ ◦ ε B = ε A .(b) To apply the topological machinery we have just set up, we translate theproblem into the category of Stone spaces. We equip each algebra in B with thediscrete topology. As these algebras are finitary, the resulting topologies are sort-wise compact, Hausdorff, and zero-dimensional. According to Lemma 6.7 (b), wecan define the limits ˆ M A X and ˆ M B X in terms of only the surjective morphisms β : M X → A with A in A or B . Let Ξ ⊆ Ξ be the set of all sorts ξ such that M ξ X = ∅ . By Lemma 6.3 (d), it follows that these are exactly the same sorts ξ with ˆ M A ,ξ X = ∅ , ˆ M B ,ξ X = ∅ , and with A ξ = ∅ , for A ∈ A . Consequently, wecan perform the rest of the proof in the category Pos Ξ . In this category we canuse Lemma 6.13, which tells us that the limits ˆ M A X and ˆ M B X are also sort-wiseStone spaces when equipped with the cone topology. In addition, the limits inthe category Stone Ξ coincide with ˆ M A X and ˆ M B X . By the definition of the conetopology, all the maps val A ( − ; β ) and val B ( − ; β ) are continuous. Furthermore,since we restricted the diagram to surjective maps β , val B ( − ; β ) ◦ ι = β impliesthat the value maps val B ( − ; β ) are also surjective. By Lemma 6.7 (a), ˆ M A X is acofiltered limit. Consequently, we can use Lemma 6.15, to show that ̺ : ˆ M B X → ˆ M A X is surjective.After these preparations we are finally able to define the type of inequalitieswe use to axiomatise pseudo-varieties and to prove the characterisation theorem. Definition 6.19. Let X be a finite unordered set and A a class of finitary M -algebras.(a) An M -inequality over X is a statement of the form s ≤ t with s, t ∈ ˆ M X .(b) A finitary M -algebra A satisfies an M -inequality s ≤ t over X if val( s ; β ) ≤ val( t ; β ) , for all β : M X → A . We write A | = s ≤ t to denote this fact.(c) The M -theory Th( A ) of A is the set of all M -inequalities s ≤ t satisfiedby every algebra in A . (We do not fix the set X these inequalities are over.)35d) A set Φ of M -inequalities (possibly over several different sets X ) axio-matises the following subclass of A . Mod A ( Φ ) := (cid:8) A ∈ A (cid:12)(cid:12) A | = s ≤ t for all s ≤ t ∈ Φ (cid:9) . y Let us start with the following important property connecting the morph-ism ̺ to the theory of a class A . Lemma 6.20. Let A be a class of M -algebras, X a finite set, and s ≤ t an M -inequality over X . Then s ≤ t ∈ Th( A ) iff ̺ A ( s ) ≤ ̺ A ( t ) , where ̺ A : ˆ M ⇒ ˆ M A is the morphism from Theorem 6.18.Proof. By Lemma 6.3 (e), we have A | = s ≤ t , for all A ∈ A iff val( s ; β ) ≤ val( t ; β ) , for all β : M X → A ∈ A iff val A ( ̺ A ( s ); β ) ≤ val A ( ̺ A ( t ); β ) , for all β : M X → A ∈ A iff ̺ A ( s ) ≤ ̺ A ( t ) . The easier direction is to show that every axiomatisable class is a pseudo-variety. Proposition 6.21. Let A be a pseudo-variety and Φ a set of M -inequalities.Then Mod A ( Φ ) is a pseudo-variety.Proof. We have to check three closure properties. First, consider a finitary sub-algebra A of a product Q i ∈ I B i with B i ∈ Mod A ( Φ ) . Let p k : Q i B i → B k bethe projection. For s ≤ t ∈ Φ over X and β : M X → A it follows that p k (val( s ; β )) = val( s ; p k ◦ β ) ≤ val( t ; p k ◦ β ) = p k (val( t ; β )) , where the second step follows from the fact that B k | = s ≤ t . As the orderingof the product is defined component-wise, this implies that val( s ; β ) ≤ val( t ; β ) .Consequently, A ∈ Mod A ( Φ ) .Next, consider a quotient q : B → A with B ∈ Mod A ( Φ ) . Fix s ≤ t ∈ Φ over X and β : M X → A . Since q is surjective, we can use Lemma 3.4 to findsome γ : M X → A with β = q ◦ γ . Then val( s ; β ) = val( s ; q ◦ γ ) = q (val( s ; γ )) ≤ q (val( t ; γ )) = val( t ; q ◦ γ ) = val( t ; β ) , where the third step follows by monotonicity of q and the fact that B | = s ≤ t .Consequently, A ∈ Mod A ( Φ ) .Finally, suppose that A is a sort-accumulation point of Mod A ( Φ ) . Fix s ≤ t ∈ Φ over X and β : M X → A . We have to show that val A ( s ; β ) ≤ val A ( t ; β ) . Suppose that s, t ∈ ˆ M ξ X and let ∆ ⊆ Ξ be a finite set of sorts containing ξ and all sorts in X . By assumption, there is some algebra B ∈ Mod A ( Φ ) with36 | ∆ ∼ = B | ∆ . Let µ : A | ∆ → B | ∆ be the corresponding isomorphism. Since B | = s ≤ t and s, t ∈ ˆ M | ∆ X , we have (working in the category Pos ∆ ) µ (val A ( s ; β | ∆ )) = val A ( s ; µ ◦ β | ∆ ) ≤ val A ( t ; µ ◦ β | ∆ ) = µ (val A ( t ; β | ∆ )) . As µ is an isomorphism, this implies that val A ( s ; β | ∆ ) ≤ val A ( t ; β | ∆ ) .For the converse statement – that every pseudo-variety is axiomatisable –we start with a proposition. Proposition 6.22. Let V be a pseudo-variety. Then V = { A | A a finitary quotient of ˆ M V X for some finite set X } . Proof. ( ⊆ ) Let A ∈ V . As A is finitely generated, there exists a surjective morph-ism β : M X → A , for some finite set X . The claim follows since val( − ; β ) ◦ ι = β implies that that val( − ; β ) : ˆ M V X → A is also surjective. ( ⊇ ) Let A be finitary and ϕ : ˆ M V X → A be surjective. We have to show that A ∈ V . As V is closed under sort-accumulation points, it is sufficient to showthat, for every finite set ∆ ⊆ Ξ there is some algebra B ∈ V with B | ∆ ∼ = A | ∆ .Hence, fix ∆ ⊆ Ξ . Note that, according to Lemma 6.13 we can define theset ˆ M V | ∆ X as the limit of a cofiltered diagram in Stone ∆ . Furthermore, we haveseen in Corollary 6.17 that the ˆ M | ∆ -algebra ˆ M | ∆ X is finitely copresentable* in SAlg ( ˆ M | ∆ ) . Therefore, there exists an algebra B ∈ V and morphisms β : M X → B and ψ : B | ∆ → A | ∆ such that ϕ | ∆ = ψ ◦ val( − ; β ) | ∆ . Let ⊑ be the congruence ordering of B generated by ker ψ and let ̺ : B → B / ⊑ be the corresponding quotient map. By Lemma 5.8, we have ker ̺ | ∆ = ⊑| ∆ = ker ψ . As ϕ | ∆ is surjective, so is µ . Consequently, µ induces an isomorphism B / ⊑| ∆ ∼ = A | ∆ . Furthermore, by the closure properties of a pseudo-variety, we have B / ⊑ ∈V . Corollary 6.23. Let V and W be pseudo-varieties. (a) V ⊆ W iff Th( V ) ⊇ Th( W ) . (b) Mod(Th( V )) = V . Proof. (a) ( ⇒ ) follows immediately by definition. For ( ⇐ ) , let ̺ V ,X : ˆ M X → ˆ M V X and ̺ W ,X : ˆ M X → ˆ M W X be the morphisms from Theorem 6.18. Itfollows by Lemma 6.20 that Th( W ) ⊆ Th( V ) implies ker ̺ W ,X ⊆ ker ̺ V ,X . Hence„ we can use the Factorisation Lemma to find a morphism q X : ˆ M W X → ˆ M V X such that ̺ V ,X = q X ◦ ̺ W ,X . By Theorem 6.18, the morphism ̺ V ,X is surjective. Hence, so is q X . That means that ˆ M V X is a quotient of ˆ M W X .Consequently, every quotient of ˆ M V X is also a quotient of ˆ M W X and it followsby Proposition 6.22 that V ⊆ W . 37b) We have seen in Proposition 6.21 that the class W := Mod(Th( V )) is apseudo-variety. We have to show that V = W . ( ⊆ ) Let A ∈ V . Then we have A | = s ≤ t , for every s ≤ t in Th( V ) . Thisimplies that A ∈ Mod(Th( V )) = W . ( ⊇ ) By (a) it is sufficient to prove that Th( W ) ⊇ Th( V ) . Hence, let s ≤ t bein Th( V ) . Then A | = s ≤ t , for all A ∈ Mod(Th( V )) = W , which implies that s ≤ t belongs to Th( W ) .We are finally able to state our Reiterman theorem for pseudo-varieties of M -algebras. Theorem 6.24. Let F be the class of all finitary M -algebras. A class V is apseudo-variety if, and only if, it is of the form V = Mod F ( Φ ) , for some set Φ of M -inequalities.Proof. ( ⇐ ) was already proved in Proposition 6.21, and ( ⇒ ) follows by Corol-lary 6.23 since V = Mod F (Th( V )) . We are mainly interested in languages defined by logical formulae. In this sectionwe isolate some abstract properties of a logic ensuring that the correspondinglanguage family forms a varieties and, thus, fits into our framework. We startwith some basic notions. Definition 7.1. (a) A logic is a triple h L, M , | = i consisting of a ( Ξ -sorted,unordered) set L of formulae, a ( Ξ -sorted, unordered) class M of models, anda satisfaction relation | = ⊆ M × L . To keep notation light, we usually identifya logic with its set of formulae L .(b) A morphism of logics h λ, µ i : h L, M , | = i → h L ′ , M ′ , | = ′ i consists of twofunctions λ : L → L ′ and µ : M ′ → M such that M ′ | = ′ λ ( ϕ ) iff µ ( M ′ ) | = ϕ , for all ϕ ∈ L ξ and M ′ ∈ M ′ ξ . We denote the category of all logics and their morphisms by Log .(c) The L -theory of a model M ∈ M ξ is Th L ( M ) := { ϕ ∈ L ξ | M | = ϕ } . For two models M and N , we define M ⊑ L N : iff Th L ( M ) ⊆ Th L ( N ) ,M ≡ L N : iff Th L ( M ) = Th L ( N ) . (d) The class of models of a formula ϕ ∈ L ξ is the set Mod( ϕ ) := { M ∈ M ξ | M | = ϕ } . (e) A class C ⊆ M ξ is L -definable if C = Mod( ϕ ) , for some ϕ ∈ L ξ .(f) A logic L is lattice closed if the collection of all L -definable classes isclosed under finite intersections and unions. y Let us isolate a few simple conditions for when a class of models is definable.38 emma 7.2. Let h L, M , | = i and h L ′ , M ′ , | = i be lattice-closed logics. (a) A class C ⊆ M ξ is L -definable if, and only if, there exists a finite subset ∆ ⊆ L ξ such that M ∈ C and M ⊑ ∆ N implies N ∈ C . (b) For sort-wise finite sets ∆ ⊆ L and ∆ ′ ⊆ L ′ , and a function f : M → M ′ the following two statements are equivalent: (1) M ⊑ ∆ N implies f ( M ) ⊑ ∆ ′ f ( N ) . (2) The preimage f − [ C ′ ] of a ∆ ′ -definable class C ′ ⊆ M ′ is ∆ -definable.Proof. (a) ( ⇒ ) Let ϕ ∈ L ξ be a formula defining C and set ∆ := { ϕ } . Supposethat M ∈ C and M ⊑ ∆ N . Then M | = ϕ , which implies that N | = ϕ . Hence, N ∈ C . ( ⇐ ) Set ϕ := _ (cid:8) ^ Th ∆ ( M ) (cid:12)(cid:12) M ∈ C (cid:9) . For N ∈ M , it follows that N | = ϕ iff N | = ^ Th ∆ ( M ) , for some M ∈ C iff M ⊑ ∆ N , for some M ∈ C iff N ∈ C . (b) (1) ⇒ (2) Suppose that C ′ ⊆ M ′ is ∆ ′ -definable. By (a), it is sufficientto show that M ∈ f − [ C ′ ] and M ⊑ ∆ N implies N ∈ f − [ C ′ ] . Hence, let M ∈ f − [ C ′ ] and M ⊑ ∆ N . Then we have f ( M ) ∈ C ′ and f ( M ) ⊑ ∆ ′ f ( N ) ,by (1). Consequently, (a) implies that f ( N ) ∈ C ′ , that is, N ∈ f − [ C ′ ] . (2) ⇒ (1) Suppose that M ⊑ ∆ N . To show that f ( M ) ⊑ ∆ ′ f ( N ) , weconsider the class C ′ M := { H ∈ M ′ | f ( M ) ⊑ ∆ ′ H } . Note that C ′ M is ∆ ′ -definable by (a). By (2), we know that f − [ C ′ M ] is ∆ -definable. Consequently, itfollows by (a) that M ∈ f − [ C ′ M ] and M ⊑ ∆ N implies N ∈ f − [ C ′ M ] , that is, f ( M ) ⊑ ∆ ′ f ( N ) . Lemma 7.3. Let h L, M , | = i and h L ′ , M ′ , | = i be logics and µ : M ′ → M afunction. The following statements are equivalent. (1) There exists a function λ : L → L ′ such that h λ, µ i : h L, M , | = i →h L ′ , M ′ , | = i is a morphism of logics. (2) If C ⊆ M is L -definable, then µ − [ C ] is L ′ -definable.If L ′ is lattice closed, the following statement is also equivalent to those above. (3) For every sort-finite ∆ ⊆ L , there exists a sort-finite ∆ ′ ⊆ L ′ such that M ⊑ ∆ ′ N implies µ [ M ] ⊑ ∆ µ [ N ] . roof. (1) ⇒ (2) Let ϕ ∈ L be a formula defining C . For M ∈ M , it follows that M ∈ µ − [ C ] iff µ ( M ) ∈ C iff µ ( M ) | = ϕ iff M | = λ ( ϕ ) . Thus, λ ( ϕ ) defines µ − [ C ] .(2) ⇒ (1) We define λ : L → L ′ as follows. For each ϕ ∈ L , the class Mod( ϕ ) is obviously L -definable. By assumption it follows that the preimage µ − [Mod( ϕ )] is defined by some formula ϕ ′ ∈ L ′ . We set λ ( ϕ ) := ϕ ′ .To see that h λ, µ i is a morphism of logics, fix M ∈ M ′ and ϕ ∈ L . Then µ ( M ) | = ϕ iff µ ( M ) ∈ Mod( ϕ )iff M ∈ µ − [Mod( ϕ )] iff M | = λ ( ϕ ) . (1) ⇒ (3) Given ∆ ⊆ L , we set ∆ ′ := λ [ ∆ ] . Suppose that M ⊑ ∆ ′ N . Forevery ϕ ∈ ∆ , we then have the implications µ [ M ] | = ϕ ⇒ M | = λ ( ϕ ) ⇒ N | = λ ( ϕ ) ⇒ µ [ N ] | = ϕ . Consequently, µ [ M ] ⊑ ∆ N .(3) ⇒ (2) Let C ⊆ M be defined by the formula ϕ ∈ L . By assumption,there is some sort-finite set ∆ ′ ⊆ L ′ such that M ⊑ ∆ ′ N implies µ [ M ] ⊑ ϕ µ [ N ] . We use Lemma 7.2 (a) to show that µ − [ C ] is ∆ ′ -definable. Hence, suppose that M ⊑ ∆ ′ N and M ∈ µ − [ C ] . Then µ [ M ] ⊑ ϕ µ [ N ] and, therefore, M ∈ µ − [ C ] ⇒ µ [ M ] | = ϕ ⇒ µ [ N ] | = ϕ ⇒ N ∈ µ − [ C ] . Here, we are mainly interested in logics whose set of models is of the form M Σ with Σ ∈ Alph , as these can be used to define languages. As with familiesof languages, we also need to consider families of logics indexed by the alphabetused. Definition 7.4. (a) A logic L is over an alphabet Σ if its class of models is M Σ .(b) A family of logics is a functor L : Alph → Log such that • for every alphabet Σ , the image L [ Σ ] is a logic over Σ , • for every function f : Σ → Γ , the image L [ f ] is a morphism h λ, µ i of logicswith µ = M f .(c) Let L be a family of logics. A family of languages K is L -definable if K ξ [ Σ ] ⊆ { Mod( ϕ ) | ϕ ∈ L ξ [ Σ ] } , for all Σ ∈ Alph and ξ ∈ Ξ . (d) Let L be a family of logics and A a finite ordered set. We call a subset K ⊆ M A L -definable, if its unordered version ( M ι ) − [ K ] ⊆ MV A is L -definable.(e) A family L of logics is varietal if the class of all L -definable languagesforms a variety of languages.(f) We call a family of logics L (sort-wise) finite if the set of formulae L [ Σ ] is (sort-wise) finite, for every alphabet Σ .(g) To keep notation light we will drop the signature from the notation incases where it is understood. Thus, we frequently write L instead of L [ Σ ] . y 40s the notion of a logic is very general, there is not much one can proof for anarbitrary logic. To get non-trivial statements we need some kind of restriction.As languages come equipped with a monadic composition operation, it is naturalto require our logics to be well-behaved under this form of composition. Thisleads to the following definition. Definition 7.5. A family L of logics is M -compositional if, for every finitesubfamily Φ ⊆ L , there exists some sort-wise finite subfamily Φ ⊆ ∆ ⊆ L suchthat, for all alphabets Σ , the relation ⊑ ∆ [ Σ ] is a congruence ordering on M Σ . y The importance of M -compositionality stems from the fact the set of theoriesof such a logic forms an M -algebra. Proposition 7.6. A family of logics L is M -compositional if, and only if, forevery finite subfamily Φ ⊆ L , there exist • a sort-wise finite subfamily Φ ⊆ ∆ ⊆ L , • a functor Θ ∆ : Alph → Alg ( M ) , and • a surjective natural transformation θ ∆ : ( M ↾ Alph ) ⇒ Θ ∆ such that s ⊑ ∆ [ Σ ] t iff θ ∆ ( s ) ≤ θ ∆ ( t ) , for all s, t ∈ M Σ . Proof. ( ⇐ ) Given Φ ⊆ L , choose Φ ⊆ ∆ ⊆ L such that s ⊑ ∆ [ Σ ] t is equivalentto θ ∆ ( s ) ≤ θ ∆ ( t ) . This implies that the relation ⊑ ∆ [ Σ ] is equal to the kernelof θ ∆ , which is a congruence ordering. ( ⇒ ) Given Φ ⊆ L , choose Φ ⊆ ∆ ⊆ L such that ⊑ ∆ is a congruence ordering.We set Θ ∆ Σ := M Σ/ ⊑ ∆ [ Σ ] and choose for θ ∆ : M Σ → M Σ/ ⊑ ∆ [ Σ ] the quotientmap. Given a function f : Σ → Γ , we define Θ ∆ f : Θ ∆ Σ → Θ ∆ Γ by Θ ∆ f ([ s ] ⊑ ∆ [ Σ ] ) := [ M f ( s )] ⊑ ∆ [ Γ ] . We start by showing that Θ ∆ f is well-defined. Consider two elements s ≡ ∆ [ Σ ] t and suppose that ∆ [ f ] = h λ, M f i , for some λ : ∆ [ Γ ] → ∆ [ Σ ] . For every formula ϕ ∈ ∆ [ Γ ] , it follows that M f ( s ) | = ϕ iff s | = λ ( ϕ ) iff t | = λ ( ϕ ) iff M f ( t ) | = ϕ . Thus, M f ( s ) ≡ ∆ [ Γ ] M f ( t ) .It immediately follows from the above definition that θ ∆ is a natural trans-formation since θ ∆ ( M f ( s )) = [ M f ( s )] ⊑ ∆ [ Γ ] = Θ ∆ f ([ s ] ⊑ ∆ [ Σ ] ) = Θ ∆ f ( θ ∆ ( s )) . Hence, it remains to show that Θ ∆ is a functor. Consider two functions f : Σ → Γ and g : Γ → Υ . As θ ∆ is a natural transformation, we have Θ ∆ ( g ◦ f ) ◦ θ ∆ = θ ∆ ◦ M ( g ◦ f ) = θ ∆ ◦ M g ◦ M f = Θ ∆ g ◦ θ ∆ ◦ M f = Θ ∆ g ◦ Θ ∆ f ◦ θ ∆ . By surjectivity of θ ∆ , this implies that Θ ∆ ( g ◦ f ) = Θ ∆ g ◦ Θ ∆ f .41ext, let us take a look at the closure properties of definable languages.Our first observation concerns closure under inverse relabellings, which holdsfor every logic L . Then we show that M -compositionality implies, but is slightlystronger than, closure under derivatives. Lemma 7.7. Let L be a family of logics. The class of L -definable languages isclosed under inverse relabellings.Proof. If f : Σ → Γ is a morphism of Alph , it follows by the definition of a familyof logics that there is some function λ such that L [ f ] = h λ, M f i is a morphismof logics. Consequently, we can use Lemma 7.3 to show that ( M f ) − [ K ] is L -definable, for every L -definable language K ⊆ M Γ . Lemma 7.8. Let L be an M -compositional family of logics, and let ∆ ⊆ L bea subfamily such that ⊑ ∆ is a congruence ordering. Then s ⊑ ∆ t implies p [ s ] ⊑ ∆ p [ t ] , for all s, t ∈ M Σ and p ∈ M ( Σ + (cid:3) ) . Proof. Set p ′ := M ( θ ∆ + 1)( p ) . By Lemma 4.4 (a), a ≤ b implies p ′ [ a ] ≤ p ′ [ b ] , for a, b ∈ Θ ∆ Σ . Consequently, s ⊑ ∆ t ⇒ θ ∆ ( s ) ≤ θ ∆ ( t ) ⇒ θ ∆ ( p [ s ]) = p ′ ( θ ∆ ( s )) ≤ p ′ ( θ ∆ ( t )) = θ ∆ ( p [ t ]) ⇒ p [ s ] ⊑ ∆ p [ t ] . Usually, the theory algebras Θ ∆ Σ from Proposition 7.6 are not very wellunderstood. (Otherwise, we would not need to introduce a special algebraicframework to study definability questions.) To shed a bit more light on whatthese algebras look like, we present an alternative construction for the theoryfunctor Θ . Definition 7.9. Let L be a family of logics such that every L -definable languagehas a syntactic algebra. The syntactic theory morphism (for an alphabet Σ ) is ˜ θ L := h syn Mod( ϕ ) i ϕ ∈ L [ Σ ] : M Σ → Y ϕ ∈ L [ Σ ] Syn(Mod( ϕ )) . y Lemma 7.10. Let L be a family of lattice-closed logics such that every L -definable language has a syntactic algebra, and let ∆ ⊆ L be sort-wise finite.The following statements are equivalent. (1) The class of ∆ -definable languages is closed under derivatives. (2) s ⊑ ∆ t iff ˜ θ ∆ ( s ) ≤ ˜ θ ∆ ( t ) . (3) s ⊑ ∆ t ⇒ p [ s ] ⊑ ∆ p [ t ] , for all contexts p . Proof. (1) ⇔ (3) follows by Lemma 7.2 (b). (2) ⇔ (3) First, note that in (3) we can replace the implication by an equival-ence since p [ s ] ⊑ ∆ p [ t ] implies s ⊑ ∆ t , if we choose for p the empty context (cid:3) .42onsequently, the equivalence of (2) and (3) follows from the fact that, for s, t ∈ M Σ , ˜ θ ∆ ( s ) ≤ ˜ θ ∆ ( t )iff s (cid:22) Mod( ϕ ) t , for all ϕ ∈ ∆ iff p [ s ] | = ϕ ⇒ p [ t ] | = ϕ , for all contexts p and all ϕ ∈ ∆ iff p [ s ] ⊑ ∆ p [ t ] , for all contexts p . Theorem 7.11. Let L be a family of lattice-closed logics such that every L -definable language has a syntactic algebra. The following statements are equival-ent. (1) L is M -compositional. (2) For every finite Φ ⊆ L , there exists a sort-wise finite Φ ⊆ ∆ ⊆ L such thatthe class of ∆ -definable languages is closed under derivatives.Proof. (1) ⇒ (2) This follows immediately from Lemma 7.2 (b) together withLemma 7.8. (2) ⇒ (1) Given a subfamily ∆ ⊆ L with the above closure properties, itfollows by Lemma 7.10 that ⊑ ∆ = ker ˜ θ ∆ . In particular, ⊑ ∆ is a congruenceordering.Apart from a criterion for M -compositionality, this theorem also gives usan explicit construction of the theory algebra Θ ∆ Σ in language-theoretic terms.It therefore provides a more direct link between properties of a logic L andproperties of the class of L -definable languages. We have finally arrived at the central part of this article where we combinealgebra and logic. It follows from Theorem 5.10 that, to every varietal logic L ,there corresponds a unique pseudo-variety V of M -algebras recognising the fam-ily of L -definable languages. We would like to use these M -algebras to study theexpressive power of our logic L . To do so, we need to know as much as possibleabout how the algebras in V look like. Unfortunately, Theorem 5.10 does tellus not very much about that. The following definition provides a slightly moreconcrete description. Definition 8.1. Let A be an M -algebra and L a family of logics.(a) A finite subset C ⊆ A is L -definably embedded in A if, for every element a ∈ A , the preimage π − ( ⇑ a ) ∩ M C is L -definable.(b) A is locally L -definable if every finite subset C ⊆ A is L -definably em-bedded in A .(c) A is L -definable if it is finitary and locally L -definable. y If our logic L is sufficiently well-behaved, it immediately follows from thisdefinition that L -definable algebras only recognise L -definable languages. (Theconverse, that every L -definable language is recognised by some L -definable43lgebra, is harder to prove. We will do so later in this section.) Note that thiscorrespondence, besides being trivial, is also not that useful for understandingthe expressive power of L , as the definition makes essential use of L -definability.But the above definition can serve as a starting point for deriving more usefuldescriptions – that of course will be specific to the logic in question.Before proving that the L -definable algebras are exactly those that onlyrecognise L -definable languages, let us start by looking at definably embeddedsets. Lemma 8.2. Let A be a finitary M -algebra and L a family of lattice-closedlogics. A finite set C ⊆ A is L -definably embedded in A if, and only if, thereexists a sort-wise finite set ∆ ⊆ L [ C ] such that s ⊑ ∆ t implies π ( s ) ≤ π ( t ) , for all s, t ∈ M C . Proof. ( ⇒ ) Choose a function (of unordered sets) ϑ : A → L such that theformula ϑ ( a ) defines the set π − ( ⇑ a ) ∩ M C . We claim that the set ∆ := rng ϑ has the desired properties. Consider s, t ∈ M C with s ⊑ ∆ t . Then s | = ϑ ( π ( s )) implies t | = ϑ ( π ( s )) . Hence, π ( t ) ≥ π ( s ) . ( ⇐ ) Let ∆ be a sort-wise finite set such that s ⊑ ∆ t implies π ( s ) ≤ π ( t ) , for s, t ∈ M C . Given a ∈ A , we set K := π − ( ⇑ a ) ∩ M C . It follows that s ∈ K and s ⊑ ∆ t implies t ∈ K . Hence, we can use Lemma 7.2 (a) to show that K is L -definable.In general, the closure properties of definably embedded sets are rather weak.To make them better behaved we have to impose some restriction on the logic L . Lemma 8.3. Let A be an M -algebra, L a family of logics, and C ⊆ A finite setthat is L -definably embedded in A . (a) Every subset of C is L -definably embedded in A . (b) If the class of L -definable languages is closed under inverse morphisms,every finite subset D ⊆ h C i is L -definably embedded in A , where h C i de-notes the subalgebra generated by C .Proof. (a) Fix D ⊆ C and let i : D → C be the inclusion map. Then π − ( ⇑ a ) ∩ M D = (cid:0) π − ( ⇑ a ) ∩ M C (cid:1) ∩ M D = ( M i ) − (cid:0) π − ( ⇑ a ) ∩ M C (cid:1) is the image of an L -definable set under an inverse relabelling and, therefore, L -definable by Lemma 7.7.(b) By (a) it is sufficient to consider the case where D = h C i . For every d ∈ D , we can find an element f ( d ) ∈ M C such that π ( f ( d )) = d . This definesa function f with π ◦ f = id D . But note that, in general, f is not monotone.Thus, we only obtain a function f : V D → M C . Let ϕ : MV D → M C be the44unique) extension of f : V D → M C to MV D . Let δ : M ◦ V ⇒ V ◦ M be thenatural isomorphism obtained by the fact that M is order agnostic. Then ι ◦ V π ◦ δ ◦ sing = ι ◦ V π ◦ V sing= ι = π ◦ f = π ◦ ϕ ◦ sing . MV D M C V D VM DD V D ϕ sing f V sing δπ ι V πι As morphisms from a free M -algebra are uniquely determined by their restrictionto rng sing , we have ι ◦ V π ◦ δ = π ◦ ϕ . For a ∈ A , it therefore follows that ( M ι ) − [ π − [ ⇑ a ] ∩ M D ] = ( π ◦ M ι ) − [ ⇑ a ] ∩ VM D = ( π ◦ ι ◦ δ ) − [ ⇑ a ] ∩ VM D = ( ι ◦ V π ◦ δ ) − [ ⇑ a ] ∩ VM D = ( π ◦ ϕ ) − [ ⇑ a ] ∩ VM D = ϕ − [ π − [ ⇑ a ] ∩ M C ] , which is the image of an L -definable language under an inverse morphism. Theway we defined L -definability for ordered sets, this implies that π − [ ⇑ a ] ∩ M D is also L -definable.It follows immediately from the definition that an L -definable algebra onlyrecognises L -definable languages. We start with a slightly more precise state-ment. Theorem 8.4. Let L be a varietal family of logics. An M -algebra A is locally L -definable if, and only if, every language recognised by A is L -definable.Proof. ( ⇐ ) If some finite subset C ⊆ A is not L -definably embedded, we canfind an element a ∈ A such that the preimage K := π − ( a ) ∩ M C is not L -definable. Thus, the restriction π ↾ M C : M C → A of the product is a morphismrecognising the non- L -definable language K . ( ⇒ ) Let ϕ : M Σ → A be a morphism and P ⊆ A ξ an upwards closed set. Byassumption, the set C := rng( ϕ ◦ sing) is L -definably embedded in A . For every a ∈ A ξ , we can therefore fix an L -formula ϑ a defining the set π − ( ⇑ a ) ∩ M C .Setting ϕ := ϕ ◦ sing it follows that t ∈ ϕ − [ P ] iff ϕ ( t ) ∈ P iff π ( M ϕ ( t )) ∈ P iff M ϕ ( t ) | = _ a ∈ P ϑ a . (For the last step, note that M ϕ ( t ) ∈ M C .) As the L -definable languages areclosed under inverse morphisms, we can find a formula χ ∈ L such that M ϕ ( t ) | = _ a ∈ P ϑ a iff t | = χ . Consequently, χ defines ϕ − [ P ] . 45bvious candidates for L -definable algebras are those of the form Θ ∆ Σ fromProposition 7.6. Below we will characterise under which conditions these are L -definable. The proof rests on the following technical result. Lemma 8.5. Let L be an M -compositional family of lattice-closed logics. Forevery sort-wise finite set ∆ ⊆ L such that ⊑ ∆ is a congruence ordering, the set rng( θ ∆ ◦ sing) is L -definably embedded in Θ ∆ Σ .Proof. Set f := θ ∆ ◦ sing : Σ → Θ ∆ Σ and C := rng f . Choose a right inverse g : V C → V Σ of V f : V Σ → V C and let π : M C → Θ ∆ Σ be the restrictionof the product of Θ ∆ Σ to M C . Recall the natural transformations δ and ι fromDefinition 2.5. Then V π ◦ δ = V π ◦ δ ◦ M ( V f ◦ g )= V π ◦ δ ◦ M ( V θ ∆ ◦ V sing ◦ g )= V π ◦ δ ◦ MV θ ∆ ◦ MV sing ◦ M g = V π ◦ VM θ ∆ ◦ VM sing ◦ δ ◦ M g = V θ ∆ ◦ V π ◦ VM sing ◦ δ ◦ M g = V θ ∆ ◦ δ ◦ M g . To show that C is L -definably embedded in Θ ∆ Σ , we fix an element a ∈ Θ ∆ Σ .Then ( M ι ) − [ π − [ ⇑ a ]] = ( π ◦ M ι ) − [ ⇑ a ]= ( π ◦ ι ◦ δ ) − [ ⇑ a ]= ( ι ◦ V π ◦ δ ) − [ ⇑ a ]= ( ι ◦ V θ ∆ ◦ δ ◦ M g ) − [ ⇑ a ]= ( θ ∆ ◦ ι ◦ δ ◦ M g ) − [ ⇑ a ] = ( M ι ◦ M g ) − [ θ − ∆ [ ⇑ a ]] . We can use Lemma 7.2 to show that the language K := θ − ∆ [ ⇑ a ] is L -definable:given s ⊑ ∆ t and s ∈ K , we have θ ∆ ( s ) ≤ θ ∆ ( t ) and θ ∆ ( s ) ≥ a . Thus, θ ∆ ( t ) ≥ a ,i.e., t ∈ K .To conclude the proof, note that we have shown in Lemma 7.7 that the classof L -definable languages is closed under inverse relabellings. Consequently, thelanguage ( M ι ) − [ π − [ ⇑ a ]] = ( M ( ι ◦ g )) − [ K ] is L -definable and, therefore, so is π − [ ⇑ a ] = π − [ ⇑ a ] ∩ M C . Theorem 8.6. Let L be an M -compositional family of lattice-closed logics. Thefollowing statements are equivalent. (1) L is varietal. (2) Every algebra of the form Θ ∆ Σ is L -definable. (3) The class of L -definable languages is closed under inverse morphisms.Proof. (3) ⇒ (1) Closure under inverse morphisms and finite unions and in-tersections holds by assumption, while closure under derivatives was shown inTheorem 7.11.(1) ⇒ (2) First, note that Θ ∆ Σ is finitary: it is generated by the finite set rng( θ ∆ ◦ sing) and, for every sort ξ ∈ Ξ , there are only finitely many elementsin ( Θ ∆ Σ ) ξ , since there are only finitely many subsets of ∆ ξ [ Σ ] .46ence, it remains to show that every finite subset is L -definably embedded.Let D ⊆ Θ ∆ Σ be finite. We have shown in the preceding lemma that the set C := rng( θ ∆ ◦ sing) is L -definably embedded in Θ ∆ Σ . As C generates Θ ∆ Σ ,we have D ⊆ h C i . Consequently, it follows by Lemma 8.3 (b) that D is also L -definably embedded.(2) ⇒ (3) Fix a morphism ϕ : M Σ → M Γ and an L -definable language K ⊆ M ξ Γ . We will construct two sort-wise finite sets ∆, ∆ ′ ⊆ L such that K is ∆ [ Γ ] -definable and s ⊑ ∆ ′ [ Σ ] t implies ϕ ( s ) ⊑ ∆ [ Γ ] ϕ ( t ) , for all s, t ∈ M ξ Σ . Then it follows by Lemma 7.2 (b) that ϕ − [ K ] is L -definable.Hence, it remains to find the sets ∆ and ∆ ′ . As L is M -compositional, wecan choose a sort-wise finite subset ∆ ⊆ L such that K is ∆ [ Γ ] -definable and ⊑ ∆ is a congruence ordering. Set f := θ ∆ ◦ ϕ ◦ sing : Σ → Θ ∆ Γ and C := rng f . By assumption, C is L -definably embedded in Θ ∆ Γ . We can therefore useLemma 8.2 to find a sort-wise finite subset Ψ ⊆ L such that u ⊑ Ψ v implies π ( u ) ≤ π ( v ) , for all u, v ∈ M C . Let ∆ ⊆ ∆ be the (finite) subset of all formulae whose sort is equal to the sortof some element of C . We have shown in Lemma 7.7 that L -definable languagesare closed under inverse relabellings. Therefore, we can use Lemma 7.3 to finda sort-wise finite set Ψ ξ ∪ ∆ ⊆ ∆ ′ ⊆ L such that s ⊑ ∆ ′ [ Σ ] t implies M f ( s ) ⊑ Ψ M f ( t ) . For s, t ∈ M ξ Σ , it follows that s ⊑ ∆ ′ [ Σ ] t ⇒ M f ( s ) ⊑ Ψ M f ( t ) ⇒ θ ∆ ( ϕ ( s )) = π ( M f ( s )) ≤ π ( M f ( t )) = θ ∆ ( ϕ ( t )) ⇒ ϕ ( s ) ⊑ ∆ ϕ ( t ) . As a consequence we obtain the following counterpart to Theorem 8.4. Corollary 8.7. Let L be an M -compositional, varietal family of logics. A lan-guage K ⊆ M Σ is L -definable if, and only if, it is recognised by an L -definablealgebra.Proof. ( ⇐ ) follows from Theorem 8.4. For ( ⇒ ) , fix some sort-wise finite ∆ ⊆ L such that K is ∆ -definable and Θ ∆ Σ exists. The claim follows as Θ ∆ Σ is L -definable by the preceding theorem.For syntactic algebras, we obtain similar statements. Lemma 8.8. Let L be a family of varietal logics. If K ⊆ M ξ Σ is an L -definablelanguage with a syntactic algebra, then Syn( K ) is L -definable. roof. Clearly, Syn( K ) is finitary. Hence, it remains to prove that it is locally L -definable. Let C ⊆ Syn( K ) be finite. Then M := π − ( ⇑ a ) ∩ M C is recognisedby the inclusion map M C → Syn( K ) . By Proposition 4.9 it therefore followsthat M is of the form M = ϕ − (cid:2) [ i Let L be a family of lattice-closed logics such that every L -definable language has a syntactic algebra. The following statements are equival-ent. (1) L is varietal. (2) For every L -definable language K ⊆ M Σ , the syntactic algebra Syn( K ) is L -definable.Proof. (1) ⇒ (2) follows by Lemma 8.8. For (2) ⇒ (1), fix an L -definable lan-guage K ⊆ M ξ Γ . Then K ⊆ syn − K [ P ] where P := syn K [ K ] . For closure underinverse morphisms, consider ϕ : M Σ → M Γ . Then ϕ − [ K ] = ϕ − [syn − K [ P ]] = (syn K ◦ ϕ ) − [ P ] , which is L -definable by Theorem 8.4.For closure under derivatives, consider a context p ∈ M ( Γ + (cid:3) ) . By Propos-ition 4.8, there exists an upwards closed set Q ⊆ Syn( K ) such that p − [ K ] =syn − K [ Q ] . Consequently, p − [ K ] is recognised by Syn( K ) and, hence, L -definableby Theorem 8.4.Next, let us take a look at the closure properties of L -definable algebras. Proposition 8.10. Let L be an M -compositional lattice-closed logic. The classof locally L -definable M -algebras is closed under (a) subalgebras, (b) arbitraryproducts, (c) quotients, and (d) sort-accumulation points.Proof. (a) Suppose that A ⊆ B where B is locally L -definable. Given a finiteset C ⊆ A and an element a ∈ A , note that the set K := π − [ ⇑ a ] ∩ M C has thesame value when evaluated in A and in B . (To see this, note that π [ M C ] ⊆ A as A is closed under π . Hence, ⇑ a ∩ π [ M C ] has the same value in both algebras.)By our assumption on B it thus follows that K is L -definable.(b) First, note that the empty product A has exactly one element ξ of eachsort ξ . Consequently, π − ( ⇑ ξ ) ∩ M C = M C , which is L -definable (by the emptyconjunction).It remains to consider the case of a non-empty product A = Q i ∈ I B i . Givena finite set C ⊆ A , we choose finite sets D i ⊆ B i , for i ∈ I , such that C ⊆ Q i D i .Let p k : Q i B i → B k be the projections. For t ∈ M Q i D i and a ∈ A , we have π ( t ) ≥ a iff π ( M p i ( t )) = p i ( π ( t )) ≥ p i ( a ) for all i . π − ( ⇑ a ) ∩ M C = \ i ∈ I ( M p i ) − (cid:2) π − ( ⇑ p i ( a )) ∩ M D i (cid:3) ∩ M C . For every pair of distinct elements c, d ∈ C , we fix one index i ∈ I with p i ( c ) = p i ( d ) . Let H ⊆ I be the (finite) set of these indices. Then we have c = d iff p i ( c ) = p i ( d ) , for some i ∈ H . It follows that π − ( ⇑ a ) ∩ M C = \ i ∈ I ( M p i ) − (cid:2) π − ( ⇑ p i ( a )) ∩ M D i (cid:3) ∩ M C = \ h ∈ H ( M p h ) − (cid:2) π − ( ⇑ p h ( a )) ∩ M D h (cid:3) ∩ M C = \ h ∈ H ( M j ) − (cid:2) ( M p h ) − (cid:2) π − ( ⇑ p h ( a )) ∩ M D h (cid:3)(cid:3) , where j : C → Q i D i is the inclusion map. Note that we have seen in Lemma 7.7that the L -definable languages are closed under inverse relabellings. As the B i are L -definable and L -is closed under finite conjunctions, the above set is there-fore also L -definable.(c) Let ϕ : A → B be a surjective morphism of M -algebras and suppose that A is locally L -definable. To show that B is also locally L -definable, fix a finiteset D ⊆ B . Since ϕ is surjective, we can find a function f : V B → A such that ϕ ◦ f = ι . We set C := f [ D ] . For b ∈ B , it follows that ( M ι ) − [ π − [ ⇑ b ] ∩ M D ] = ( π ◦ M ι ) − [ ⇑ b ] ∩ MV D = ( π ◦ M ϕ ◦ M f ) − [ ⇑ b ] ∩ MV D = ( ϕ ◦ π ◦ M f ) − [ ⇑ b ] ∩ MV D = ( M f ) − (cid:2) π − [ ϕ − [ ⇑ b ]] (cid:3) ∩ MV D = [ a ∈ ϕ − [ ⇑ b ] ( M f ) − (cid:2) π − [ ⇑ a ] (cid:3) ∩ MV D = [ a ∈ ϕ − [ ⇑ b ] ( M f ) − (cid:2) π − [ ⇑ a ] ∩ M C (cid:3) ∩ MV D . This set is L -definable since each language of the form π − [ ⇑ a ] ∩ M C is L -definable and the class of L -definable languages is closed under finite unionsand inverse relabellings. Consequently, π − [ ⇑ b ] ∩ M D is also L -definable.(d) Let A be a sort-accumulation point of the class of locally L -definable al-gebras. To show that A is also locally L -definable, fix a finite set C ⊆ A and andelement a ∈ A . Let ∆ ⊆ Ξ be a finite set of sorts such that C ∪{ a } ⊆ A | ∆ . By as-sumption, we can find a locally L -definable algebrebra B such that A | ∆ and B | ∆ are isomorphic. Let µ : A | ∆ → B | ∆ by the corresponding isomorphism. Then µ [ C ] is L -definably embedded in B and the set K := π − ( ⇑ µ ( a )) ∩ M µ [ C ] L -definable. By closure under inverse relabellings, the preimage M µ − [ K ] = π − ( ⇑ a ) ∩ M C is also L -definable. Corollary 8.11. Let L be an M -compositional logic that is lattice closed. Theclass of L -definable M -algebras is a pseudo-variety. Note that this corollary also follows directly from Theorem 5.10. By thattheorem we furthermore know that this pseudo-variety is generated by by thesyntactic algebras of L -definable algebras. The next theorem shows that it isalso generated by the theory algebras Θ ∆ Σ . Theorem 8.12. Let L be a varietal M -compositional logic. An M -algebra A is L -definable if, and only if, it belongs the the pseudo-variety V generated byall theory algebras of the form Θ ∆ X where X is some finite set and ∆ ⊆ L asort-wise finite subfamily such that ⊑ ∆ is a congruence ordering.Proof. ( ⇐ ) We have seen in Corollary 8.11 that the class of all L -definablealgebras forms a pseudo-variety W , and in Theorem 8.6 that W contains alltheory algebras. Consequently, V ⊆ W . ( ⇒ ) Let A be L -definable and fix a finite set C ⊆ A of generators. For each a ∈ A , we choose some formula ϑ ( a ) ∈ L defining the set π − [ ⇑ a ] ∩ M C . Thisdefines a function (of unordered sets) ϑ : A → L . For every sort ξ ∈ Ξ , let ∆ ξ ⊆ L be a sort-wise finite set such that ϑ [ A ξ ] ⊆ ∆ ξ and ⊑ ∆ ξ is a congruenceordering. Consider the morphism ψ := h θ ∆ ξ i ξ ∈ Ξ : M C → Y ξ ∈ Ξ Θ ∆ ξ C . For s, t ∈ M ξ C , we have ψ ( s ) ≤ ψ ( t ) ⇒ θ ∆ ξ ( s ) ≤ θ ∆ ξ ( t ) ⇒ s ⊑ ∆ ξ t ⇒ t | = ϑ ( π ( s )) since s | = ϑ ( π ( s )) ⇒ π ( s ) ≤ π ( t ) . Consequently, ker ψ ⊆ ker π and we can use the Factorisation Lemma to finda morphism ̺ : B → A such that π = ̺ ◦ ψ , where B is the subalgebraof Q ξ ∈ Ξ Θ ∆ ξ C induced by rng ψ . In particular, A is a quotient of a finitarysubalgebra of a product of theory algebras, which implies that A ∈ V . Corollary 8.13. Let A be the class of all theory algebras Θ ∆ Σ . A finitary M -algebra is L -definable if, and only if, it satisfies every M -inequality in Th( A ) .Proof. Let V be the pseudo-variety of all L -definable algebras. By Theorem 8.12, V is the smallest pseudo-variety containing A . The class W := Mod(Th( A )) isalso a pseudo-variety containing A . Consequently, V ⊆ W . Furthermore, A ⊆ V implies Th( A ) ⊇ Th( V ) . Hence, it follows by Corollary 6.23 that W = Mod(Th( A )) ⊆ Mod(Th( V )) = V . Theorem 8.14. Let L be an M -compositional varietal family of logics and let K ⊆ M ξ Σ be a language with a syntactic algebra. The following statements areequivalent. (1) K is L -definable. (2) K is recognised by some L -definable algebra. (3) Syn( K ) is L -definable. (4) Syn( K ) is a quotient of Θ ∆ Γ , for some ∆ and Γ . (5) syn K = ̺ ◦ θ ∆ , for some ∆ and a surjective morphism ̺ : Θ ∆ Σ → Syn( K ) . (6) K is recognised by Θ ∆ Γ , for some ∆ and Γ . (7) θ ∆ : M Σ → Θ ∆ Σ recognises K , for some ∆ . (8) Syn( K ) satisfies all M -inequalities s ≤ t that hold in every theory algebra Θ ∆ Γ . (9) There is some ∆ such that s ⊑ ∆ t implies s ∈ K ⇒ t ∈ K , for all s, t ∈ M Σ . (10) ⊑ ∆ ⊆ (cid:22) K , for some ∆ .(Here ∆ ranges over sort-wise finite subsets of L and Γ ranges over alphabets.)Proof. (5) ⇒ (4) is trivial.(4) ⇒ (6) Since syn K : M Σ → Syn( K ) recognises K , the claim follows byLemma 5.5.(6) ⇒ (2) follows by Theorem 8.6.(2) ⇔ (1) was shown in Corollary 8.7.(1) ⇔ (9) was proved in Lemma 7.2.(9) ⇒ (10) Fix a finite set Φ ⊆ L such that s ⊑ Φ t implies s ∈ K ⇒ t ∈ K , and choose a finite set Φ ⊆ ∆ ⊆ L such that Θ ∆ is defined. We claim that ⊑ ∆ ⊆ (cid:22) K . Hence, suppose that s ⊑ ∆ t . Note that we have shown in Lemma 7.8that s ⊑ ∆ t implies p [ s ] ⊑ ∆ p [ t ] , for every context p . By choice of ∆ , it followsthat p [ s ] ∈ K implies p [ t ] ∈ K , for all contexts p . (10) ⇔ (5) Note that ⊑ ∆ = ker θ ∆ and (cid:22) K = ker syn K . For a finite set ∆ ⊆ L , it therefore follows that ⊑ ∆ ⊆ (cid:22) K iff ker θ ∆ ⊆ ker syn K iff syn K = ̺ ◦ θ ∆ , for some ̺ , where the last equivalence holds by the Factorisation Lemma and Lemma 3.3.515) ⇒ (7) Since syn K recognises K , there exists an upwards closed set P ⊆ Syn( K ) such that K = syn − K [ P ] . Setting Q := ̺ − [ P ] , it follows that K = syn − K [ P ] = θ − ∆ [ ̺ − [ P ]] = θ − ∆ [ Q ] . (7) ⇒ (9) Suppose that K = θ − ∆ [ P ] for some upwards closed set P . If s ⊑ ∆ t and s ∈ K , then θ ∆ ( s ) ≤ θ ∆ ( t ) and θ ∆ ( s ) ∈ P , which implies that θ ∆ ( t ) ∈ P , i.e., t ∈ K .(4) ⇒ (3) We have seen in Theorem 8.6 that every theory algebra is L -definable, and in Corollary 8.11 that the class of L -definable algebras forms apseudo-variety. In particular, it is closed under quotients.(3) ⇒ (2) holds as syn K : M Σ → Syn( K ) recognises K .(3) ⇔ (8) follows by Corollary 8.13. As an example, let us see how this abstract framework looks like in the caseof languages of infinite trees. In this case, the functor M maps a given set A to the set of all (finite and infinite) A -labelled trees. There are several possibleways to chose the precise definition for M . We will present two of them denoted T and T × . The latter is the more general one, while the former is a subfunctor.Both operate on the category Pos ω with sorts Ξ := ω . We interpret a sort n < ω as the arity of an element. Given a set A ∈ Pos ω , the set T × A consistsof all (finite or infinite) trees t where each vertex v is labelled by an element a of A such that the arity of a matches the number of successors of v . Hence, theelements of A appear at the leaves of t , those of A at internal vertices withexactly two successors, and so on. In addition to the elements of A we also allowas labels special variable symbols x , x , x , . . . , which are treated as elementsof arity and which are supposed to be distinct from all elements of A . Thus T × A can be interpreted as the set of all (possibly infinite) non-closed terms overthe signature A . The set T × n A consists of all trees t that use only the variablesymbols x , . . . , x n − . Formally, we consider such a tree t ∈ T × n A as a function t : dom( t ) → A + { x , . . . , x n − } where dom( t ) is the set of vertices of t .Note that each variable x i can be used once, several times, or not at all. Thesubset T A ⊆ T × A consists of all those trees that use each variable at most once.(Such trees are sometimes called linear in the literature.) T and T × are clearly polynomial functors. We turn them into monads asfollows. The singleton map sing : A → T × A maps an element a ∈ A n to the tree a ( x , . . . , x n − ) consisting of a root with label a to which are attached n leaveswith labels x , . . . , x n − , respectively. The flattening map flat : T × T × A → T × A works as follows. Given a tree T ∈ T × T × A where each vertex v is labelled bysome tree T ( v ) ∈ T × A , we build a large tree assembled from the trees T ( v ) by • taking the disjoint union of all trees T ( v ) ; • replacing each occurrence of a variable x i in T ( v ) by an edge to the rootof T ( u ) , where u is the ( i + 1) -th successor of v ; • unravelling the resulting directed acyclic graph into a tree.52or details, we refer the reader to [6, 2]. It is now straightforward but a bittedious to check that T × together with these two operations forms a monad.Hence, so is the restriction to T .By necessity the proofs below assume some familiarity with tree automata(more precisely, non-deterministic parity automata) and back-and-forth argu-ments. Readers who want to refresh their knowledge we refer to [23] and [16]for an introduction. Theorem 9.1. T × is essentially finitary over the class of all MSO -definable treealgebras.Proof. Let T reg A ⊆ T × A the set of all regular trees in T × A , i.e., those that, upto isomorphism, have only finitely many distinct subtrees. We claim that theinclusion morphism T reg ⇒ T × is dense over the class of all finite products of MSO -definable tree algebras.Let A , . . . , A n − be MSO -definable, B ⊆ A × · · · × A n − , and t ∈ T B atree with π ( t ) = ¯ a . We have to find a regular tree t ◦ ∈ T reg B with π ( t ◦ ) = ¯ a .Let C i ⊆ A i be a finite set of generators of A i and let A i be a parity automatonrecognising π − ( a i ) ∩ T C . Suppose that Q i is the set of states of A i , K i the setof priorities used by it, and Ω i : Q i → K i the corresponding priority function.For every ¯ b ∈ B , we fix trees σ i (¯ b ) ∈ T C i with π ( σ i (¯ b )) = b i , for i < n . Thisdefines a function σ i : V B → TV C i , which we can extend to a morphism ˆ σ i : TV B → TV C i .We construct the desired tree t ◦ by the following variant of the usual Automaton–Pathfinder game (see, e.g., [23]). In this game Automaton tries to construct atree s ∈ T B such that, for every i < n , ˆ σ i ( s ) is accepted by A i , while Pathfindertries to prove that such a tree does not exist. We will define the game in such away that there is a correspondence between winning strategies for Automatonand such trees s . Note that these are exactly the trees s with π ( s ) = ¯ a , since π (ˆ σ i ( s )) = π (flat( T σ i ( s ))) = π ( T π ( T σ i ( s ))) = π ( T p i ( s )) = p i ( π ( s )) , where p i : A × · · · × A n − → A i is the i -th projection. As π ( t ) = ¯ a , it followsthat Automaton indeed has a winning strategy for the game. Furthermore, thewinning condition of our game is regular. Therefore, it follows by the Büchi-Landweber Theorem [14] that Automaton even has a winning strategy that usesonly a finite amount of memory. As the trees s corresponding to finite-memorystrategies via the above correspondence are regular, the claim follows.To conclude the proof, it therefore remains to define a regular game with theabove properties. In each round, Automaton picks the label ¯ b ∈ B for the nextvertex v of s and Pathfinder responds by choosing one of the successors of v .While doing so, we have to keep track of all the states of the various automatafrom which we want to accept the remaining subtree.The positions for Automaton are of the form ¯ U ∈ Q i Every MSO -definable language has a syntactic algebra. Our next goal is to show that MSO and FO are varietal and compositional.We start with MSO . Theorem 9.3. The logic MSO is T × -compositional and, therefore, also T -com-positional.Proof. We start with a bit of terminology. A partial run of a tree automaton A on some tree t ∈ T × Σ is a function ̺ assigning states to the vertices of t in sucha way that • ̺ satisfies the transition relation of A at every vertex with a label in Σ , • there is no restriction on ̺ ( v ) if v is the root or a leaf labelled by a variable, • every infinite branch of ̺ satisfies the parity condition.The profile of a partial run ̺ on a tree t is the tuple τ = h p, ¯ U i where p is thestate at the root of t and U i is the set of all pairs h k, q i such that there existssome leaf v of t labelled x i with state q := ̺ ( v ) and such that the least priorityseen along the path from the root to v is equal to k .Because of the translations between formulae and automata, there exists, forevery automaton A and each profile τ of A , an MSO -formula ϕ A ,τ stating that54here is a partial run of A on the given tree with profile τ . Furthermore, every MSO -formula is equivalent to some formula of this kind.For m < ω , let MSO ( m ) denote the set of all MSO -formulae equivalent to aformula of the form ϕ A ,τ where A is an automaton with at most m states, and let ≡ ( m ) be the equivalence relation which holds for two trees if they satisfy the same MSO ( m ) -formulae. We claim that ≡ ( m ) is a congruence ordering. This meansthat, if S, T ∈ T × T × Σ are trees with the same ‘shape’, i.e., dom( S ) = dom( T ) ,then S ( v ) ≡ ( m ) T ( v ) , for all v , implies flat( S ) ≡ ( m ) flat( T ) . For the proof, fix a formula ϕ A ,τ ∈ MSO ( m ) with flat( S ) | = ϕ . We haveto show that flat( T ) also satisfies ϕ A ,τ , i.e., that there is a partial run of A on flat( T ) with profile τ . To do so, we introduce the following variant of theAutomaton–Pathfinder game. For a given tree T ∈ T × T × Σ , Player Automatontries to prove that there is a partial run of A on flat( T ) with profile τ , whilePathfinder tries to disprove him. The game starts in the position h r, τ i where r is the root of T . In a position h v, υ i where v ∈ dom( T ) and υ is a profile,Automaton tries to show that there exists a partial run ̺ on the subtree rootedat v with profile υ . He starts by choosing a partial run ̺ of A on the tree T ( v ) starting in the same state as υ . Then he has to choose profiles ¯ λ for all thesubtrees attached to the copy of T ( v ) in flat( T ) such that the ‘composition’ ofthe profile of ̺ and ¯ λ is equal to υ . This is done as follows.Let µ = h p, ¯ U i be the profile of ̺ . For each component U i , Automatonchooses a set W i of triples h k, q, λ i where k is a priority, q a state, and λ aprofile. These sets must satisfy the following conditions. • U i is the projection of W i to the first two components. • For each h k, q, λ i ∈ W i , the state q is equal to the starting state of λ . • υ = h p, ¯ V i is the composition of µ and the profiles λ . Formally, V i = (cid:8) h l, q ′ i (cid:12)(cid:12) h k, q, λ i ∈ W i , λ = h q, ¯ L i , h k ′ , q ′ i ∈ L ,l = min { k, k ′ } (cid:9) . Let u , . . . , u n − be the successors of v . Given ¯ W , Pathfinder responds by choos-ing a successor u i of v and a triple h k, q, λ i ∈ W i . Then the game continues inthe position h u i , λ i .If the game reaches a leaf of T , it ends with a win for one of the players.If the leaf is labelled by a variable x i and the current position is h v, υ i , thenAutomaton wins if, and only if, υ is of the form h q, ¯ U i with U i = { q } and U j = ∅ ,for j = i . Otherwise, Pathfinder wins. If the leaf is not labelled by a variable,then Automaton wins if he can choose µ = h p, ¯ U i such that U i = ∅ , for all i .In the case where the game is infinite, Automaton wins if the sequence ofpairs h k , q , λ i , h k , q , λ i , . . . chosen by Pathfinder satisfies the parity condi-tion lim inf i<ω k i is even . It is straightforward to check that Automaton wins the game on a giventree T if, and only if, there exists a partial run of A on flat( T ) with profile τ .55Every partial run of A on flat( T ) with this profile gives rise to a winning strategyin the game and, conversely, every winning strategy can be used to construct apartial run with the desired profile.)To conclude the proof we have to show that, if T is a tree with S ( v ) ≡ ( m ) T ( v ) , for all v , then Automaton has a winning strategy in the game on T . Byconstruction, Automaton has a winning strategy σ in the game on S . We use itto define a winning strategy σ ′ in the game on T as follows. If σ tells Automatonto choose a partial run ̺ on S ( v ) , σ ′ returns some partial run ̺ ′ on T ( v ) with thesame profile as ̺ . (This is possible since S ( v ) ≡ ( m ) T ( v ) .) As only the profile ofthe chosen run is used by the game and σ is winning, it follows that the resultingstrategy σ ′ is also winning. Remark. Note that in the above proof we have chosen a rather strange stratific-ation of MSO . It might be nice if we could use the usual stratification in termsof the quantifier-rank instead, but this does not seem to work for T × . For themonad T on the other hand, there is an alternative proof consisting of a simpleinductive back-and-forth argument based on the quantifier-rank.To show that MSO is varietal it suffices, by Theorem 8.6, to prove that thetheory algebras are MSO -definable, Proposition 9.4. Let Σ be an alphabet and ∆ m := MSO ( m ) the fragment of MSO used in the proof of Theorem 9.3. The theory algebra Θ ∆ m Σ is MSO -definable.Proof. The set C := θ ∆ m [ Σ ] is a finite set of generators of Θ ∆ m Σ . Given a ∆ m -theory σ ∈ Θ ∆ m Σ , we have to find an MSO -formula ϕ defining the set π − ( σ ) ∩ M C . Each formula χ ∈ σ is a statement of the form: ‘there exists a partial run ofthe automaton A with profile τ ’. Let us write χ = χ A ,τ to mark the relevantparameters. For t ∈ M C , it follows that π ( t ) = σ if, and only if, for every tree s ∈ M Σ with M θ ∆ m ( s ) = t and every χ ∈ σ , there exists a partial run of thecorresponding automaton on s with the corresponding profile. Consequently, todefine the above preimage it is sufficient to express, for a given automaton A anda profile τ , that every preimage of the given tree t under M θ ∆ m has a partialrun of A with profile τ . This can be done by saying that, for every vertex v there is some formula χ A ,υ v ∈ t ( v ) such that the ‘composition’ of the profiles υ v yields τ . For this composition, we have to check that the states at the bordersmatch and to compute the minimal priorities on each branch. All of this caneasily be done in MSO .Let us turn to FO next. Again, we start with compositionality. Theorem 9.5. The logic FO is T × -compositional and, therefore, also T -com-positional.Proof. Let FO m denote the set of all first-order formulae of quantifier-rank atmost m and denote by ≡ m equivalence with respect to such formulae. We use asignature consisting of the tree order (cid:22) , successor relations S i , for i < ω , unarypredicates P a , for each symbol a ∈ Σ , unary predicates Q i , for each variable x i ,56nd a constant r for the root. We claim that ≡ m is a congruence on T × Σ . Hence,consider two trees S, T ∈ T × T × Σ with dom( S ) = dom( T ) satisfying S ( v ) ≡ m T ( v ) , for all vertices v . We have to show that flat( S ) ≡ m flat( T ) .The proof is by induction on m . To make the inductive step go throughwe have to prove a slightly stronger statement involving parameters. Given atuple ¯ a of vertices of flat( S ) and a copy s of S ( v ) in flat( S ) , we denote by ¯ a s the tuple a si := a i if a i ∈ dom( s ) ,v if v is a leave of s labelled by a variable and a i is a descendantof v in flat( S ) ,u if v is the root of s and a i is not a descendent of v in flat( S ) . We use the same notation for parameters in flat( T ) . For a tuple ¯ a of vertices ofsome tree s , we write h s, ¯ a i for the expansion of s by constants for the vertices ¯ a .The claim we prove is that, for trees S, T ∈ T × T × Σ with parameters ¯ a in flat( S ) and ¯ b in flat( T ) , h s, ¯ a s i ≡ m h t, ¯ b t i , for all v, copies s of S ( v ) , and copies t of T ( v ) , implies that h flat( S ) , ¯ a i ≡ m h flat( T ) , ¯ b i . For m = 0 , the proof is straightforward. For the inductive step, suppose that h s, ¯ a s i ≡ m +1 h t, ¯ b t i , for all v, copies s of S ( v ) , and copies t of T ( v ) . We use a back-and-forth argument to show that h flat( S ) , ¯ a i ≡ m +1 h flat( T ) , ¯ b i .Let c ∈ dom(flat( S )) be a new parameter. Suppose that c belongs to a copy s of the tree S ( v ) . When we want to apply the inductive hypothesis, we now facethe problem that, if flat( S ) contains several copies of S ( v ) , only one of themcontains the new parameter. To solve this issue, we have to modify the trees S and T to make sure this does not happen.Let v , . . . , v n be the path from the root v of S to v = v n and let s i bethe copy of S ( v i ) in flat( S ) such that c is a descendent of the root of s i . Weconstruct new trees S , . . . , S n and T , . . . , T n as follows. We start with S := S and T := T . For the inductive step, suppose we have already defined S i and T i for some i < n and that there is a unique copy t i of T i ( v i ) in flat( T i ) . We choosea vertex d i of t i such that h s i , ¯ a s i c s i i ≡ m h t i , ¯ b t i d i i . Note that the vertex c s i is a leaf labelled by some variable x j . Hence, so is d i . Ifthere is no other occurrence of x j in s i , we set S i +1 := S i . Otherwise, we choosesome variable x k that does not appear in s i and we replace every occurrenceof x j in s i by x k , except for the one at c s i . Let S i +1 be the tree obtained from S i by 57 changing S ( v i ) = s i in this way and • duplicating the subtree attached to v i that corresponds to the variable x j in such a way that the new copy corresponds to the variable x k .This ensures that flat( S i +1 ) = flat( S i ) and that S i +1 contains a unique copy of S ( v i +1 ) . The tree T i +1 is obtained from T i in exactly the same way.Having constructed S n and T n , we choose some element d n ∈ dom( T n ( v n )) such that h s n , ¯ a s n c s n i ≡ m h t n , ¯ b t n d n i . Setting d := d n , it follows that d t i = d i , for all i ≤ n , which implies that h s i , ¯ a s i c s i i ≡ m h t i , ¯ b t i d t i i , for all i ≤ n . Note that, if u is a vertex different from v , . . . , v n , s a copy of S n ( u ) and t acopy of T n ( u ) , then c s is the root of s and d s is the root of t . Consequently, wealso have h s, ¯ a s c s i ≡ m h t, ¯ b t d t i . Hence, the trees S n and T n together with the parameters ¯ a, c and ¯ b, d satisfyour inductive hypothesis and it follows that h flat( S n ) , ¯ a, c i ≡ m h flat( T n ) , ¯ b, d i . Since flat( S n ) = flat( S ) and flat( T n ) = flat( T ) , the claim follows.In the same way we can show that, for every choice of d in flat( T ) , we finda matching vertex c in flat( S ) .It remains to show that FO is varietal. It turns out that this is only the casefor the monad T , but not for T × . Proposition 9.6. FO is closed under inverse morphisms of T -algebras.Proof. Let ϕ : T Σ → T Γ be a morphism of T -algebras and let ϕ := ϕ ◦ sing : Σ → T Γ be its restriction to Σ . For s, t ∈ T Σ , we will prove that s ≡ m t implies ϕ ( s ) ≡ m ϕ ( t ) , where ≡ m denotes equivalence with respect to FO -formulae of quantifier-rankat most m . For the induction we again need to prove a more general statementinvolving parameters. We start with setting up a bit of notation.Note that a tree of the form ϕ ( s ) = flat( T ϕ ( s )) is obtained from s byreplacing each vertex u by a tree ϕ ( s ( u )) . For s ∈ T Σ , we denote by g s :dom( ϕ ( s )) → dom( s ) the function mapping a vertex u of ϕ ( s ) to the vertex v := g s ( u ) such that the copy of the tree ϕ ( s ( v )) replacing v in ϕ ( s ) contains u . (Notethat this copy of ϕ ( s ( v )) is unqiue, since we are dealing with the monad T .)For an n -tuple ¯ a of vertices of ϕ ( s ) and a vertex u of s , we set I u := { i < n | g s ( a i ) = u } and ¯ a u := ( a i ) i ∈ I u , where we consider ¯ a u as a tuple of vertices of ϕ ( s ( u )) .58he statement we will prove by induction on m is the following. Let s, t ∈ M Σ be trees and ¯ a and ¯ b n -tuples of parameters of, respectively, ϕ ( s ) and ϕ ( t ) .Then (cid:10) s, g s (¯ a ) (cid:11) ≡ m (cid:10) t, g t (¯ b ) (cid:11) and (cid:10) ϕ ( s ( u )) , ¯ a u (cid:11) ∼ = (cid:10) ϕ ( t ( v )) , ¯ b v (cid:11) , for all u, v with I u = I v = ∅ , implies h ϕ ( s ) , ¯ a i ≡ m h ϕ ( t ) , ¯ b i . For m = 0 , this is immediate. Hence, suppose that m > . We have to checkthe back-and-forth properties. Thus, let c ∈ dom( ϕ ( s )) and set u := g s ( c ) . Thenthere is some v ∈ dom( t ) such that h s, g s (¯ a ) , g s ( c ) i ≡ m − h t, g t (¯ b ) , v i . We distinguish two cases. If I u = ∅ , then there exists an isomorphism σ : (cid:10) ϕ ( s ( u )) , ¯ a u (cid:11) → (cid:10) ϕ ( t ( v )) , ¯ b v (cid:11) and we can set d := σ ( c ) .Otherwise, s ( u ) = t ( v ) implies that ϕ ( s ( u )) ∼ = ϕ ( t ( v )) , and we can choosesome element d of ϕ ( t ) such that (cid:10) ϕ ( s ( u )) , c (cid:11) ∼ = (cid:10) ϕ ( t ( v )) , d (cid:11) . In both cases, it now follows that (cid:10) s, g s (¯ a ) , g s ( c ) (cid:11) ≡ m (cid:10) t, g t (¯ b ) , g t ( d ) (cid:11) and (cid:10) ϕ ( s ( u )) , ¯ a u c u (cid:11) ∼ = (cid:10) ϕ ( t ( v )) , ¯ b v d v (cid:11) , for all u, v with I u = I v = ∅ , which, by inductive hypothesis, implies that h ϕ ( s ) , ¯ ac i ≡ m − h ϕ ( t ) , ¯ bd i . The other direction follows by symmetry.As already noted by Bojańczyk and Michalewski [10], FO is not closed underinverse morphisms of T × -algebras. Their counterexample rests on the followinglemma. Recall that a tree is complete binary if every non-leaf has exactly twosuccessors. Lemma 9.7 (Potthoff [20]) . There exists a first-order formula ϕ such that afinite complete binary tree T = h T, S , S , (cid:22)i satisfies ϕ if, and only if, everyleaf of T has an even distance from the root.Proof. The basic idea is as follows. If every leaf is at an even distance from theroot, we can determine whether a vertex x belongs to an even level of the treeby walking a zig-zag path from x downwards until we hit a leaf. For such a pathit is trivial to check that its length is even. Hence, our formula only needs toexpress that the level parities computed in this way are consistent and that theroot is on an even level. 59o express all this in first-order logic, we first define a few auxiliary formulae. suc( x, y ) := S ( x, y ) ∨ S ( x, y )zigzag( x, y ; u, v ) := [ S ( x, y ) ∧ S ( u, v )] ∨ [ S ( x, y ) ∧ S ( u, v )]probe( x, y ) := x (cid:22) y ∧ ¬∃ z [suc( y, z )] ∧ ∀ u ∀ v ∀ w [ x (cid:22) u ∧ suc( u, v ) ∧ suc( v, w ) ∧ w (cid:22) y → zigzag( u, v ; v, w )] . The first one just states that y is a successor of x ; the second one says that h x, y i and h u, v i are two edges that go into different directions, one to the left and oneto the right; and the last one states that y is one of the two leaves below x thatare reached by a zig-zag path consisting of alternatingly taking left and rightsuccessors.Using these formulae we can express that a vertex x has an even distancefrom some leaf by even( x ) := ∃ y [probe( x, y ) ∧∃ u ∃ v [ x = y ∨ [suc( x, u ) ∧ u (cid:22) v ∧ suc( v, y ) ∧ zigzag( x, u ; v, y )]]] . Consequently, we can write the desired formula as ∀ x ∀ y [suc( x, y ) → [even( x ) ↔ ¬ even( y )]] ∧ ∃ x ∀ y [ x (cid:22) y ∧ even( x )] . Corollary 9.8 (Bojańczyk, Michalewski [10]) . FO is not closed under inversemorphisms of T × -algebras.Proof. Let Σ := { a, c } and Γ := { b, c } where a is unary, b binary, and c aconstant, and let ϕ := T × Σ → T × Γ be the morphism mapping a to b ( x , x ) and c to c . Let K ⊆ T × Γ be the set of all trees where every leave is at an evendepth. By Lemma 9.7, K is FO -definable. But ϕ − [ K ] is the set of all paths a n ( c ) where n is even, which is not FO -definable. Theorem 9.9. (a) MSO is varietal with respect to the functors T and T × . (b) FO is varietal with respect to the functor T , but not with respect to T × .Proof. Both claims follow by Theorem 8.6.It follows that the framework we have set up applies to MSO and FO : (i) MSO -definable languages have syntactic algebras; (ii) the class of all such languagesforms a variety of languages; (iii) every subvariety can be axiomatised by a setof inequalities. In particular, we can use Theorem 8.14 to study the expressivepower of these two logics.When the functors T and T × were introduced, it was not quite clear whichvariant was the right one. The preceding proposition is an indication that T isto be preferred over T × . For instance, it follows from the general results abovethat the syntactic T -algebra of every first-order definable language is first-orderdefinable. Furthermore, we know that there must exist a set of T -inequalitiesaxiomatising first-order definability, even it is still unknown at the moment howit might look like. The hope is that such a set of inequalities can be used todevise a decision procedure for first-order definability of a given tree language.For simpler logics, the algebraic methods developed in this article have alreadysucessfully be used to obtain such decision procedures [3].60 eferences [1] J. Adámek and H. E. Porst , On tree coalgebras and coalgebra presentations ,Theoretical Computer Science, 311 (2004), pp. 257–283.[2] A. Blumensath , Branch-Continuous Tree Algebras . arXiv:1807.04568,unpublished.[3] , ω -Forest Algebras and Temporal Logics . unpublished.[4] , Recognisability for algebras of infinite trees , Theoretical ComputerScience, 412 (2011), pp. 3463–3486.[5] , An Algebraic Proof of Rabin’s Tree Theorem , Theoretical ComputerScience, 478 (2013), pp. 1–21.[6] , Regular Tree Algebras , Logical Methods in Computer Science, 16 (2020),pp. 16:1–16:25.[7] M. Bojańczyk , Recognisable languages over monads . unpublished note,arXiv:1502.04898v1.[8] M. Bojańczyk and T. Idziaszek , Algebra for Infinite Forests with anApplication to the Temporal Logic EF , in Proc. 20th International Conference onConcurrency Theory, CONCUR , LNCS 5710 , 2009, pp. 131–145.[9] M. Bojańczyk, T. Idziaszek, and M. Skrzypczak , Regular languages ofthin trees , in Proc. 30th International Symposium on Theoretical Aspects ofComputer Science, STACS M. Bojańczyk and H. Michalewski , Some connections between universalalgebra and logics for trees . arXiv:1703.04736, unpublished.[11] M. Bojańczyk and I. Walukiewicz , Forest Algebras , in Logic and Automata:History and Perspectives, J. Flum, E. Grädel, and T. Wilke, eds., AmsterdamUniversity Press, 2007, pp. 107–132.[12] F. Borceux , Handbook of Categorical Algebra , vol. 2, Cambridge UniversityPress, 1994.[13] , Handbook of Categorical Algebra , vol. 1, Cambridge University Press,1994.[14] J. R. Büchi and L. H. Landweber , Solving sequential conditions byfinite-state strategies , Trans. Amer. Math. Soc., 139 (1969), pp. 367–378.[15] L.-T. Chen, J. Adámek, S. Milius, and H. Urbat , Profinite monads,profinite equations and reiterman’s theorem , in Proc. 19th Int. Conference onFoundations of Software Science and Computation Structures, FoSSaCS , 2016,pp. 531–547. (preprint with proofs: arXiv:1511.02147).[16] H.-D. Ebbinghaus and J. Flum , Finite Model Theory , Springer Verlag, 1995.[17] P. T. Johnstone , Stone spaces , Cambridge University Press, 1982.[18] S. Milius and H. Urbat , Equational Axiomatization of Algebras withStructure , in Proc. 22nd International Conference on Foundations of SoftwareScience and Computation Structures, FOSSACS D. Perrin and J.-É. Pin , Infinite Words – Automata, Semigroups, Logic andGames , Elsevier, 2004.[20] A. Potthoff , Logische Klassifizierung regulärer Baumsprachen , Ph. D. Thesis,Universität Kiel, Kiel, 1994.[21] J. Reiterman , The Birkhoff theorem for finite algebras , Algebra Universalis, 14(1982), pp. 1–10. L. Ribes and P. Zalesskii , Profinite Groups , Springer-Verlag, 2010.[23] W. Thomas , Languages, Automata, and Logic , in Handbook of FormalLanguages, G. Rozenberg and A. Salomaa, eds., vol. 3, Springer, New York,1997, pp. 389–455.[24] H. Urbat, J. Adámek, L.-T. Chen, and S. Milius , Eilenberg theorems forfree , in 42nd International Symposium on Mathematical Foundations ofComputer Science, MFCS 2017, August 21–25, 2017 – Aalborg, Denmark,vol. 83, Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2017,pp. 43:1–43:15., in 42nd International Symposium on Mathematical Foundations ofComputer Science, MFCS 2017, August 21–25, 2017 – Aalborg, Denmark,vol. 83, Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2017,pp. 43:1–43:15.