# Difference between revisions of "Coalgebra"

## Idea

Many systems can be described by having some kind of state space and a map that assigns to each state the result of observations that can be made on that state and possible next states that are reachable from that state. From an abstract perspective, the structure of the states are described by a category C and the possible observations are specified by an endofunctor on this category. A coalgebra is then a morphism for some carrier X, the state space.

Let us take a look at some examples before we dive into formal definitions and results.

1. Deterministic Automata. The typical, first year example one learns about in Computer Science are deterministic automata over a finite alphabet . These are given by a set of states , a set of final states and a map that assigns to a state and an input symbol the next state. We can combine this data into a single map by putting with and .
2. Non-deterministic automata. These are an extension of deterministic automata where we allow a state to have a set of successors, they are maps of the type .
3. Differential Equations. A more mathematical example are (ordinary) differential equations, these assign to each point in space a time dependent vector field, i.e., they are given on vector spaces by maps of the form where is the tangent space and are the real numbers.

Note that in all these cases we have completely ignored initial states or initial conditions. These are not part of coalgebras, every element of the state space can be initial.

## Definition

<definition id="coalg"> Let C be a category and an endofunctor on C. An F-coalgebra is a morphism in C, and a homomorphism from a coalgebra to is a morphism such that

commutes. </definition> Sometimes it is clearer to denote a coalgebra not just by c but instead by to clearly indicate the carrier of c.

Straight from the definition, we can prove the following. <theorem id="coalg-cat">

 -Coalgebras and their homomorphisms form a category .


</theorem>

## Final Coalgebras

One can think of a coalgebra as the operational semantics of a system. To get the denotational semantics of such a coalgebra, we need a semantic domain where we can interpret it. This is provided by a final (F-)coalgebra, if it exists. <definition id="final-coalg">

 A final object in the category  is called a final (F)-coalgebra.


</definition> Concretely, this means that there is a coalgebra such that for every coalgebra there is a unique homomorphism . This map is sometimes called the corecursion of h or, similarly to linear extensions, the coinductive extension of h. The notation for h is not fixed though. In the context of programming or Type Theory, the notation is used, whereas category theorists prefer shorter notation like . The latter is the one we use throughout this article.

A classical result for final coalgebras, due to Lambek, is that they are fixed point of a functor. <theorem id="lambek-coalg">

 If  is a final coalgebra, then  is an isomorphism.


</theorem> This justifies the notation , which is sometimes used to denote a (chosen) final coalgebra for F.

TODO:

• Non-examples: powerset functor
• Construction via final chain

## Behavioural Equivalence

Final coalgebras allow us to compare the behaviour of states. For example, let F be a functor on and a function. We say that two states are behaviourally equivalent, if . This can be generalised in case F does not admit a final coalgebra. <definition id="behavioural-equivalence">

 Let  and  be coalgebras. If there is a cospan  in , then we say that c and d are behaviourally equivalent.


</definition>

TODO:

• Compare to bisimilary and other notions. See