Steps and Traces

. In the theory of coalgebras, trace semantics can be deﬁned in various distinct ways, including through algebraic logics, the Kleisli category of a monad or its Eilenberg-Moore category. This paper elaborates two new unifying ideas: 1) coalgebraic trace semantics is naturally presented in terms of corecursive algebras, and 2) all three approaches arise as instances of the same abstract setting. Our perspective puts the different approaches under a common roof, and allows to derive conditions under which some of them coincide.


Introduction
Traces are used in the semantics of state-based systems as a way of recording the consecutive behaviour of a state in terms of sequences of observable (input and/or output) actions. Trace semantics leads to, for instance, the notion of trace equivalence, which expresses that two states cannot be distinguished by only looking at their iterated in/output behaviour.
For many years already, trace semantics is a central topic of interest in the coalgebra community -and not only there, of course. One of the key features of the area of coalgebra is that states and their coalgebras can be considered in different universes, formalised as categories. The break-through insight is that trace semantics for a system in universe A can often be obtained by switching to a different universe B. More explicitly, where the (ordinary) behaviour of the system can be described via a final coalgebra in universe A, the trace behaviour arises by finality in the different universe B. Typically, the alternative universe B is a category of algebraic logics, the Kleisli category, or the category of Eilenberg-Moore algebras, of a monad on universe A. This paper elaborates two new unifying ideas.
1. We observe that the trace map from the state space of a coalgebra to a carrier of traces is in all three situations the unique 'coalgebra-to-algebra' map to a corecursive algebra [6] of traces. This differs from earlier work which tries to describe traces as final coalgebras. For us it is quite natural to view languages as algebras, certainly when they consist of finite words/traces.
2. Next, these corecursive algebras, used as spaces of traces, all arise via a uniform construction, in a setting given by an adjunction together with a special natural transformation that we call a 'step'. We heavily rely on a basic result saying that in this situation, the (lifting of the) right adjoint preserves corecursive algebras, sending them from one universe to another. This is a known result [5], but its fundamental role in trace semantics has not be recognized before. For an arbitrary coalgebra there is then a unique map to the transferred corecursive algebra; this is the trace map that we are after.
The main contribution of this paper is the unifying step-based approach to coalgebraic trace semantics: it is shown that three existing flavours of trace semantics -logical, Eilenberg-Moore, Kleisli -are all instances of our approach. Moreover, comparison results are given relating two of these forms of trace semantics, namely logic-to-Eilenberg-Moore and logic-to-Kleisli. The other combinations involve subtleties which we do not fully grasp yet. Due to space limitations, we don't cover the whole field of coalgebraic trace semantics: we focus only on finite trace semantics, and also exclude at this stage the 'iteration' based approaches, e.g., in [25,22,8].
Outline. The paper is organised as follows. It starts in Section 1 with the abstract step-and-adjunction setting, and the relevant definitions and results for corecursive algebras. In the next three sections, it is explained how this setting gives rise to trace semantics, by presenting the above-mentioned three approaches to coalgebraic trace semantics in terms of steps and adjunctions: Eilenberg-Moore (Section 3), logical (Section 4) and Kleisli (Section 5). In each case, the relevant corecursive algebra is described. These sections are illustrated with several examples. The next section establishes a connection between the Eilenberg-Moore and the logical approach, and a connection between the Kleisli and logical approach (Section 6). In Section 7 we briefly show that our construction of corecursive algebras strengthens to a construction of completely iterative algebras. Finally, in Section 8 we provide some directions for future work.
Notation. In the context of an adjunction F G, we shall use overline notation (−) for adjoint transposition. The unit and counit of an adjunction are, as usual, written as η and ε.
For an endofunctor H, we write Alg(H) for its algebra category and CoAlg(H) for its coalgebra category. For a monad (T, η, µ) on C, we write EM(T ) for the Eilenberg-Moore category and K (T ) for the Kleisli category.
We recall that any functor S : Sets → Sets has a unique strength st. We write st :

Coalgebraic semantics from a step
This section is about the construction of corecursive algebras and their use for semantics. The notion of corecursive algebra, studied in [9,6] as the dual of Taylor's notion of recursive coalgebra [10], is defined as follows.

Definition 1.
Let H be an endofunctor on a category C.

1.
A coalgebra-to-algebra morphism from a coalgebra c : X → H(X) to an algebra a : commutes. Equivalently: such a morphism is a fixpoint for the endofunction on the homset C(X, A) sending f to the composite 2. An algebra a : H(A) → A is corecursive when for every coalgebra c : H → H(X) there is a unique coalgebra-to-algebra morphism (X, c) → (A, a).
Here is some intuition.
-As explained in [14], the specification of a coalgebra-to-algebra morphism f is a "divide-and-conquer" algorithm. It says: to operate on an argument, first decompose it via the coalgebra c, then operate on each component via H(f ), then combine the results via the algebra a.
For most functors of interest, this final coalgebra gives semantics up to bisimilarity, which is finer than trace equivalence. So trace semantics requires a different corecursive algebra.
In all our examples, we use the same procedure for obtaining a corecursive algebra, which we shall now explain. Our basic setting consists of an adjunction, two endofunctors, and a natural transformation: The natural transformation ρ : HG ⇒ GL will be called a step. Here H is the behaviour functor : we study H-coalgebras and give semantics for them in a corecursive H-algebra. This arrangement is well-known in the area of coalgebraic modal logic [3,27,20,7,24], but we shall see that its application is wider. A step can be formulated in several equivalent ways [18,23].
Theorem 2. In the situation (1), there are bijective correspondences between natural transformations ρ 1 : HG ⇒ GL, ρ 2 : F H ⇒ LF , ρ 3 : F HG ⇒ L and ρ 4 : H ⇒ GLF . Moreover, if H and L happen to be monads, then ρ 1 is an EM-law (map HG ⇒ GL compatible with the monad structures) iff ρ 2 is a K -law (map F H ⇒ LF compatible with the monad structures) iff ρ 4 is a monad map; and two further equivalent characterisations are respectively a lifting of G or an extension of F : Proof. We only mention the bijective correspondences: ρ 1 and ρ 3 correspond by adjoint transposition, and similarly for ρ 2 and ρ 4 . Further, ρ 2 and ρ 3 are obtained from each other by: It is common to refer to ρ 1 and ρ 2 as mates; the other two maps are their adjoint transposes. In diagrams we omit the subscript i in ρ i and let the type determine which version of ρ is meant.
Further, in the remainder of this paper we drop the usual subscript of components of natural transformations. dually, a lifting F ρ of the left adjoint F , called the step-induced coalgebra lifting: Our approach relies on the following basic result. Thus, by analogy with the familiar statement that "right adjoints preserves limits", we have "step-induced algebra liftings of right adjoints preserve corecursiveness". Now we give the complete construction for semantics of a coalgebra.
Theorem 5. Suppose that L has a final coalgebra ζ : Ψ ∼ = → L(Ψ ). Then for every H-coalgebra (X, c) there is a unique coalgebra-to-algebra map c † as on the left below: The map c † on the left can alternatively be characterized via its adjoint transpose c † on the right, which is the unique coalgebra-to-algebra morphism. The latter can also be seen as the unique map to the final coalgebra Ψ ∼ = → L(Ψ ).
Note that Theorem 5 generalises final coalgebra semantics: taking in (1) F = G = Id C and H = L, the map c † in the above theorem is the unique homomorphism to the final coalgebra. In the remainder of this paper we focus on instances where c † captures traces, and we therefore refer to it as the trace semantics map.

Traces via Eilenberg-Moore
We recall the approach to trace semantics developed in [17,29,4], putting it in the framework of the previous section. The approach deals with coalgebras for the composite functor BT , where T is a monad that captures the 'branching' aspect. The following assumptions are required.
1. An endofunctor B : C → C with a final coalgebra ζ : Θ ∼ = → B(Θ). 2. A monad (T, η T , µ T ), with the standard adjunction F U between categories C EM(T ), where U is 'forget' and F is for 'free algebras'. 3. A lifting B of B, as in (2), or, equivalently, an EM-law κ : T B ⇒ BT . Example 6. To briefly illustrate these ingredients, we consider non-deterministic automata. These are BT -coalgebras with B : Sets → Sets, B(X) = 2 × X A with 2 = {⊥, } and T the finite powerset monad. The functor B has a final coalgebra carried by the set 2 A * of languages. Further, EM(T ) is the category of join semi-lattices (JSL). The lifting is defined by product in EM(T ), using the JSL on 2 given by the usual ordering ⊥ ≤ . By the end of this section, we revisit this example and obtain the usual language semantics. These assumptions give rise to the following instance of our general setting (1): Actually -and equivalently, by Theorem 2 -the step ρ is most easily given in terms of ρ 4 : BT ⇒ U BF: since B lifts B, we have U BF = BU F = BT , so that ρ 4 is then defined simply as the identity.
The following result is well-known, and is (in a small variation) due to [30].
We apply the step-induced algebra lifting G ρ : Alg(B) → Alg(BT ) to the inverse of this final B-coalgebra, obtaining a BT -algebra: By Theorem 5, this algebra is corecursive, giving us trace semantics of BTcoalgebras. More explicitly, given a coalgebra c : X → BT (X), the trace semantics is the unique map, written as em c , making the following square commute.
The unique map em c in (3) appears in the literature as a 'coiteration up-to' or 'unique solution' theorem [1]. Examples follow later in this section (Theorem 8, Example 9). In [17,29], the above trace semantics of BT -coalgebras arises through 'determinisation', which we explain next. Given a coalgebra c : X → BT (X), one takes its adjoint transpose: It follows from Theorem 2 and our definition of ρ that this transpose coincides with the application of the step-induced coalgebra lifting F ρ : CoAlg(BT ) → CoAlg(B) from the previous section, i.e., F ρ (X, c) = (F(X), c). The functor F ρ thus plays the role of determinisation, see [17]. By Theorem 5, the trace semantics em c can equivalently be characterised in terms of F ρ , as the unique map em c making (4) commute. This is how the trace semantics via Eilenberg-Moore is presented in [17,29]: as the transpose em c = em c • η T X . We conclude this section by recalling a canonical construction of a distributive law [15] for a class of 'automata-like' examples.

Theorem 8.
Let Ω be a set, T a monad on Sets and t : T (Ω) → Ω an EMalgebra. Let B : Sets → Sets, B(X) = Ω × X A , and κ : T B ⇒ BT given by Then κ is an EM-law. Moreover, the final B-coalgebra (Ω A * , ζ) together with Example 9. By Theorem 8, we obtain an explicit description of the trace semantics arising from the corecursive algebra (3): for any o, f : We instantiate the trace semantics em for various choices of Ω, T and t. Given independently of these choices. The table below lists the inductive case em(x)(aw) respectively for non-deterministic automata (NDA) where branching is interpreted as usual (NDA-∃), NDA where branching is interpreted conjunctively (NDA-∀) and (reactive) probabilistic automata (PA). Here P f is the finite powerset functor, and D fin the finitely supported distribution functor.
For other examples, and a concrete presentation of the associated determinisation constructions, see [17,29].

Traces via Logic
This section illustrates how the 'logical' approach to trace semantics of [21], started in [27], fits in our general framework. In essence, traces are built up from logical formulas, also called tests, which are evaluated for states. These tests are obtained via an initial algebra of a functor L. The approach works both for T B and BT -coalgebras (and could, in principle, be extended to more general combinations). We start by listing our assumptions in this section.
1. An adjunction F G between categories C D op . 2. A functor T on C with a step τ : T G ⇒ G. 3. A functor B : C → C and a functor L : D → D with a step δ : BG ⇒ GL.
4. An initial algebra α : We deviate from the convention of writing ρ for 'step', since the above map τ gives rise to multiple steps δ τ and δ τ in (6) below, in the sense of Definition 2; here we use 'delta' instead of 'rho' notation since it is common in modal logic.
Example 10. We take C = D = Sets, and F, G both the contravariant powerset functor 2 − . Non-deterministic automata are obtained either as BT -coalgebras with B(X) = 2 × X A and T the finite powerset functor; or as T B-coalgebras, with B(X) = A × X + 1 and T again the finite powerset functor. In both cases, L is given by , and intuitively models the existential choice in the semantics of non-deterministic automata. The map ρ and the language semantics are defined later in this section.
The assumptions are close to the general step-and-adjunction setting (1). Here, we have an opposite category on the right, and instantiate H to T B or BT : Notice that our assumptions already include a step δ (involving B, L) and a step τ , which we can compose to obtain steps for the T B respectively BT case: Both δ τ and δ τ are steps, and hence give rise to step-induced algebra liftings G δτ and G δ τ of G (Section 2). By Theorem 5, we obtain two corecursive algebras by applying these liftings to the inverse of the initial algebra, i.e., the (inverse of the) final coalgebra in D op : These corecursive algebras define trace semantics for any T B-coalgebra (X, c) and BT -coalgebra (Y, d): It is instructive to characterise this trace semantics in terms of the transpose and the step-induced coalgebra liftings F δτ and F δ τ , showing how they arise as unique maps from an initial algebra: In the remainder of this section, we show two classes of examples of the logical trace semantics. With these descriptions we retrieve most of the examples from [21] in a smooth manner.

Proposition 11.
Let Ω be a set, T : Sets → Sets a functor and t : T (Ω) → Ω a map. Then the set of languages Ω A * carries a corecursive algebra for the functor Ω × T (−) A . Given a coalgebra o, f : X → Ω × T (X) A , the unique coalgebrato-algebra morphism log : for all x ∈ X, a ∈ A and w ∈ A * .
Proof. We instantiate the assumptions in the beginning of this section by C = D = Sets, F = G = Ω − , B(X) = Ω × X A , L(X) = A × X + 1 and T the functor from the statement. The initial L-algebra is α : The map t extends to a modality τ : T G ⇒ G, given on components by The logic δ : BG ⇒ GL is given by the isomorphism Ω × (Ω − ) A ∼ = Ω (A×−)+1 . Instantiating (7) we obtain the corecursive BT -algebra The concrete description of log follows by spelling out the coalgebra-to-algebra diagram that characterises it.
Example 12. We instantiate the trace semantics log from Proposition 11 for various choices of Ω, T and t. Similar to the instances in Example 9, we consider a coalgebra o, f : X → Ω × T (X) A , and we always have log(x)(ε) = o(x).
The cases of non-deterministic automata (NDA-∃, NDA-∀) and probabilistic automata (PA) are the same as in Example 9. However, in constrast to the Eilenberg-Moore approach and other approaches to trace semantics, a monad structure on T is not required here. This is convenient as it also allows to treat alternating automata (AA), where T = P f P f ; it is unclear whether T carries a suitable monad structure in that case.
y∈T log(y)(w) We also describe a logic for polynomial functors constructed from a signature. Here, we model a signature by a functor Σ : N → Sets, where N is the discrete category of natural numbers. This gives rise to a functor H Σ : Sets → Sets as usual by H Σ (X) = n∈N Σ(n)×X n . We abuse notation and write σ(x 1 , . . . , x n ) instead of (σ, x 1 , . . . x n ). The initial algebra of H Σ consists of closed terms (or finite node-labelled trees) over the signature.

Proposition 13.
Let Ω be a meet semi-lattice with top element as well as a bottom element ⊥, let T : Sets → Sets be a functor, and t : T (Ω) → Ω a map. Let Φ be the initial H Σ -algebra. The set Ω Φ of 'tree' languages carries a corecursive algebra for the functor T H Σ . Given a coalgebra c : X → T H Σ (X), the unique coalgebra-to-algebra map log : X → Ω Φ is given by for all x ∈ X and σ(t 1 , . . . , t n ) ∈ Φ.
Proof. We use C = D = Sets, F = G = Ω − , B = L = H Σ . The map t extends to a modality τ : T G ⇒ G as in the proof of Proposition 11. The logic δ : The corecursive algebra log is then given by: The explicit characterisation of log is a straightforward computation.
for every state x ∈ X and tree σ(t 1 , . . . , t n ). This is the standard semantics of tree automata. It is easily adapted to weighted tree automata, see [21].
In both Example 14 and Example 12, the step-induced coalgebra lifting F δ τ (respectively F δτ ) of the underlying logic corresponds to reverse determinisation, see [21,28] for details. In particular, in Example 14 it maps a top-down tree automaton to the corresponding bottom-up tree automaton.

Traces via Kleisli
In this section we briefly recall the 'Kleisli approach' to trace semantics [12], and cast it in our abstract framework. It applies to coalgebras for a composite functor T B, where T is a monad modelling the type of branching. For example, a coalgebra X → P(A × X + S) has an associated map X → P(A * × S) that sends a state x ∈ X to the set of its complete traces. (Taking S = 1, this is the usual language semantics of a nondeterministic automaton.) To fit this to our framework, the monad T is P and the functor B is (A × −) + S. In general, the following assumptions are required.
1. An endofunctor B : C → C with an initial algebra β : In the case that B is the functor (A × −) + S, its initial algebra is carried by A * × S, and the canonical K -law is given at X by [T inl • st A,X , T inr • η T S ] : A × T X + S → T (A × X + S) A central observation for the Kleisli approach to traces is that the fourth assumption holds under certain order enrichment requirements on K (T ), see [12]. In particular, these hold when T is the powerset monad, the (discrete) subdistribution monad or the lift monad.
The above assumptions give rise to the following instance of our setting (1): Similar to the EM-case in Section 3, the map of adjunctions is most easily given in terms of ρ 4 : T B ⇒ U BJ as the identity, using that B extends B.
We apply the step-induced algebra lift G ρ : Alg(B) → Alg(T B) to the inverse of the final B-coalgebra, and call it kl : By Theorem 5, this algebra is corecursive, i.e., for every coalgebra c : X → T B(X), there is a unique map kl c as below: The trace semantics is exactly as in [12], to which we refer for examples.

Comparison
The presentation of trace semantics in terms of corecursive algebras allows us compare the different approaches by constructing algebra morphisms between them. In this section, we compare the Eilenberg-Moore against the logical approach, and the Kleisli against the logical approach as well. For a comparison between Kleisli and Eilenberg-Moore we refer to [17]. The latter is not in terms of corecursive algebras; we leave such a reformulation for future work. In [21], logical traces are also compared to determinisation constructions. But the technique is different, with the primary difference that no corecursive algebras are used there.

Eilenberg-Moore and Logic
To compare the Eilenberg-Moore approach to the logical approach, we combine their assumptions. This amounts to an adjunction F G, endofunctors B, L and a monad T as follows: The map τ is an assumption of the logical approach, but the compatibility with the monad structure was not assumed before (in the logical approach, T is not assumed to be a monad). We note that τ being a monad action is the same thing as τ being an EM-law (involving the monad T on the left and the identity monad on the right). Therefore, by Theorem 2: Such monad actions and the corresponding liftings are used, e.g., in [13,16,11] where F is called Pred. We turn back to the comparison between the Eilenberg-Moore and logical approach. First, observe that since δ : BG ⇒ GL is a step, it induces a corecursive B-algebra BG(Φ) Hence, we obtain a unique map e as in the following diagram: This is a map from the carrier of the corecursive algebra em (from the Eilenberg-Moore approach) to the carrier of the corecursive algebra log (from the logical approach). Note that, by the above diagram, it is a B-algebra morphism, whereas em and log are BT -algebras. The following is a sufficient condition under which the map e is a BT -algebra morphism from em to log , which implies that the logical trace semantics factors through the Eilenberg-Moore trace semantics (Theorem 17).
Lemma 16. The distributive law κ commutes with the logics in (6), as in: iff there is a natural transformation : B G ⇒ GL such that U ( ) = δ -where the functor G : D op → EM(T ) is the lifting corresponding to τ (Lemma 15).
Proof. The existence of such a amounts to the property that each component δ X : BG(X) → GL(X) is a T -algebra homomorphism from B G(X) to GL(X), i.e., the following diagram commutes: This corresponds exactly to (12).
Theorem 17. If the equivalent conditions in Lemma 16 hold, then the map e defined in (11) is an algebra morphism from em to log , as on the left below.
In that case, for any coalgebra X c → BT (X) the triangle on the right commutes.
The rectangle on the right commutes by definition of e. For the square on the left, it suffices to show e • a = τ 1 • T (e); this is equivalent to F (a) • e = τ 2 • e in: Indeed, by transposing we have on the one hand: And on the other hand, using that τ 2 = F (τ 1 • T (η)) • , By transposing the maps in (11), it follows that e : Φ → F (Θ) is the unique morphism from the initial L-algebra to F (ζ) • δ 2 : LF (Θ) → F (Θ). Hence, for the desired equality F (a) • e = τ 2 • e, it suffices to prove that F (a) and τ 2 are both algebra homomorphisms from F (ζ)•δ 2 to a common algebra, which in turn follows from commutativity of the following diagram.
For the second part of the theorem, let c : X → BT (X) be a coalgebra. Since e is an algebra morphism, the equation e • em c = log c follows by uniqueness of morphisms from c to the corecursive algebra on G(Φ).
The equality e • em c = log c means that equivalence wrt Eilenberg-Moore trace semantics implies equivalence wrt the logical trace semantics. The converse is, of course, true if e is monic. For that, it is sufficient if δ : BG ⇒ GL is expressive. Here expressiveness is the property that for any B-coalgebra, the unique coalgebra-to-algebra morphism to the corecursive algebra on G(Φ) factors as a B-coalgebra homomorphism followed by a mono. This holds in particular if the components δ A : BG(A) → GL(A) are all monic (in C) [20].
Lemma 18. If δ : BG ⇒ GL is expressive, then e is monic. Moreover, if δ is an isomorphism, then e is an iso as well.
Proof. Expressivity of δ means that we have e = m • h for some coalgebra homomorphism h and mono m. By finality of ζ there is a B-coalgebra morphism h such that h • h = id. It follows that h is monic (in C), so that m • h = e is monic too. For the second claim, if δ is an isomorphism, then G(α −1 ) • δ : BG(Φ) → G(Φ) is an invertible corecursive B-algebra, which implies it is a final coalgebra (see [5,Proposition 7], which states the dual). It then follows from (11) that e is a coalgebra morphism from one final B-coalgebra to another, which means it is an isomorphism.
Previously, we have seen both a class of examples of the Eilenberg-Moore approach (Theorem 8), and the logical approach (Proposition 11). Both arise from the same data: a monad T (just a functor in the logical approach) and an EM-algebra t. We thus obtain, for these automata-like examples, both a logical trace semantics and a matching 'Eilenberg-Moore' semantics, where the latter essentially amounts to a determinisation procedure. The underlying distributive laws satisfy (12) by construction, so that the two approaches coincide (as already seen in the concrete examples).

Theorem 19.
Let Ω be a set, T : Sets → Sets a monad and t : T (Ω) → Ω an EM-algebra. The EM-law κ of Theorem 8, together with δ, τ as defined in the proof of Proposition 11, satisfies (12). For any coalgebra c : X → Ω × T (X) A , the map log c coincides (up to isomorphism) with the map em c .
Proof. To prove (12), i.e., δ τ • κ = δ τ , we first compute, following (6), Hence, we need to show that for every set X. To this end, let S ∈ T (Ω × (Ω X ) A ) and t ∈ (A × X + 1). We first spell out the right-hand side: In the last step, we used the definition of δ: For the left-hand side of (13), distinguish cases * ∈ 1 and (a, x) ∈ A × X.
which matches the right-hand side of (13). For (a, x) ∈ A × X, we have: which also matches the right-hand side, hence we obtain (13) as desired.
Since (12) is satisfied, it follows from Theorem 17 that e • em c = log c . Since δ is an iso, e is an iso as well by Lemma 18.

Kleisli and Logic
To compare the Kleisli approach to the logical approach, we combine their assumptions. This amounts to an adjunction F G, endofunctors B, L and a monad T as follows: together with: 1. An initial algebra β : B(Ψ ) Again, we assume τ to be compatible with the monad, satisfying the equivalent conditions in Lemma 15. Since δ is a step, we obtain the following unique coalgebra-to-algebra morphism k from the initial B-algebra: Since τ is a monad action, for every X, G(X) carries an Eilenberg-Moore algebra τ X . Thus we can take the adjoint transpose k = τ Φ • T (k) : T (Ψ ) → G(Φ). We have the following analogue of Theorem 17.
Lemma 20. The distributive law λ commutes with the logics in (6), as in: T BG δτ w w GL (15) iff there is a natural transformation : L F ⇒ F B given by J = δ -where the functor F : K (T ) → D op is the extension corresponding to τ (Lemma 15).
Proof. The condition J = δ simply means that X = δ X for every object X in C. Naturality of amounts to commutativity of the outside of the diagram below, for every map f : The lower rectangle commutes by naturality, the upper is equivalent to (15). Hence, (15) implies naturality. Conversely, if is natural, then the upper rectangle commutes for each Y by taking f = id T Y (the identity map in C).
In that case, for any coalgebra c : X → T B(X) there is a commuting triangle as on the right above.
Proof. Consider the following diagram.
Everything commutes: the upper right rectangle by assumption (15), the rightmost square in the middle row since τ is an action, the outer shapes by definition of kl and log , the lower left rectangle by (14) and the rest by naturality.
The above result gives a sufficient condition under which 'Kleisli' trace equivalence implies logical trace equivalence. However, contrary to the case of traces in Eilenberg-Moore, in Lemma 18, we currently do not have a converse. If δ has monic components, then it is easy to use corecursiveness to define a map from log to kl , but this surprisingly is not sufficient to show k to be monic, as confirmed by Example 22 below. In the comparison between Eilenberg-Moore and Kleisli traces [17], a similar difficulty arises: it is unclear under what conditions the map from the final coalgebra in Kleisli to the final coalgebra in Eilenberg-Moore obtained there is mono (and hence, if Eilenberg-Moore trace equivalence implies Kleisli trace equivalence).
Let λ : BT ⇒ T B be the distributive law from [12], given by λ X (a, S) = {(a, x) | x ∈ S} and λ( * ) = { * }. Then (15) is satisfied: It is straightforward to check that this commutes. However, given a coalgebra f : X → T B(X), the induced logical semantics log : X → 2 A * is: log(x)(w) = iff * ∈ f (x) or ∃a ∈ A, v ∈ A * , y ∈ X.w = av ∧ (a, y) ∈ f (x) ∧ log(y)(v) = . In particular, this means that if * ∈ f (x) and * ∈ f (y) for some states x, y, then they are trace equivalent. This differs from the Kleisli semantics, which amounts to the usual language semantics of non-deterministic automata [12].
Cîrstea [8] compares logical traces to a 'path-based semantics', which resembles the Kleisli approach (as well as [22]) but does not require a final B-coalgebra. In particular, given a commutative monad T on Sets and a signature Σ, she considers a canonical distributive law λ : H Σ T ⇒ T H Σ , which coincides with the one in [12]. Cîrstea shows that, with Ω = T (1), t = µ 1 : T T (1) → T (1) and δ from the proof of Proposition 13 (assuming T 1 to have enough structure to define that logic), the triangle (15) commutes (see [8,Lemma 5.12]).

Completely Iterative Algebras
In this paper, we constructed several corecursive algebras. We briefly show that they all satisfy the following stronger property [26].
Definition 23. For an endofunctor H on C, an H-algebra a : HA → A is completely iterative when [id, a] is a corecursive A + H-coalgebra. Explicitly: when for every c : X → A + HX there is a unique f : X → A such that the following diagram commutes.
Following [14,26], we have two ways of constructing such algebras.
1. If ζ : A → HA is a final H-coalgebra, then (A, ζ −1 ) is completely iterative. 2. Given a step as in Section 2, the functor G ρ preserves complete iterativity.
We may thus say: "step-induced algebra liftings of right adjoints preserve complete iterativity". Consequently, by analogy with Theorem 5, if L has a final coalgebra (Ψ, ζ) then G ρ (A, ζ −1 ) is completely iterative. For our examples, this may be seen as a trace semantics for a coalgebra c that may sometimes stop following the behaviour functor and instead provide semantics directly.

Future work
The main contribution of this paper is a general treatment of trace semantics via corecursive algebras, constructed through an adjunction and a step, covering the 'Eilenberg-Moore', 'Kleisli' and 'logic' approaches to trace semantics. It is expected that our framework also works for other examples, such as the 'quasi-liftings' in [2], but this is left for future work. In [19], several examples of adjunctions are discussed in the context of automata theory, some of them the same as the adjunctions here, but with the aim of lifting them to categories of coalgebras, under the condition that what we call the step is an iso. In our case, it usually is not an iso, since the behaviour functor is a composite T B or BT ; however, it remains interesting to study cases in which such adjunction liftings appear, as used for instance in the aforementioned paper and [28,21]. Further, our treatment in Section 3 (Eilenberg-Moore) assumes a monad to construct the corecursive algebra, but it was shown by Bartels [1] that this algebra is also corecursive when the underlying category has countable coproducts (and dropping the monad assumption). We currently do not know whether this fits our abstract approach. Finally, the Eilenberg-Moore/logic and Kleisli/logic comparisons (Section 6) seem to share certain aspects (the conditions look very similar), but so far we have been unable to derive a general perspective on such comparisons that covers both, and possibly also the Eilenberg-Moore/Kleisli comparison of [17].