---
abstract: 'In this paper, we present a systematic way of deriving (1) languages of (generalised) regular expressions, and (2) sound and complete axiomatizations thereof, for a wide variety of systems. This generalizes both the results of Kleene (on regular languages and deterministic finite automata) and Milner (on regular behaviours and finite labelled transition systems), and includes many other systems such as Mealy and Moore machines.'
address:
- '[a]{}CWI, Amsterdam, The Netherlands'
- '[b]{}LIACS, University of Leiden,The Netherlands'
- '[c]{}CWI (Amsterdam), VUA (Amsterdam) and RUN (Nijmegen) , The Netherlands'
author:
- Alexandra Silvaa
- Marcello Bonsangueb
- Jan Ruttenc
bibliography:
- 'refs.bib'
title: 'Non-deterministic Kleene coalgebras'
---

[^1]

Introduction
============

In a previous paper [@BRS08], we presented a language to describe the behaviour of Mealy machines and a sound and complete axiomatization thereof. The defined language and axiomatization can be seen as the analogue of classical regular expressions [@kleene] and Kleene algebra [@kozen], for deterministic finite automata (DFA), or the process algebra and axiomatization for labelled transition systems (LTS) [@milner].

We now extend the previous approach and devise a framework wherein languages and axiomatizations can be uniformly derived for a large class of systems, including DFA, LTS and Mealy machines, which we will model as coalgebras.

Coalgebras provide a general framework for the study of dynamical systems such as DFA, Mealy machines and LTS. For a functor ${\mathcal{G}}\colon  \mathbf{Set}
\to \mathbf{Set}$, a ${\mathcal{G}}$-coalgebra or ${\mathcal{G}}$-system is a pair $(S,g)$, consisting of a set $S$ of states and a function $g\colon S\to {\mathcal{G}}(S)$ defining the “transitions” of the states. We call the functor ${\mathcal{G}}$ the *type* of the system. For instance, DFA can be modelled as coalgebras of the functor ${\mathcal{G}}(S) = 2 \times
S^A$, Mealy machines are obtained by taking ${\mathcal{G}}(S) = (B\times S)^A$ and image-finite LTS are coalgebras for the functor ${\mathcal{G}}(S) = (\pow
(S))^A$, where $\pow$ is finite powerset.

Under mild conditions, functors ${\mathcal{G}}$ have a *final coalgebra* (unique up to isomorphism) into which every ${\mathcal{G}}$-coalgebra can be mapped via a unique so-called ${\mathcal{G}}$*homomorphism*. The final coalgebra can be viewed as the universe of all possible ${\mathcal{G}}$-*behaviours*: the unique homomorphism into the final coalgebra maps every state of a coalgebra to a canonical representative of its behaviour. This provides a general notion of behavioural equivalence: two states are equivalent if and only if they are mapped to the same element of the final coalgebra. Instantiating the notion of final coalgebra for the aforementioned examples, the result is as expected: for DFA the final coalgebra is the set $2^{A^*}$ of all languages over $A$; for Mealy machines it is the set of causal functions $f\colon A^\omega\to B^\omega$; and for LTS it is the set of finitely branching trees with arcs labelled by $a\in A$ modulo bisimilarity. The notion of equivalence also specializes to the familiar notions: for DFA, two states are equivalent when they accept the same language; for Mealy machines, if they realize (or compute) the same causal function; and for LTS if they are bisimilar.

It is the main aim of this paper to show how the type of a system, given by the functor ${\mathcal{G}}$, is not only enough to determine a notion of behaviour and behavioural equivalence, but also allows for a uniform derivation of both a set of expressions describing behaviour and a corresponding axiomatization. The theory of universal coalgebra [@Rutten00] provides a standard equivalence and a universal domain of behaviours, uniquely based on the functor ${\mathcal{G}}$. The main contributions of this paper are (1) the definition of a set of expressions ${\mathsf{Exp}}_{\mathcal{G}}$ describing ${\mathcal{G}}$-behaviours, (2) the proof of the correspondence between behaviours described by ${\mathsf{Exp}}_{\mathcal{G}}$ and locally finite ${\mathcal{G}}$-coalgebras (this is the analogue of Kleene’s theorem), and (3) a corresponding sound and complete axiomatization, with respect to bisimulation, of ${\mathsf{Exp}}_{\mathcal{G}}$ (this is the analogue of Kleene algebra). All these results are solely based on the type of the system, given by the functor ${\mathcal{G}}$.

In a nutshell, we combine the work of Kleene with coalgebra, considering the class of non-deterministic functors. Hence, the title of the paper: non-deterministic Kleene coalgebras.

#### **Organization of the paper.**

In Section \[sec:ndc\] we introduce the class of nondeterministic functors and coalgebras. In Section \[sec:expressions\] we associate with each nondeterministic functor ${\mathcal{G}}$ a generalized language ${\mathsf{Exp}}_{\mathcal{G}}$ of regular expressions and we present an analogue of Kleene’s theorem, which makes precise the connection between ${\mathsf{Exp}}_{\mathcal{G}}$ and ${\mathcal{G}}$-coalgebras. A sound and complete axiomatization of ${\mathsf{Exp}}_{\mathcal{G}}$ is presented in Section \[sec:axiom\]. Section \[sec:appl\] contains two more examples of application of the framework and Section \[sec:pol\_fin\] shows a language and axiomatization for the class of polynomial and finitary coalgebras. Section \[sec:conclusions5\] presents concluding remarks, directions for future work and discusses related work. This paper is an extended version of [@regexp; @BRS09b]: it includes all the proofs, more examples and explanations, new material about polynomial and finitary functors and an extended discussion section.

Preliminaries {#sec:ndc}
=============

We give the basic definitions on non-deterministic functors and coalgebras and introduce the notion of bisimulation.

First we fix notation on sets and operations on them. Let $\mathbf{Set}$ be the category of sets and functions. Sets are denoted by capital letters $X,Y,\ldots$ and functions by lower case $f,g,\ldots$. We write $\emptyset$ for the empty set and the collection of all [*finite*]{} subsets of a set $X$ is defined as $\pow(X) = \{Y\subseteq X\mid \mbox{\textrm{$Y$ finite}}\}$. The collection of functions from a set $X$ to a set $Y$ is denoted by $Y^X$. We write $\mathit{id}_X$ for the identity function on set $X$. Given functions $f\;:\; X\to Y$ and $g\;:\;Y\to Z$ we write their composition as $g\circ f$. The product of two sets $X,Y$ is written as $X\times Y$, with projection functions $\xymatrix{X&X\times
Y\ar[l]_-{\pi_1}\ar[r]^-{\pi_2}&Y}.
$ The set $1$ is a singleton set typically written as $1=\{ * \}$ and it can be regarded as the empty product. We define $X{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}Y$ as the set $X\uplus Y \uplus \{\bot,\top\}$, where $\uplus$ is the disjoint union of sets, with injections $\xymatrix{X\ar[r]^-{\kappa_1}&X
\uplus
Y &Y\ar[l]_-{\kappa_2}}$. Note that the set $X{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}Y$ is different from the classical coproduct of X and Y (which we shall denote by $X+Y$), because of the two extra elements $\bot$ and $\top$. These extra elements will later be used to represent, respectively, underspecification and inconsistency in the specification of some systems. The intuition behind the need of these extra elements will become clear when we present our language of expressions and concrete examples, in Section \[sec:examples\_synt\], of systems whose type involves ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$. Note that $X {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}X
\not\cong 2\times X \cong X+ X$.

For each of the operations defined above on sets, there are analogous ones on functions. Let $f\colon X\to Y$, $f_1\colon X\to Y$ and $f_2\colon Z\to W$. We define the following operations: $$\begin{array}{l@{\hspace{2.3cm}}l}
f_1\times f_2 \colon X\times Z \to Y\times W & f_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}f_2 \colon X{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}Z \to Y{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}W\\[.6ex]
(f_1\times f_2)(<x,z>) = <f_1(x),f_2(z)> &
(f_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}f_2)(c) = c,\ c\in\{\bot,\top\}\\ &
(f_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}f_2)(\kappa_i(x)) = \kappa_i(f_i(x)),\ i\in\{1,2\}\\[2.4ex]
f^A \colon X^A \to Y^A & \pow(f) \colon \pow (X) \to \pow (Y)\\[.6ex]

f^A (g) = f\circ g & \pow(f)(S) = \{f(x) \mid x\in S\}
\end{array}$$ Note that here we are using the same symbols that we defined above for the operations on sets. It will always be clear from the context which operation is being used.

In our definition of non-deterministic functors we will use constant sets equipped with an information order. In particular, we will use joinsemilattices. A (bounded) joinsemilattice is a set ${\mathsf{B}}$ equipped with a binary operation $\vee_{\mathsf{B}}$ and a constant $\bot_{\mathsf{B}}\in {\mathsf{B}}$, such that $\vee_{\mathsf{B}}$ is commutative, associative and idempotent. The element $\bot_{\mathsf{B}}$ is neutral with respect to $\vee_{\mathsf{B}}$. As usual, $\vee_{\mathsf{B}}$ gives rise to a partial ordering $\leq_{\mathsf{B}}$ on the elements of ${\mathsf{B}}$: $$b_1 \leq_{\mathsf{B}}b_2 \Leftrightarrow b_1\vee_{\mathsf{B}}b_2 = b_2$$ Every set $S$ can be mapped into a joinsemilattice by taking ${\mathsf{B}}$ to be the set of all finite subsets of $S$ with union as join.

#### **Non-deterministic functors.**

Non-deterministic functors are functors ${\mathcal{G}}\colon\textbf{Set} \to \textbf{Set}$, built inductively from the identity and constants, using $\times$, ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$, $(-)^A$ and $\pow$.

\[def:polfunctor\] The class ${\mathit{NDF}}$ of [*nondeterministic functors*]{} on $\mathbf{Set}$ is inductively defined by putting: $${\mathit{NDF}}\ni {\mathcal{G}}::= {\mathsf{Id}}\mid {\mathsf{B}}\mid {\mathcal{G}}{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{G}}\mid {\mathcal{G}}\times
{\mathcal{G}}\mid {\mathcal{G}}^A \mid \pow {\mathcal{G}}$$ where ${\mathsf{B}}$ is a finite (non-empty) joinsemilattice and $A$ is a finite set.

Since we only consider finite exponents $A = \{a_1,\ldots,a_n\}$, the functor $(-)^A$ is not really needed, since it is subsumed by a product with $n$ components. However, to simplify the presentation, we decided to include it.

Next, we show the explicit definition of the functors above on a set $X$ and on a morphism $f\colon X\to Y$ (note that ${\mathcal{G}}(f) \colon {\mathcal{G}}(X) \to
{\mathcal{G}}(Y)$). $$\begin{array}{lll}
{\mathsf{Id}}(X) = X & {\mathsf{B}}(X) = {\mathsf{B}}& ({\mathcal{G}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{G}}_2) (X) = {\mathcal{G}}_1(X){\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{G}}_2(X) \\
{\mathsf{Id}}(f) = f &  {\mathsf{B}}(f) = \mathit{id}_{\mathsf{B}}& ({\mathcal{G}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{G}}_2) (f) = {\mathcal{G}}_1(f)
{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{G}}_2 (f) \\[1ex]
 ({\mathcal{G}}^A)(X) = {\mathcal{G}}(X)^A & (\pow
{\mathcal{G}})(X)
= \pow ({\mathcal{G}}(X)) & ({\mathcal{G}}_1\times {\mathcal{G}}_2) (X) = {\mathcal{G}}_1(X) \times {\mathcal{G}}_2(X) \\
 ({\mathcal{G}}^A)(f) = {\mathcal{G}}(f)^A & 
(\pow {\mathcal{G}})(f) = \pow ({\mathcal{G}}(f)) & ({\mathcal{G}}_1\times {\mathcal{G}}_2) (f) = {\mathcal{G}}_1(f) \times
{\mathcal{G}}_2(f)
\\
\end{array}$$ Typical examples of nondeterministic functors include ${\mathcal{M}}=
({\mathsf{B}}\times {\mathsf{Id}})^A$, ${\mathcal{D}}= 2 \times {\mathsf{Id}}^A$, ${\mathcal{Q}}= (1 {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathsf{Id}})^A$ and ${\mathcal{N}}= 2
\times (\pow{\mathsf{Id}})^A $, where $2 = \{0,1\}$ is a two-element join semilattice with $0$ as bottom element ($1\vee 0 = 1$) and $1=\{*\}$ is a one element join-semilattice. These functors represent, respectively, the type of Mealy, deterministic, partial deterministic and nondeterministic automata. In this paper, we will use the last three as running examples. In [@BRS08], we have studied in detail regular expressions for Mealy automata. Similarly to what happened there, we impose a joinsemilattice structure on the constant functor. The product, exponentiation and powerset functors preserve the joinsemilattice structure and thus do not need to be changed. This is not the case for the classical coproduct and thus we use ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$ instead, which also guarantees that the join semilattice structure is preserved.

Next, we give the definition of the ingredient relation, which relates a nondeterministic functor ${\mathcal{G}}$ with its [*ingredients*]{}, [*i.e.*]{} the functors used in its inductive construction. We shall use this relation later for typing our expressions.

Let $\lhd\subseteq {\mathit{NDF}}\times {\mathit{NDF}}$ be the least reflexive and transitive relation on nondeterministic functors such that $${\mathcal{G}}_1\triangleleft {\mathcal{G}}_1\times {\mathcal{G}}_2,\ \ \ {\mathcal{G}}_2\lhd {\mathcal{G}}_1\times {\mathcal{G}}_2,\ \ \ {\mathcal{G}}_1\lhd {\mathcal{G}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{G}}_2,\ \ \ {\mathcal{G}}_2\lhd {\mathcal{G}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{G}}_2,\ \ \ {\mathcal{G}}\lhd {\mathcal{G}}^A,\ \ \ {\mathcal{G}}\lhd \pow {\mathcal{G}}$$

Here and throughout this document we use ${\mathcal{F}}\lhd {\mathcal{G}}$ as a shorthand for $<{\mathcal{F}},{\mathcal{G}}>\in \lhd$. If ${\mathcal{F}}\lhd {\mathcal{G}}$, then ${\mathcal{F}}$ is said to be an *ingredient* of ${\mathcal{G}}$. For example, $2$, ${\mathsf{Id}}$, ${\mathsf{Id}}^A$ and ${\mathcal{D}}$ itself are all the ingredients of the deterministic automata functor ${\mathcal{D}}=2\times{\mathsf{Id}}^A$.

#### **Non-deterministic coalgebras.**

A [nondeterministic]{} coalgebra is a pair $(S, f\colon S\to {\mathcal{G}}(S))$, where $S$ is a set of states and ${\mathcal{G}}$ is a nondeterministic functor. The functor ${\mathcal{G}}$, together with the function $f$, determines the [*transition structure*]{} (or dynamics) of the ${\mathcal{G}}$-coalgebra [@Rutten00]. Mealy, deterministic, partial deterministic and nondeterministic automata are, respectively, coalgebras for the functors ${\mathcal{M}}=
({\mathsf{B}}\times {\mathsf{Id}})^A$, ${\mathcal{D}}= 2 \times {\mathsf{Id}}^A$, ${\mathcal{Q}}= (1 {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathsf{Id}})^A$ and ${\mathcal{N}}= 2
\times (\pow{\mathsf{Id}})^A $.

A [*${\mathcal{G}}$-homomorphism*]{} from a ${\mathcal{G}}$-coalgebra $(S,f)$ to a ${\mathcal{G}}$-coalgebra $(T,g)$ is a function $h\colon S \to T$ preserving the transition structure, [*i.e.*]{} such that $g\circ h = {\mathcal{G}}(h) \circ
f$.

A ${\mathcal{G}}$-coalgebra $(\Omega,\omega)$ is said to be [*final*]{} if for any ${\mathcal{G}}$-coalgebra $(S,f)$ there exists a unique ${\mathcal{G}}$-homomorphism $\mathbf{beh}_S\colon S\to \Omega$.

For every non-deterministic functor ${\mathcal{G}}$ there exists a final ${\mathcal{G}}$-coalgebra $(\Omega_{\mathcal{G}},
\omega_{\mathcal{G}})$ [@Rutten00]. For instance, as we already mentioned in the introduction, the final coalgebra for the functor ${\mathcal{D}}$ is the set of languages $2^{A^*}$ over $A$, together with a transition function $d\;:\;2^{A^*} \to 2\times(2^{A^*})^A $ defined as $d(\phi) =
<\phi(\epsilon), \lambda a\lambda w. \phi(aw)>$. Here $\epsilon$ denotes the empty sequence and $aw$ denotes the word resulting from prefixing $w$ with the letter $a$. The notion of finality will play a key role later in providing a semantics to expressions.

Given a ${\mathcal{G}}$-coalgebra $(S,f)$ and a subset $V$ of $S$ with inclusion map $i\colon V\to S$ we say that $V$ is a subcoalgebra of $S$ if there exists $g\colon V\to {\mathcal{G}}(V)$ such that $i$ is a homomorphism. Given $s\in
S$, $<s>=(T,t)$, denotes the smallest subcoalgebra generated by $s$, with $T$ given by $$T = \bigcap \{V \mid V \text{ is a subcoalgebra of $S$ and } s\in V\}$$ If the functor ${\mathcal{F}}$ preserves arbitrary intersections, then the subcoalgebra $<s>$ exists. This will be the case for every functor considered in this paper. Moreover, all the functors we will consider preserve monos and thus the transition structure $t$ is unique [@Rutten00 Proposition 6.1].

We will write $\mathit{Coalg}({\mathcal{G}})$ for the category of ${\mathcal{G}}$-coalgebras together with coalgebra homomorphisms. We also write $\mathit{Coalg}_{\mathbf{LF}}({\mathcal{G}})$ for the category of ${\mathcal{G}}$-coalgebras that are [*locally finite*]{}. Objects are ${\mathcal{G}}$-coalgebras $(S,f)$ such that for each state $s\in S$ the generated subcoalgebra $<s>$ is finite. Maps are the usual homomorphisms of coalgebras.

Let $(S, f)$ and $(T,g)$ be two ${\mathcal{G}}$-coalgebras. We call a relation $R \subseteq S\times T$ a [*bisimulation*]{} [@HermidaJ98] iff $$<s,t>\in R \Rightarrow <f(s), g(t)>\in \overline {\mathcal{G}}(R)$$ where $\overline {\mathcal{G}}(R)$ is defined as $\overline {\mathcal{G}}(R) = \{ <{\mathcal{G}}(\pi_1)(x),{\mathcal{G}}(\pi_2)(x)> \mid x \in {\mathcal{G}}(R) \}
$. We write $s\sim_{\mathcal{G}}t$ whenever there exists a bisimulation relation containing $(s,t)$ and we call $\sim_{\mathcal{G}}$ the bisimilarity relation. We shall drop the subscript ${\mathcal{G}}$ whenever the functor ${\mathcal{G}}$ is clear from the context. For all non-deterministic ${\mathcal{G}}$-coalgebras $(S,f)$ and $(T,g)$ and $s\in
S, t\in T$, it holds that $s\sim t \iff \mathbf{beh}_S(s) =
\mathbf{beh}_T(t)$ (the left to right implication always holds, whereas the right to left implication only holds for certain classes of functors, which include the ones we consider in this paper [@Rutten00; @staton]).

A language of expressions for nondeterministic coalgebras {#sec:expressions}
=========================================================

In this section, we generalize the classical notion of regular expressions to nondeterministic coalgebras. We start by introducing an untyped language of expressions and then we single out the well-typed ones via an appropriate typing system, thereby associating expressions to nondeterministic functors.

Let $A$ be a finite set, ${\mathsf{B}}$ a finite joinsemilattice and $X$ a set of fixed point variables. The set ${\mathsf{Exp}}$ of all [*expressions*]{} is given by the following grammar, where $a\in A$, $b\in {\mathsf{B}}$ and $x\in X$: $$\begin{array}{lcl}
{\varepsilon}&:: =& {\underline\emptyset}\mid x \mid {\varepsilon}\oplus {\varepsilon}\mid \mu x.\gamma
    \mid b \mid l<{\varepsilon}> \mid r<{\varepsilon}> \mid l[{\varepsilon}] \mid r[{\varepsilon}] \mid a({\varepsilon}) \mid
\{{\varepsilon}\}\\
\end{array}$$ where $\gamma$ is a [*guarded expression*]{} given by: $$\begin{array}{lcl}
\gamma &:: =& {\underline\emptyset}\mid \gamma \oplus \gamma \mid \mu
x.\gamma
    \mid b \mid l<{\varepsilon}> \mid r<{\varepsilon}> \mid l[{\varepsilon}] \mid r[{\varepsilon}] \mid a({\varepsilon}) \mid
\{{\varepsilon}\}\\
\end{array}$$ The only difference between the BNF of $\gamma$ and ${\varepsilon}$ is the occurrence of $x$.

In the expression $\mu x.\gamma$, $\mu$ is a binder for all the free occurrences of $x$ in $\gamma$. Variables that are not bound are free. A [*closed expression*]{} is an expression without free occurrences of fixed point variables $x$. We denote the set of closed expressions by ${\mathsf{Exp}}^c$.

Intuitively, expressions denote elements of the final coalgebra. The expressions ${\underline\emptyset}$, ${\varepsilon}_1\oplus {\varepsilon}_2$ and $\mu x.\, {\varepsilon}$ will play a similar role to, respectively, the empty language, the union of languages and the Kleene star in classical regular expressions for deterministic automata. The expressions $l<{\varepsilon}>$ and $r<{\varepsilon}>$ refer to the left and right hand-side of products. Similarly, $l[{\varepsilon}]$ and $r[{\varepsilon}]$ refer to the left and right hand-side of sums. The expressions $a({\varepsilon})$ and $\{{\varepsilon}\}$ denote function application and a singleton set, respectively. We shall soon illustrate, by means of examples, the role of these expressions. Here, it is already visible that our approach (to define a language) for the powerset functor differs from classical modal logic where $\Box$ and $\Diamond$ are used. This is a choice, justified by the fact that our goal is to have a “process algebra” like language instead of a modal logic one. It also explains why we only consider finite powerset: every finite set can be written as the finite union of its singletons.

Our language does not have any operator denoting intersection or complement (it only includes the sum operator $\oplus$). This is a natural restriction, very much in the spirit of Kleene’s regular expressions for deterministic finite automata. We will prove that this simple language is expressive enough to denote exactly all locally finite coalgebras.

Next, we present a typing assignment system for associating expressions to nondeterministic functors. This will allow us to associate with each functor ${\mathcal{G}}$ the expressions ${\varepsilon}\in {\mathsf{Exp}}^c$ that are valid specifications of ${\mathcal{G}}$-coalgebras. The typing proceeds following the structure of the expressions and the ingredients of the functors.

\[def:ts\] We define a typing relation $\vdash \subseteq {\mathsf{Exp}}\times {\mathit{NDF}}\times {\mathit{NDF}}$ that will associate an expression ${\varepsilon}$ with two nondeterministic functors ${\mathcal{F}}$ and ${\mathcal{G}}$, which are related by the ingredient relation (${\mathcal{F}}$ is an ingredient of ${\mathcal{G}}$). We shall write $\vdash {\varepsilon}\colon {\mathcal{F}}\lhd {\mathcal{G}}$ for $<{\varepsilon},{\mathcal{F}},{\mathcal{G}}> \in \;\vdash$. The rules that define $\vdash$ are the following: $$\begin{array}{cccc}
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash {\underline\emptyset}\colon {\mathcal{F}}\lhd {\mathcal{G}}$}}$}}& 
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash b\colon {\mathsf{B}}\lhd {\mathcal{G}}$}}$}}&
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash x \colon {\mathcal{G}}\lhd {\mathcal{G}}$}}$}}&
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash{\varepsilon}\colon {\mathcal{G}}\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash \mu x.{\varepsilon}\colon {\mathcal{G}}\lhd {\mathcal{G}}$}}$}}\\\\
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}_1 \colon {\mathcal{F}}\lhd {\mathcal{G}}\;\;\;\; \vdash{\varepsilon}_2\colon {\mathcal{F}}\lhd
{\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash {\varepsilon}_1\oplus{\varepsilon}_2 \colon {\mathcal{F}}\lhd {\mathcal{G}}$}}$}} &
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{G}}\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash {\varepsilon}\colon {\mathsf{Id}}\lhd {\mathcal{G}}$}}$}}&
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{F}}\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash \{{\varepsilon}\} \colon \pow {\mathcal{F}}\lhd {\mathcal{G}}$}}$}}&
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{F}}\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash a({\varepsilon}) \colon {\mathcal{F}}^A\lhd {\mathcal{G}}$}}$}}
\\\\
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{F}}_1\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash l<{\varepsilon}> \colon {\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}$}}$}}&
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{F}}_2\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash r<{\varepsilon}> \colon {\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}$}}$}}&
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{F}}_1\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash l[{\varepsilon}] \colon {\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}$}}$}}&
{\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{F}}_2\lhd {\mathcal{G}}$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash r[{\varepsilon}] \colon {\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}$}}$}}\end{array}$$

Intuitively, $\vdash {\varepsilon}\colon {\mathcal{F}}\lhd
{\mathcal{G}}$ (for a closed expression ${\varepsilon}$) means that ${\varepsilon}$ denotes an element of ${\mathcal{F}}(\Omega_{\mathcal{G}})$, where $\Omega_{\mathcal{G}}$ is the final coalgebra of ${\mathcal{G}}$. As expected, there is a rule for each expression construct. The extra rule involving ${\mathsf{Id}}\lhd {\mathcal{G}}$ reflects the isomorphism between the final coalgebra $\Omega_{\mathcal{G}}$ and ${\mathcal{G}}(\Omega_{\mathcal{G}})$ (Lambek’s lemma, cf. [@Rutten00]). Only fixed points at the outermost level of the functor are allowed. This does not mean however that we disallow nested fixed points. For instance, $\mu x.\, a(x \oplus \mu y.\, a(y))$ would be a well-typed expression for the functor ${\mathcal{D}}$ of deterministic automata, as it will become clear below, when we will present more examples of well-typed and non-well-typed expressions. The presented type system is decidable (expressions are of finite length and the system is inductive on the structure of ${\varepsilon}\in
{\mathsf{Exp}}$). Note that the rules above are meant to be read as an inductive definition rather than as an algorithm. In an eventual implementation, extra care is needed in the case ${\mathcal{G}}={\mathsf{Id}}$, to avoid looping in the rule for ${\mathsf{Id}}\lhd {\mathcal{G}}$.

We can formally define the set of ${\mathcal{G}}$-expressions: (closed and guarded) well-typed expressions associated with a nondeterministic functor ${\mathcal{G}}$.

Let ${\mathcal{G}}$ be a nondeterministic functor and ${\mathcal{F}}$ an ingredient of ${\mathcal{G}}$. We define ${\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$ by: $${\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}} = \{{\varepsilon}\in {\mathsf{Exp}}^c \mid\ \vdash{\varepsilon}\colon {\mathcal{F}}\lhd {\mathcal{G}}\}\,.$$ We define the set ${\mathsf{Exp}}_{\mathcal{G}}$ of well-typed [*${\mathcal{G}}$-expressions*]{} by ${\mathsf{Exp}}_{{\mathcal{G}}\lhd {\mathcal{G}}}$.

Let us instantiate the definition of ${\mathcal{G}}$-expressions to the functors of deterministic automata ${\mathcal{D}}= 2\times {\mathsf{Id}}^A$.

Let $A$ be a finite set of input actions and let $X$ be a set of (recursion or) fixed point variables. The set ${\mathsf{Exp}}_{\mathcal{D}}$ of [*deterministic expressions*]{} is given by the set of closed and guarded (each variable occurs in the scope of $a(-)$) expressions generated by the following BNF grammar. For $a \in A$ and $x \in X$: $$\begin{array} {l@{\;}l@{\;}c@{\;}l}
{\mathsf{Exp}}_{\mathcal{D}}\ni &{\varepsilon}&::=&  {\underline\emptyset}\mid {\varepsilon}\oplus {\varepsilon}\mid 
         \mu x.{\varepsilon}\mid 
 x \mid l<{\varepsilon}_1> \mid r<{\varepsilon}_2> \\
&{\varepsilon}_1 &::=& {\underline\emptyset}\mid 0 \mid 1 \mid {\varepsilon}_1\oplus{\varepsilon}_1\\
&{\varepsilon}_2 &::=&  {\underline\emptyset}\mid a({\varepsilon}) \mid {\varepsilon}_2\oplus{\varepsilon}_2
\end{array}$$

Examples of well-typed expressions for the functor ${\mathcal{D}}= 2\times {\mathsf{Id}}^A$ (with $2=\{0,1\}$ a two-element join-semilattice with $0$ as bottom element; recall that the ingredients of ${\mathcal{D}}$ are $2$, ${\mathsf{Id}}^A$ and ${\mathcal{D}}$ itself) include $r<a({\underline\emptyset})>$, $l<1>\oplus r<a(l<0>)>$ and $\mu x. r<a(x)> \oplus
l<1>$. The expressions $l[1]$, $l<1>\oplus 1$ and $\mu x. 1$ are examples of non well-typed expressions for ${\mathcal{D}}$, because the functor ${\mathcal{D}}$ does not involve ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$, the subexpressions in the sum have different type, and recursion is not at the outermost level ($1$ has type $2\lhd {\mathcal{D}}$), respectively.

It is easy to see that the closed (and guarded) expressions generated by the grammar presented above are exactly the elements of ${\mathsf{Exp}}_{\mathcal{D}}$. The most interesting case to check is the expression $r<a({\varepsilon})>$. Note that $a({\varepsilon})$ has type ${\mathsf{Id}}^A\lhd {\mathcal{D}}$ as long as ${\varepsilon}$ has type ${\mathsf{Id}}\lhd {\mathcal{D}}$. And the crucial remark here is that, by definition of $\vdash$, ${\mathsf{Exp}}_{{\mathsf{Id}}\lhd
{\mathcal{G}}} \subseteq {\mathsf{Exp}}_{\mathcal{G}}$. Therefore, ${\varepsilon}$ has type ${\mathsf{Id}}\lhd {\mathcal{D}}$ if it is of type ${\mathcal{D}}\lhd {\mathcal{D}}$, or more precisely, if ${\varepsilon}\in {\mathsf{Exp}}_{\mathcal{D}}$, which explains why the grammar above is correct.

At this point, we should remark that the syntax of our expressions differs from the classical regular expressions in the use of $\mu$ and action prefixing $a({\varepsilon})$ instead of star and full concatenation. We shall prove later that these two syntactically different formalisms are equally expressive (Theorems \[kleene1\] and  \[kleene2\]), but, to increase the intuition behind our expressions, let us present the syntactic translation from classical regular expressions to ${\mathsf{Exp}}_{\mathcal{D}}$ (this translation is inspired by [@milner]) and back.

\[def:regexp\_to\_exp\] The set of regular expressions is given by the following syntax $$RE \ni r ::= \underline 0 \mid \underline 1 \mid a \mid r+r \mid r\cdot r \mid r^*$$ where $a\in A$ and $\cdot$ denotes sequential composition. We define the following translations between regular expressions and deterministic expressions: $$\begin{array}{llp{.8cm}ll}
\multicolumn{2}{l}{(-)^\dagger\colon RE \to
{\mathsf{Exp}}_{\mathcal{D}}}&&\multicolumn{2}{l}{(-)^\ddagger\colon {\mathsf{Exp}}_{\mathcal{D}}\to RE}\\
 (\underline 0)^\dagger &= {\underline\emptyset}&&  ({\underline\emptyset})^\ddagger
&= \underline 0\\
 (\underline 1)^\dagger &= l<1> && (l<{\underline\emptyset}>)^\ddagger &=
(l<0>)^\ddagger = (r<{\underline\emptyset}>)^\ddagger = \underline 0 \\
  (a)^\dagger &= r<a(l<1>)> && (l<1>)^\ddagger &=\underline 1 \\
 (r_1+r_2)^\dagger &= (r_1)^\dagger\oplus (r_2)^\dagger &&
(l<{\varepsilon}_1\oplus {\varepsilon}_2>)^\ddagger &=(l<{\varepsilon}_1>)^\ddagger+ (l<{\varepsilon}_2>)^\ddagger\\
 (r_1\cdot r_2)^\dagger &= (r_1)^\dagger [(r_2)^\dagger/l<1>] &&
(r<a({\varepsilon})>)^\ddagger &=a \cdot ({\varepsilon})^\ddagger\\
  (r^*)^\dagger &= \mu x. (r)^\dagger[x/l<1>]\oplus l<1> &&
(r<{\varepsilon}_1\oplus {\varepsilon}_2>)^\ddagger &=(r<{\varepsilon}_1>)^\ddagger+
(r<{\varepsilon}_2>)^\ddagger\\
&&& ({\varepsilon}_1\oplus{\varepsilon}_2)^\ddagger &= ({\varepsilon}_1)^\ddagger+ ({\varepsilon}_2)^\ddagger\\
&&&  (\mu x. {\varepsilon})^\ddagger &= \mathbf{sol}(\mathbf{eqs}(\mu x. {\varepsilon})) 
\end{array}$$ The function $\mathbf{eqs}$ translates $\mu x. {\varepsilon}$ into a system of equations in the following way. Let $\mu x_1. {\varepsilon}_1, \ldots, \mu x_n.
{\varepsilon}_n$ be all the fixed point subexpressions of $\mu x. {\varepsilon}$, with $x_1=x$ and ${\varepsilon}_1={\varepsilon}$. We define $n$ equations $x_i =
(\overline{\varepsilon}_i)^\dagger$, where $\overline{\varepsilon}_i$ is obtained from ${\varepsilon}_i$ by replacing each subexpression $\mu x_i. {\varepsilon}_i$ by $x_i$, for all $i=1,\ldots n$. The solution of the system, $\mathbf{sol}(\mathbf{eqs}(\mu x.{\varepsilon}))$, is then computed in the usual way (the solution of an equation of shape $x=rx+t$ is $r^*t$).

In [@Rut98c], regular expressions were given a coalgebraic structure, using Brzozowski derivatives [@Brz64]. Later in this paper, we will provide a coalgebra structure to ${\mathsf{Exp}}_{\mathcal{D}}$, after which the soundness of the above translations can be stated and proved: $r \sim
r^\dagger$ and ${\varepsilon}\sim {\varepsilon}^\ddagger$, where $\sim$ will coincide with language equivalence.

Thus, the regular expression $aa^*$ is translated to $r<a(\mu x. r<a(x)> \oplus l<1>)>$, whereas the expression $\mu x. r<a(r<a(x)>)> \oplus l<1>$ is transformed into $(aa)^*$.

We present next the syntax for the expressions in ${\mathsf{Exp}}_{\mathcal{Q}}$ and in ${\mathsf{Exp}}_{\mathcal{N}}$ (recall that ${\mathcal{Q}}=(1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathsf{Id}})^A$ and ${\mathcal{N}}=2\times (\pow{\mathsf{Id}})^A$).

Let $A$ be a finite set of input actions and $X$ be a set of (recursion or) fixed point variables. The set ${\mathsf{Exp}}_{\mathcal{Q}}$ of [*partial expressions*]{} is given by the set of closed and guarded expressions generated by the following BNF grammar. For $a \in A$ and $x \in X$: $$\begin{array} {l@{\;}l@{\;}c@{\;}l}
{\mathsf{Exp}}_{\mathcal{Q}}\ni &{\varepsilon}&::=& {\underline\emptyset}\mid  {\varepsilon}\oplus {\varepsilon}\mid 
         \mu x.{\varepsilon}\mid  x \mid 
         a({\varepsilon}_1)\\
& {\varepsilon}_1&::=& {\underline\emptyset}\mid {\varepsilon}_1\oplus {\varepsilon}_1   \mid l[{\varepsilon}_2] \mid r[{\varepsilon}] \\   
& {\varepsilon}_2 &::=& {\underline\emptyset}\mid {\varepsilon}_2\oplus {\varepsilon}_2 \mid * 
\end{array}$$ Intuitively, the expressions $a(l[*])$ and $a(r[{\varepsilon}])$ specify, respectively, a state which has no defined transition for input $a$ and a state with an outgoing transition to another one specified by ${\varepsilon}$.

Let $A$ be a finite set of input actions and $X$ be a set of (recursion or) fixed point variables. The set ${\mathsf{Exp}}_{\mathcal{N}}$ of [*nondeterministic expressions*]{} is given by the set of closed and guarded expressions generated by the following BNF grammar. For $a \in A$ and $x \in X$: $$\begin{array} {l@{\;}l@{\;}c@{\;}l}
{\mathsf{Exp}}_{\mathcal{N}}\ni& {\varepsilon}&::=&  {\underline\emptyset}\mid x \mid 
         r<{\varepsilon}_2> \mid  l<{\varepsilon}_1> \mid 
         {\varepsilon}\oplus {\varepsilon}\mid 
         \mu x.{\varepsilon}\\
&{\varepsilon}_1 &::=&  {\underline\emptyset}\mid {\varepsilon}_1 \oplus {\varepsilon}_1 \mid 1 \mid 0\\
&{\varepsilon}_2 &::=&  {\underline\emptyset}\mid {\varepsilon}_2 \oplus {\varepsilon}_2 \mid a({\varepsilon}')\\
&{\varepsilon}' &::=&  {\underline\emptyset}\mid {\varepsilon}' \oplus {\varepsilon}' \mid \{{\varepsilon}\}
\end{array}$$ Intuitively, the expression $r<a(\{{\varepsilon}_1\}\oplus \{{\varepsilon}_2\})>$ specifies a state which has two outgoing transitions labelled with the input letter $a$, one to a state specified by ${\varepsilon}_1$ and another to a state specified by ${\varepsilon}_2$.

We have defined a language of expressions which gives us an algebraic description of systems. We should also remark at this point that in the examples we strictly follow the type system to derive the syntax of the expressions. However, it is obvious that many simplifications can be made in order to obtain a more polished language. In particular, after the axiomatization we will be able to decrease the number of levels in the above grammars, since will we have axioms of the shape $a({\varepsilon})\oplus
a({\varepsilon}') \equiv a({\varepsilon}\oplus {\varepsilon}')$. In Section \[sec:appl\], we will sketch two examples where we apply some simplification to the syntax.

The goal is now to present a generalization of Kleene’s theorem for nondeterministic coalgebras (Theorems \[kleene1\] and \[kleene2\]). Recall that, for regular languages, the theorem states that a language is regular if and only if it is recognized by a finite automaton. In order to achieve our goal we will first show that the set ${\mathsf{Exp}}_{\mathcal{G}}$ of ${\mathcal{G}}$-expressions carries a ${\mathcal{G}}$-coalgebra structure.

Expressions are coalgebras {#sec:expressions_coalg}
--------------------------

In this section, we show that the set of ${\mathcal{G}}$-expressions for a given nondeterministic functor ${\mathcal{G}}$ has a coalgebraic structure $\delta_{\mathcal{G}}\colon
{\mathsf{Exp}}_{\mathcal{G}}\to {\mathcal{G}}({\mathsf{Exp}}_{\mathcal{G}})\,$. More precisely, we are going to define a function $$\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}\; : \; {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}} \to {\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}})$$ for every ingredient ${\mathcal{F}}$ of ${\mathcal{G}}$, and then set $\delta_{\mathcal{G}}=
\delta_{{\mathcal{G}}\lhd {\mathcal{G}}}$. Our definition of the function $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$ will make use of the following.

For every ${\mathcal{G}}\in {\mathit{NDF}}$ and for every ${\mathcal{F}}$ with ${\mathcal{F}}\lhd {\mathcal{G}}$:

-   we define a constant ${\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}} \in
    {\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{G}}})$ by induction on the syntactic structure of ${\mathcal{F}}$: $$\begin{array}{lcl}
    {\mathsf{Empty}}_{{\mathsf{Id}}\lhd {\mathcal{G}}} &=& {\underline\emptyset}\\
    {\mathsf{Empty}}_{{\mathsf{B}}\lhd {\mathcal{G}}} &=& \bot_{\mathsf{B}}\\
    {\mathsf{Empty}}_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}} &=& <{\mathsf{Empty}}_{{\mathcal{F}}_1\lhd
    {\mathcal{G}}}, {\mathsf{Empty}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}}>
    \end{array}
    \begin{array}{lcl}
    {\mathsf{Empty}}_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}} &=& \bot\\
    {\mathsf{Empty}}_{{\mathcal{F}}^A\lhd {\mathcal{G}}} &=& \lambda a. {\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}}\\
    {\mathsf{Empty}}_{\pow {\mathcal{F}}\lhd {\mathcal{G}}} &=& \emptyset
    \end{array}$$

-   we define a function ${\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}\colon
    {\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{G}}})\times
    {\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{G}}})\to
    {\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}})$ by induction on the syntactic structure of ${\mathcal{F}}$: $$\begin{array}{lcl}
    {\mathsf{Plus}}_{{\mathsf{Id}}\lhd {\mathcal{G}}} ({\varepsilon}_1, {\varepsilon}_2) &=& {\varepsilon}_1 \oplus {\varepsilon}_2\\
    {\mathsf{Plus}}_{{\mathsf{B}}\lhd {\mathcal{G}}} (b_1,b_2) &=& b_1\vee_{\mathsf{B}}b_2\\
    {\mathsf{Plus}}_{{\mathcal{F}}_1\times {\mathcal{F}}_2 \lhd {\mathcal{G}}} (<{\varepsilon}_1, {\varepsilon}_2>, <{\varepsilon}_3,
    {\varepsilon}_4>)& =& <{\mathsf{Plus}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}} ({\varepsilon}_1,{\varepsilon}_3),
    {\mathsf{Plus}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}} (
    {\varepsilon}_2, {\varepsilon}_4)>\\
    {\mathsf{Plus}}_{{\mathcal{F}}_1 {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}} (\kappa_i({\varepsilon}_1),\kappa_i({\varepsilon}_2)) &=&
    \kappa_i({\mathsf{Plus}}_{{\mathcal{F}}_i\lhd {\mathcal{G}}} ({\varepsilon}_1,{\varepsilon}_2)),\ \ \ i\in \{1,2\}\\
    {\mathsf{Plus}}_{{\mathcal{F}}_1 {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}} (\kappa_i({\varepsilon}_1),\kappa_j({\varepsilon}_2)) &=& \top
    \ \ \ i,j\in\{1,2\}\ \ and\ \ i\neq j\\
    {\mathsf{Plus}}_{{\mathcal{F}}_1 {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}} (x,\top) &=& {\mathsf{Plus}}_{{\mathcal{F}}_1
    {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}
    (\top,x) = \top\\
    {\mathsf{Plus}}_{{\mathcal{F}}_1 {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}} (x,\bot) &=& {\mathsf{Plus}}_{{\mathcal{F}}_1
    {\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}
    (\bot,x) = x\\
    {\mathsf{Plus}}_{{\mathcal{F}}^A\lhd {\mathcal{G}}}(f,g)& =& \lambda a.\ {\mathsf{Plus}}_{{\mathcal{F}}\lhd
    {\mathcal{G}}}(f(a),g(a))\\
    {\mathsf{Plus}}_{\pow {\mathcal{F}}\lhd {\mathcal{G}}}(s_1,s_2)&=& s_1\cup s_2
    \end{array}$$

Intuitively, one can think of the constant ${\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$ and the function ${\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$ as liftings of ${\underline\emptyset}$ and $\oplus$ to the level of ${\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{G}}}$).

We need two more things to define $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$. First, we define an order $\preceq$ on the types of expressions. For ${\mathcal{F}}_1$, ${\mathcal{F}}_2$ and ${\mathcal{G}}$ non-deterministic functors such that ${\mathcal{F}}_1\lhd {\mathcal{G}}$ and ${\mathcal{F}}_2\lhd {\mathcal{G}}$, we define $$({\mathcal{F}}_1\lhd {\mathcal{G}}) \preceq
({\mathcal{F}}_2\lhd {\mathcal{G}}) \Leftrightarrow {\mathcal{F}}_1\lhd {\mathcal{F}}_2$$ The order $\preceq$ is a partial order (structure inherited from $\lhd$). Note also that $({\mathcal{F}}_1\lhd {\mathcal{G}}) = ({\mathcal{F}}_2\lhd {\mathcal{G}}) \Leftrightarrow {\mathcal{F}}_1={\mathcal{F}}_2$. Second, we define a measure $N({\varepsilon})$ based on the maximum number of nested unguarded occurrences of $\mu$-expressions in ${\varepsilon}$ and unguarded occurrences of $\oplus$. We say that a subexpression $\mu x.{\varepsilon}_1$ of ${\varepsilon}$ occurs unguarded if it is not in the scope of one of the operators $l<->$, $r<->$, $l[-]$, $r[-]$, $a(-)$ or $\{-\}$.

\[def:N\] For every guarded expression ${\varepsilon}$, we define $N({\varepsilon})$ as follows: $$\begin{aligned}
&N({\underline\emptyset}) = N(b) = N(a({\varepsilon})) = N(l<{\varepsilon}>) = N(r<{\varepsilon}>) = N(l[{\varepsilon}]) =
N(r[{\varepsilon}]) = N(\{{\varepsilon}\})= 0
\\
&N({\varepsilon}_1 \oplus {\varepsilon}_2) = 1 + \mathit{max} \{ N({\varepsilon}_1) , \, N({\varepsilon}_2) \}\\
& N(\mu x.{\varepsilon}) = 1 + N({\varepsilon})\end{aligned}$$

The measure $N$ induces a partial order on the set of expressions: ${\varepsilon}_1\ll {\varepsilon}_2 \Leftrightarrow N({\varepsilon}_1) \leq N({\varepsilon}_2)$, where $\leq$ is just the ordinary inequality of natural numbers.

Now we have all we need to define $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}\colon
{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}\to {\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}})$.

For every ingredient ${\mathcal{F}}$ of a nondeterministic functor ${\mathcal{G}}$ and an expression ${\varepsilon}\in {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$, we define $\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}({\varepsilon})$ as follows: $$\begin{array}{lcl}
\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}  ({\underline\emptyset}) &=& {\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}}\\
\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}  ({\varepsilon}_1\oplus{\varepsilon}_2) &=& {\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}(\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}  ({\varepsilon}_1), \delta_{{\mathcal{F}}\lhd {\mathcal{G}}}  ({\varepsilon}_2))\\
\delta_{{\mathcal{G}}\lhd {\mathcal{G}}}  (\mu x. {\varepsilon}) &=& \delta_{{\mathcal{G}}\lhd {\mathcal{G}}} ({\varepsilon}[\mu x.
{\varepsilon}/x])\\
\delta_{{\mathsf{Id}}\lhd {\mathcal{G}}}({\varepsilon}) &=& {\varepsilon}\ \ \ \textrm{for} \ {\mathcal{G}}\neq {\mathsf{Id}}\\
\delta_{{\mathsf{B}}\lhd {\mathcal{G}}} (b) &=& b\\
\delta_{{\mathcal{F}}_1\times {\mathcal{F}}_2 \lhd {\mathcal{G}}} (l<{\varepsilon}>) &=& <
\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon}), {\mathsf{Empty}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}} >\\
\delta_{{\mathcal{F}}_1\times {\mathcal{F}}_2 \lhd {\mathcal{G}}} (r<{\varepsilon}>) &=& <{\mathsf{Empty}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}},
\delta_{{\mathcal{F}}_2\lhd {\mathcal{G}}}({\varepsilon}) >\\
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd {\mathcal{G}}} (l[{\varepsilon}]) &=& \kappa_1(\delta_{{\mathcal{F}}_1
\lhd {\mathcal{G}}}({\varepsilon}))\\
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd {\mathcal{G}}} (r[{\varepsilon}]) &=& \kappa_2(\delta_{{\mathcal{F}}_2
\lhd {\mathcal{G}}}({\varepsilon}))\\
\delta_{{\mathcal{F}}^A \lhd {\mathcal{G}}} (a({\varepsilon})) &=& \lambda a' .\left\{
\begin{array}{ll}\delta_{{\mathcal{F}}\lhd {\mathcal{G}}} ({\varepsilon})
&\text{if }a=a'\\{\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}}&\text{otherwise}\end{array}\right.
\\
\delta_{\pow {\mathcal{F}}\lhd {\mathcal{G}}} (\{{\varepsilon}\}) &=& \{\,\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon})\,\}
\end{array}$$ Here, ${\varepsilon}[\mu x.{\varepsilon}/x]$ denotes syntactic substitution, replacing every free occurrence of $x$ in ${\varepsilon}$ by $\mu x.{\varepsilon}$.

In order to see that the definition of $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$ is well-formed, we have to observe that $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$ can be seen as a function having two arguments: the type ${\mathcal{F}}\lhd {\mathcal{G}}$ and the expression ${\varepsilon}$. Then, we use induction on the Cartesian product of types and expressions with orders $\preceq$ and $\ll$, respectively. More precisely, given two pairs $<{\mathcal{F}}_1\lhd {\mathcal{G}}, {\varepsilon}_1>$ and $<{\mathcal{F}}_2\lhd {\mathcal{G}}, {\varepsilon}_2>$ we have an order $$\label{ind:order5}
\begin{array}{lcll}
<{\mathcal{F}}_1\lhd {\mathcal{G}}, {\varepsilon}_1> \leq <{\mathcal{F}}_2\lhd {\mathcal{G}}, {\varepsilon}_2> &\Leftrightarrow&&
\text{(i) } ({\mathcal{F}}_1\lhd {\mathcal{G}}) \preceq ({\mathcal{F}}_2\lhd {\mathcal{G}}) \\ &&\text{ or }&
\text{(ii) } ({\mathcal{F}}_1\lhd {\mathcal{G}}) = ({\mathcal{F}}_2\lhd {\mathcal{G}})\text{ and } {\varepsilon}_1\ll {\varepsilon}_2
\end{array}$$ Observe that in the definition above it is always true that $<{\mathcal{F}}'\lhd {\mathcal{G}}, {\varepsilon}'> \leq <{\mathcal{F}}\lhd {\mathcal{G}}, {\varepsilon}>$, for all occurrences of $\delta_{{\mathcal{F}}'\lhd {\mathcal{G}}}({\varepsilon}')$ occurring in the right hand side of the equation defining $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon})$. In all cases, but the ones that ${\varepsilon}$ is a fixed point or a sum expression, the inequality comes from point (i) above. For the case of the sum, note that $<{\mathcal{F}}\lhd
{\mathcal{G}},{\varepsilon}_1> \leq <{\mathcal{F}}\lhd {\mathcal{G}},  {\varepsilon}_1\oplus{\varepsilon}_2>$ and $<{\mathcal{F}}\lhd {\mathcal{G}}, {\varepsilon}_2> \leq
<{\mathcal{F}}\lhd {\mathcal{G}},  {\varepsilon}_1\oplus{\varepsilon}_2>$ by point (ii), since $N({\varepsilon}_1) \ls  N({\varepsilon}_1\oplus{\varepsilon}_2)$ and $N({\varepsilon}_2) \ls N({\varepsilon}_1\oplus{\varepsilon}_2)$. Similarly, in the case of $\mu x.{\varepsilon}$ we have that $N({\varepsilon}) = N({\varepsilon}[\mu x.{\varepsilon}/x])$, which can easily be proved by (standard) induction on the syntactic structure of ${\varepsilon}$, since ${\varepsilon}$ is guarded (in $x$), and this guarantees that $N({\varepsilon}[\mu x.{\varepsilon}/x]) \ls N(\mu x. {\varepsilon})$. Hence, $<{\mathcal{G}}\lhd
{\mathcal{G}},{\varepsilon}> \leq <{\mathcal{G}}\lhd {\mathcal{G}},\mu x.{\varepsilon}>$. Also note that clause 4 of the above definition overlaps with clauses 1 and 2 (by taking ${\mathcal{F}}={\mathsf{Id}}$). However, they give the same result and thus the function $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$ is well-defined.

We define, for each nondeterministic functor ${\mathcal{G}}$, a ${\mathcal{G}}$-coalgebra $$\delta_{\mathcal{G}}\colon {\mathsf{Exp}}_{\mathcal{G}}\to {\mathcal{G}}({\mathsf{Exp}}_{\mathcal{G}})$$ by putting $\delta_{\mathcal{G}}= \delta_{{\mathcal{G}}\lhd {\mathcal{G}}}$.

The function $\delta_{\mathcal{G}}$ can be thought of as the generalization of the well-known notion of Brzozowski derivative [@Brz64] for regular expressions and, moreover, it provides an operational semantics for expressions, as we shall see in Section \[sec:expressive\].

The observation that the set of expressions has a coalgebra structure will be crucial for the proof of the generalized Kleene theorem, as will be shown in the next two sections.

Expressions are expressive {#sec:expressive}
--------------------------

Having a ${\mathcal{G}}$-coalgebra structure on ${\mathsf{Exp}}_{\mathcal{G}}$ has two advantages. First, it provides us, by finality, directly with a natural semantics because of the existence of a (unique) homomorphism $\mathbf{beh} \colon {\mathsf{Exp}}_{\mathcal{G}}\to \Omega_{\mathcal{G}}$, that assigns to every expression ${\varepsilon}$ an element $\mathbf{beh}({\varepsilon})$ of the final coalgebra $\Omega_{\mathcal{G}}$.

The second advantage of the coalgebra structure on ${\mathsf{Exp}}_{\mathcal{G}}$ is that it lets us use the notion of ${\mathcal{G}}$-bisimulation to relate ${\mathcal{G}}$-coalgebras $(S,g)$ and expressions ${\varepsilon}\in {\mathsf{Exp}}_{\mathcal{G}}$. If one can construct a bisimulation relation between an expression ${\varepsilon}$ and a state $s$ of a given coalgebra, then the behaviour represented by ${\varepsilon}$ is equal to the behaviour of the state $s$. This is the analogue of computing the language $L(r)$ represented by a given regular expression $r$ and the language $L(s)$ accepted by a state $s$ of a finite state automaton and checking whether $L(r) = L(s)$.

The following theorem states that every state in a locally finite ${\mathcal{G}}$-coalgebra can be represented by an expression in our language. This generalizes [*half*]{} of Kleene’s theorem for deterministic automata: if a language is accepted by a finite automaton then it is regular ([*i.e.*]{} it can be denoted by a regular expression). The generalization of the other [*half*]{} of the theorem (if a language is regular then it is accepted by a finite automaton) will be presented in Section \[sec:synthesis\]. It is worth to remark that in the usual definition of deterministic automaton the initial state of the automaton is included and, thus, in the original Kleene’s theorem, it was enough to consider finite automata. In the coalgebraic approach, the initial state is not explicitly modelled and thus we need to consider locally-finite coalgebras: coalgebras where each state will generate a finite subcoalgebra.

\[kleene1\] Let ${\mathcal{G}}$ be a nondeterministic functor and let $(S,g)$ be a locally-finite ${\mathcal{G}}$-coalgebra. Then, for any $s \in S$, there exists an expression $\expr s \in {\mathsf{Exp}}_{\mathcal{G}}$ such that $s\sim \expr s$.

Let $s\in S$ and let $<s>= \{s_1, \ldots, s_n\}$ with $s_1=s$. We construct, for every state $s_i \in <s>$, an expression $\expr {s_i} $ such that $s_i \sim \expr {s_i} $ .

If ${\mathcal{G}}= {\mathsf{Id}}$, we set, for every $i$, $\expr {s_i} = {\underline\emptyset}$. It is easy to see that $\{<s_i,{\underline\emptyset}> \mid s_i\in <s> \}$ is a bisimulation and, thus, we have that $s \sim \expr s$.

For ${\mathcal{G}}\neq {\mathsf{Id}}$, we proceed in the following way. Let, for every $i$, $A_i = \mu x_i. \gamma^{\mathcal{G}}_{g(s_i)}$ where, for ${\mathcal{F}}\lhd {\mathcal{G}}$ and $c\in {\mathcal{F}}<s>$, the expression $\gamma^{\mathcal{F}}_{c}\in {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$ is defined by induction on the structure of ${\mathcal{F}}$: $$\begin{array}{llll}
\gamma^{{\mathsf{Id}}}_{s_i} = x_i & \gamma^{{\mathsf{B}}}_b = b &
{\gamma^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{<c,c'>} = l<\gamma^{{\mathcal{F}}_1}_{c}> \oplus
r<\gamma^{{\mathcal{F}}_2}_{c'}>} & \gamma^{{\mathcal{F}}^A}_f =  \bigoplus\limits_{a\in A}
a(\gamma^{\mathcal{F}}_{f(a)})
\\[2ex]
\gamma^{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}_{\kappa_1(c)} = l[\gamma^{{\mathcal{F}}_1}_{c}] & 
\gamma^{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}_{\kappa_2(c)} = r[\gamma^{{\mathcal{F}}_2}_{c}] &
\gamma^{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}_{\bot} = {\underline\emptyset}& \gamma^{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}_{\top} = l[{\underline\emptyset}]\oplus r[{\underline\emptyset}] \\[2ex]
\multicolumn{2}{l}{\gamma^{\pow {\mathcal{F}}}_{C} = \begin{cases}
\bigoplus\limits_{c\in C}
\{\gamma^{\mathcal{F}}_{c}\} & C\neq\emptyset\\{\underline\emptyset}&\text{otherwise}\end{cases} }
\end{array}$$ Note that here the choice of $l[{\underline\emptyset}]\oplus
r[{\underline\emptyset}]$ to represent inconsistency is arbitrary but [*canonical*]{}, in the sense that any other expression involving sum of $l[{\varepsilon}_1]$ and $r[{\varepsilon}_2]$ will be bisimilar. Formally, the definition of $\gamma$ above is parametrized by a function from $\{s_1,\ldots, s_n\}$ to a fixed set of variables $\{x_1,\ldots, x_n\}$. It should also be noted that $\bigoplus\limits_{i\in I} {\varepsilon}_i$ stands for ${\varepsilon}_1 \oplus ({\varepsilon}_2 \oplus
({\varepsilon}_3 \oplus
\ldots))$ (this is a choice, since later we will axiomatize $\oplus$ to be commutative and associative).

Let $A^0_i = A_i$, define $A_i^{k+1} =
A_i^k\{A^k_{k+1}/x_{k+1}\}$ and then set $\expr{s_i} = A_i^n$. Here, $A\{A'/x\}$ denotes syntactic replacement (that is, substitution without renaming of bound variables in $A$ which are also free variables in $A'$). The definition of $\expr{s_i}$ does not depend in the chosen order of $\{s_1,\dots, s_n\}$: the expressions obtained are just different modulo renaming of variables.

Observe that the term $$A^n_i = ( \mu x_i.  \gamma^{\mathcal{G}}_{g(s_i)}) \{A^0_{1}/x_{1}\} \ldots \{A^{n-1}_{n}/x_{n}\}$$ is a closed term because, for every $j = 1,\ldots, n$, the term $A_j^{j-1}$ contains at most $n-j$ free variables in the set $\{x_{j+1}, \ldots, x_n\}$.

It remains to prove that $s_i\sim \expr {s_i}$. We show that is a bisimulation. For that, we define, for ${\mathcal{F}}\lhd {\mathcal{G}}$ and $c\in
{\mathcal{F}}<s>$, $\xi^{\mathcal{F}}_{c} = \gamma^{\mathcal{F}}_{c}  \{A^0_{1}/x_{1}\} \ldots \{A^{n-1}_{n}/x_{n}\}$ and the relation $$R_{{\mathcal{F}}\lhd {\mathcal{G}}} = \{<c, \delta_{{\mathcal{F}}\lhd {\mathcal{G}}}(\xi^{\mathcal{F}}_{c})> \mid c \in {\mathcal{F}}<s> \}.$$ Then, we prove that

\(C) [$1$]{};

$R_{{\mathcal{F}}\lhd {\mathcal{G}}} = \overline {\mathcal{F}}(R)$ and

\(C) [$2$]{};

$<g(s_i), \delta_{\mathcal{G}}(\expr{s_i})> \in R_{{\mathcal{G}}\lhd {\mathcal{G}}}$.

-   By induction on the structure of ${\mathcal{F}}$.

    Note that $R_{{\mathsf{Id}}\lhd {\mathcal{G}}} = \{<s_i, \xi^{{\mathsf{Id}}}_{s_i}> \mid s_i\in <s>\}$ which is equal to ${\mathsf{Id}}(R)=R$ provided that $\xi^{{\mathsf{Id}}}_{s_i} = \expr{s_i}$. The latter is indeed the case: $$\begin{array}{lcll}
    \xi^{{\mathsf{Id}}}_{s_i} &=& \gamma^{{\mathsf{Id}}}_{s_i}  \{A^0_{1}/x_{1}\} \ldots \{A^{n-1}_{n}/x_{n}\} & \text{(def. $\xi^{{\mathsf{Id}}}_{s_i}$)}\\[1ex]
    &=& x_i  \{A^0_{1}/x_{1}\} \ldots \{A^{n-1}_{n}/x_{n}\} & \text{(def. $\gamma^{{\mathsf{Id}}}_{s_i}$)}\\[1ex]
    &=& A^{i-1}_i \{A^{i}_{i+1}/x_{i+1}\} \ldots \{A^{n-1}_{n}/x_{n}\} & \text{($\{A_i^{i-1}/x_i\}$)} \\[1ex]
    &=& A^0_i \{A^0_{1}/x_{1}\} \ldots \{A^{n-1}_{n}/x_{n}\}& \text{(def. $A^{i-1}_i$)}\\[1ex]
    &=& \expr{s_i}& \text{(def. $\expr{s_i}$)}
    \end{array}$$

    Note that, for $b\in {\mathsf{B}}$, $\xi^{\mathsf{B}}_b = \gamma^{\mathsf{B}}_b
    \{A^0_{1}/x_{1}\} \ldots \{A^{n-1}_{n}/x_{n}\} = b$. Thus, we have that $R_{{\mathsf{B}}\lhd {\mathcal{G}}} = \{<s_i, \xi^{\mathsf{B}}_{s_i}> \mid s_i\in {\mathsf{B}}<s>\} =  \{<b, b> \mid b\in {\mathsf{B}}\}  = \overline {\mathsf{B}}(R)$.

    $$\begin{array}{@{}lcll}
    &&<<u,v>, <e,f>> \in \overline{{\mathcal{F}}_1\times {\mathcal{F}}_2}(R) \\&\iff& <u,e> \in
    \overline{{\mathcal{F}}_1}(R) \text{ and }  <v,f> \in  \overline{{\mathcal{F}}_2}(R)&\text{(def. $\overline{{\mathcal{F}}_1\times {\mathcal{F}}_2}$)}\\[1.5ex]
    &\iff&  <u,e>  \in R_{{\mathcal{F}}_1 \lhd {\mathcal{G}}} \text{ and } <v,f>  \in  R_{{\mathcal{F}}_2 \lhd {\mathcal{G}}}& \text{(ind. hyp.)}\\[1.5ex]
    &\iff& <u,e>  = <c , \delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}(\xi^{{\mathcal{F}}_1}_{c})> \text{ and }
    <v,f>  = <c' , \delta_{{\mathcal{F}}_2\lhd {\mathcal{G}}}(\xi^{{\mathcal{F}}_2}_{c'})>&\text{(def. $R_{{\mathcal{F}}_i\lhd {\mathcal{G}}}$)}\\[1.5ex]
    &\iff& <u,v> = <c,c'> \text{ and }  <e,f> = \delta_{{\mathcal{F}}_1\times
    {\mathcal{F}}_2\lhd {\mathcal{G}}}(l(\xi^{{\mathcal{F}}_1}_{c}) \oplus r(\xi^{{\mathcal{F}}_2}_{c'}))&\text{(def. $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$)}\\[1.5ex]
    &\iff& <u,v> = <c,c'> \text{ and }  <e,f> = \delta_{{\mathcal{F}}_1\times
    {\mathcal{F}}_2\lhd {\mathcal{G}}}(\xi^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{<c,c'>})&\text{(def. $\xi^{\mathcal{F}}$)}\\[1.5ex]
    &\iff&  <<u,v>, <e,f>> \in R_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}} 
    \end{array}$$

    , and : similar to ${\mathcal{F}}_1\times {\mathcal{F}}_2$.

-   We want to prove that $<g(s_i),
    \delta_{\mathcal{G}}(\expr{s_i})> \in R_{{\mathcal{G}}\lhd {\mathcal{G}}}$. For that, we must show that $g(s_i) \in {\mathcal{G}}<s>$ and $\delta_{\mathcal{G}}(\expr{s_i}) =
    \delta_{\mathcal{G}}(\xi^{\mathcal{G}}_{g(s_i)})$. The former follows by definition of $<s>$, whereas for the latter we observe that:

      ----------- -------------------------------------------------------------------------------------------- ----------------------------------
                      $\delta_{\mathcal{G}}(\expr{s_i})$                                                       

                  $= \delta_{\mathcal{G}}((\mu x_i. \gamma^{\mathcal{G}}_{g(s_i)})  \{A^0_{1}/x_{1}\} \ldots   $ \text{(def. of $\expr{s_i}$)}$
                  \{A^{n-1}_{n}/x_{n}\}) $                                                                     

      \[1.5ex\]   $=\delta_{\mathcal{G}}(\mu x_i. \gamma^{\mathcal{G}}_{g(s_i)}  \{A^0_{1}/x_{1}\} \ldots      
                  \{A^{i-2}_{i-1}/x_{i-1}\}  \{A^i_{i+1}/x_{i+1}\}                                             
                  \ldots\{A^{n-1}_{n}/x_{n}\})$                                                                

      \[1.5ex\]   $=\delta_{\mathcal{G}}(\gamma^{\mathcal{G}}_{g(s_i)}  \{A^0_{1}/x_{1}\} \ldots               $  \text{(def. of
                  \{A^{i-2}_{i-1}/x_{i-1}\}  \{A^i_{i+1}/x_{i+1}\}                                             $\delta_{\mathcal{G}}$)}$
                  \ldots\{A^{n-1}_{n}/x_{n}\}[A^n_i/x_i])$                                                     

      \[1.5ex\]   $=\delta_{\mathcal{G}}(\gamma^{\mathcal{G}}_{g(s_i)}  \{A^0_{1}/x_{1}\} \ldots               $  \text{($[A^n_i/x_i] =
                  \{A^{i-2}_{i-1}/x_{i-1}\}  \{A^i_{i+1}/x_{i+1}\}                                             \{A^n_i/x_i\}$)}$
                  \ldots\{A^{n-1}_{n}/x_{n}\}\{A^n_i/x_i\})$                                                   

      \[1.5ex\]   $=\delta_{\mathcal{G}}(\gamma^{\mathcal{G}}_{g(s_i)}  \{A^0_{1}/x_{1}\} \ldots               
                  \{A^{i-2}_{i-1}/x_{i-1}\} \{A^n_i/x_i\} \{A^i_{i+1}/x_{i+1}\}                                
                  \ldots\{A^{n-1}_{n}/x_{n}\})$                                                                

      \[1.5ex\]   $=\delta_{\mathcal{G}}(\xi^{\mathcal{G}}_{g(s_i)})$                                          
      ----------- -------------------------------------------------------------------------------------------- ----------------------------------

    Here, note that $[A^n_i/x_i] = \{A^n_i/x_i\}$, because $A^n_i$ has no free variables. The last two steps follow, respectively, because $x_i$ is not free in $A^i_{i+1},\ldots, A^{n-1}_{n}$ and: $$\begin{aligned}
    \nonumber
     && \{A^n_i/x_i\} \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\} \\
     \nonumber  &=& \{A^{i-1}_i \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\} /x_i\} \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\} \\[1.5ex]
     \label{eq:subst1} &=& \{A^{i-1}_i/x_i\} \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\}
      \end{aligned}$$ Equation (\[eq:subst1\]) uses the syntactic identity $$\label{eq:subst2}A\{B\{C/y\}/x\}\{C/y\} =
    A\{B/x\}\{C/y\},\ \ \ y \text{ not free in $C$}$$

Let us illustrate the construction appearing in the proof of Theorem \[kleene1\] by some examples. These examples will illustrate the similarity with the proof of Kleene’s Theorem presented in most textbooks, where a regular expression denoting the language recognized by a state of a deterministic automaton is built using a system of equations.

Consider the following deterministic automaton over $A=\{a,b\}$, whose transition function $g$ is given by the following picture ($\xymatrix{*++[o][F=]{s}}$ represents that the state $s$ is final): $$\xymatrix{*++[o][F]{s_1} \ar[r]^{a}\ar@(l,u)[]^{b}&*++[o][F=]{s_2}
\ar@(r,u)[]_{a, b}}$$ We define $A_1 = \mu x_1  . \gamma^{\mathcal{D}}_{g(s_1)}$ and $A_2 = \mu x_2  . \,  \gamma^{\mathcal{D}}_{g(s_2)}$ where $$\gamma^{\mathcal{D}}_{g(s_1)} = l<0> \oplus r<b(x_1) \oplus a(x_2)> \;\;\;\;\;
\gamma^{\mathcal{D}}_{g(s_2)} =
l<1> \oplus r<a(x_2) \oplus b(x_2)>$$ We have $A^2_1 = A_1 \{A^1_2/x_2\}$ and $A^2_2 = A_2 \{A^0_1/x_1\} $. Thus, $\expr {s_2} = A_2$ and, since $A^1_2=A_2$, $\expr {s_1}$ is the expression $$\mu x_1 . \, l<0> \oplus r<b(x_1) \oplus a(\mu x_2 . \, l<1> \oplus r<a(x_2) \oplus
b(x_2)>
)>$$ By construction we have $s_1 \sim \expr{s_1}$ and $s_2 \sim \expr{s_2}$.

For another example, take the following partial automaton, also over a two letter alphabet $A=\{a,b\}$: $$\xymatrix{*++[o][F]{q_1} \ar[r]^{a}& *++[o][F]{q_2}
\ar@(r,u)[]_{b}}$$ In the graphical representation of a partial automaton $(S,p)$ we omit transitions for which $p(s)(a)
=\kappa_1(*)$. In this case, this happens in $q_1$ for the input letter $b$ and in $q_2$ for $a$.

We will have the equations $$\begin{array}{l}
A_1 = A^0_1 = A^1_1 =  \mu x_1  . b(l[*]) \oplus a(r[x_2]) \\[1ex]
A_2 = A^0_2 = A^1_2 =  \mu x_2  . a(l[*]) \oplus b(r[x_2])
\end{array}$$ Thus: $$\begin{array}{l}
\expr{s_1} = A^2_1 = \mu x_1 . \, b(l[*]) \oplus a(r[\mu x_2 . \,
a(l[*]) \oplus b(r[x_2])])\\
\expr{s_2} = \mu x_2  . a(l[*]) \oplus b(r[x_2])
\end{array}$$ Again we have $s_1 \sim \expr{s_1}$ and $s_2 \sim \expr {s_2}$.

As a last example, let us consider the following nondeterministic automaton, over a one letter alphabet $A=\{a\}$: $$\xymatrix{
*++[o][F]{s_1} \ar@(l,u)[]^{a}\ar@/^/[dr]^{a}\ar[rr]^{a}&& *++[o][F]{s_2}\ar@(r,u)[]_{a} \ar[dl]_{a} \\
&*++[o][F=]{s_3}\ar@(r,d)[]^{a}\ar@/^/[ul]^{a}&}$$ We start with the equations: $$\begin{array}{lcl}
A_1&=&\mu x_1. l<0> \oplus r<a(\{x_1\} \oplus \{x_2\} \oplus \{x_3\})>\\
A_2&=&\mu x_2. l<0> \oplus r<a( \{x_2\} \oplus \{x_3\})>\\
A_3&=&\mu x_3. l<1> \oplus r<a(\{x_1\} \oplus \{x_3\})>
\end{array}$$ Then we have the following iterations: $$\begin{array}{l}
A_1^1 = A_1\\[1ex]
A_1^2 = A_1 \{A_2^1/x_2\} = \mu x_1. l<0> \oplus r<a(\{x_1\} \oplus \{A_2\} \oplus \{x_3\})>\\[1ex]
A_1^3 = A_1 \{A_2^1/x_2\} \{A_3^2/x_3\} =  \mu x_1. l<0> \oplus r<a(\{x_1\} \oplus \{(A_2\{A_3^2/x_3\})\} \oplus \{A_3^2\})>\\
\\
A_2^1 =  A_2 \{A_1/x_1\} = A_2\\[1ex]
A_2^2 = A_2 \{A_1/x_1\} = A_2\\[1ex]
A_2^3 = A_2 \{A_1/x_1\}\{A_3^2/x_3\} = \mu x_2. l<0> \oplus r<a( \{x_2\} \oplus \{A_3^2\})>\\
\\
A_3^1 = A_3  \{A_1/x_1\} = \mu x_3. l<1> \oplus r<a(\{A_1\} \oplus \{x_3\})>\\[1ex]
A_3^2 = A_3  \{A_1/x_1\}\{A_2^1/x_2\} = \mu x_3. l<1> \oplus r<a(\{(A_1\{A_2^1/x_2\}) \} \oplus \{x_3\})>\\[1ex]
A_3^3 = A_3^2\\
\end{array}$$ This yields the following expressions: [$$\begin{array}{@{}l}
\expr{s_1} =  \mu x_1. l<0> \oplus r<a(\{x_1\} \oplus \{\expr{s_2}\} \oplus \{\expr{s_3}\})>\\
\expr{s_2} = \mu x_2. l<0> \oplus r<a( \{x_2\} \oplus \{\expr{s_3}\})>\\ 
\expr{s_3} = \mu x_3. l<1> \oplus r<a(\{ \mu x_1. l<0> \oplus r<a(\{x_1\} \oplus \{\mu x_2. l<0> \oplus r<a( \{x_2\} \oplus \{x_3\})>\} \oplus \{x_3\})> \} \oplus \{x_3\})>\\
\end{array}$$ ]{}

Finite systems for expressions {#sec:synthesis}
------------------------------

Next, we prove the converse of Theorem \[kleene1\], that is, we show how to construct a *finite* ${\mathcal{G}}$-coalgebra $(S,g)$ from an arbitrary expression ${\varepsilon}\in{\mathsf{Exp}}_{\mathcal{G}}$, such that there exists a state $s\in S$ with ${\varepsilon}\sim_{\mathcal{G}}s$.

The immediate way of obtaining a coalgebra from an expression ${\varepsilon}\in {\mathsf{Exp}}_{\mathcal{G}}$ is to compute the subcoalgebra $<{\varepsilon}>$, since we have provided the set ${\mathsf{Exp}}_{\mathcal{G}}$ with a coalgebra structure $\delta_{\mathcal{G}}\colon {\mathsf{Exp}}_{\mathcal{G}}\to {\mathcal{G}}({\mathsf{Exp}}_{\mathcal{G}})$. However, the subcoalgebra generated by an expression ${\varepsilon}\in {\mathsf{Exp}}_{\mathcal{G}}$ by repeatedly applying $\delta_{\mathcal{G}}$ is, in general, infinite. Take for instance the deterministic expression ${\varepsilon}_1 = \mu x.\, r<a(x \oplus \mu y.\,
r<a(y)>)>$ (for simplicity, we consider $A=\{a\}$ and below we will write, in the second component of $\delta_{\mathcal{D}}$, an expression ${\varepsilon}$ instead of the function mapping $a$ to ${\varepsilon}$) and observe that:

As one would expect, all the new states are equivalent and will be identified by $\mathbf{beh}$ (the morphism into the final coalgebra). However, the function $\delta_{\mathcal{D}}$ does not make any state identification and thus yields an infinite coalgebra.

This phenomenon occurs also in classical regular expressions. It was shown in [@Brz64] that normalizing the expressions using the axioms for associativity, commutativity and idempotency was enough to guarantee finiteness[^2]. We will show in this section that this also holds in our setting.

Consider the following axioms (only the first three are essential, but we include the fourth to obtain smaller coalgebras): $$\begin{array}{llll}
\mathit{(Associativity)} &  {\varepsilon}_1 \oplus ({\varepsilon}_2 \oplus {\varepsilon}_3)  \equiv
({\varepsilon}_1 \oplus
{\varepsilon}_2) \oplus {\varepsilon}_3\\
\mathit{(Commutativity)} &  {\varepsilon}_1 \oplus {\varepsilon}_2  \equiv {\varepsilon}_2 \oplus
{\varepsilon}_1\\
\mathit{(Idempotency)}   &  {\varepsilon}\oplus {\varepsilon}\equiv {\varepsilon}\\
\mathit{(Empty)}        &   {\underline\emptyset}\oplus {\varepsilon}\equiv {\varepsilon}\end{array}$$ We define the relation $\equiv_{\mathit{ACIE}} \subseteq {\mathsf{Exp}}_{{\mathcal{F}}\lhd
{\mathcal{G}}}\times {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$, written infix, as the least equivalence relation containing the four identities above. The relation $\equiv_{\mathit{ACIE}}$ gives rise to the (surjective) equivalence map $[{\varepsilon}]_{\mathit{ACIE}} = \{{\varepsilon}'\mid {\varepsilon}\equiv_{\mathit{ACIE}}
{\varepsilon}'\}$. The following diagram shows the maps defined so far: $$\xymatrix{
{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}\ar[d]_{\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}} \ar[rr]^-{[-]_{\mathit{ACIE}}}
&&
{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv_{\mathit{ACIE}}}\\
{\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{G}}})\ar[rr]_-{{\mathcal{F}}([-]_{\mathit{ACIE}})} && {\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv_{\mathit{ACIE}}}) 
}$$ In order to complete the diagram, we next prove that $\equiv_{\mathit{ACIE}}$ is contained in the kernel of ${\mathcal{F}}([-]_{\mathit{ACIE}}) \circ \delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$[^3].

This will guarantee the existence of a function $$\overline{\delta}_{{\mathcal{F}}\lhd
{\mathcal{G}}}\colon
{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv_{\mathit{ACIE}}} \to
{\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv_{\mathit{ACIE}}})$$ which, when ${\mathcal{F}}={\mathcal{G}}$, provides ${\mathsf{Exp}}_{\mathcal{G}}/_\equiv$ with a coalgebraic structure $$\overline{\delta}_{\mathcal{G}}\colon
{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv_{\mathit{ACIE}}} \to
{\mathcal{G}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv_{\mathit{ACIE}}})$$ (as before we write $\overline{\delta}_{\mathcal{G}}$ for $\overline{\delta}_{{\mathcal{G}}\lhd {\mathcal{G}}}$) and which makes $[-]_{\mathit{ACIE}}$ a homomorphism of coalgebras.

\[lemma:equivACIE\] Let ${\mathcal{G}}$ and ${\mathcal{F}}$ be nondeterministic functors, with ${\mathcal{F}}\lhd {\mathcal{G}}$. For all ${\varepsilon}_1,{\varepsilon}_2\in {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$, $${\varepsilon}_1\equiv_{\mathit{ACIE}} {\varepsilon}_2 \Rightarrow ({\mathcal{F}}([-]_{\mathit{ACIE}})) (\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}({\varepsilon}_1)) = ({\mathcal{F}}([-]_{\mathit{ACIE}})) (\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}({\varepsilon}_2))$$

In order to improve readability, in this proof we will use $[-]$ to denote $[-]_{\mathit{ACIE}}$.

It is enough to prove that for all $x_1, x_2, x_3 \in
{\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{G}}})$:

-   ${\mathcal{F}}([-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}({\mathsf{Plus}}_{{\mathcal{F}}\lhd
    {\mathcal{G}}}(x_1, x_2),x_3)) = {\mathcal{F}}([-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd
    {\mathcal{G}}}(x_1,{\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}(x_2,x_3)))$

-   ${\mathcal{F}}([-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd
    {\mathcal{G}}}(x_1,x_2))= {\mathcal{F}}([-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}(x_2,x_1))$

-   ${\mathcal{F}}([-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd
    {\mathcal{G}}}(x_1,x_1))={\mathcal{F}}([-])(x_1)$

-   ${\mathcal{F}}([-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}( {\mathsf{Empty}}_{{\mathcal{F}}\lhd
    {\mathcal{G}}},x_1)) ={\mathcal{F}}([-])(x_1)$

By induction on the structure of ${\mathcal{F}}$. We illustrate a few cases, the omitted ones are proved in a similar way.

$x_1, x_2, x_3\in {\mathsf{Exp}}_{{\mathcal{G}}}$

$$\begin{array}{@{}llll}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}&&[{\mathsf{Plus}}_{{\mathsf{Id}}\lhd {\mathcal{G}}}({\mathsf{Plus}}_{{\mathsf{Id}}\lhd
{\mathcal{G}}}(x_1,x_2),x_3)]\\ &=& [(x_1 \oplus x_2) \oplus x_3] & \text{(def.
${\mathsf{Plus}}$)}\\
&=& [x_1 \oplus (x_2 \oplus x_3)] &\text{($\mathit{Associativity}$)}\\
  &=& [{\mathsf{Plus}}_{{\mathsf{Id}}\lhd
{\mathcal{G}}}(x_1,{\mathsf{Plus}}_{{\mathsf{Id}}\lhd
{\mathcal{G}}}(x_2,x_3))]  &\text{(def.
${\mathsf{Plus}}$)}\\[1.5ex]
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {4};
  \end{tikzpicture}}&& [{\mathsf{Plus}}_{{\mathsf{Id}}\lhd {\mathcal{G}}}( {\mathsf{Empty}}_{{\mathsf{Id}}\lhd
{\mathcal{G}}},x_1) ] \\
&=&[{\underline\emptyset}\oplus x_1] &\text{(def.
${\mathsf{Plus}}$ and ${\mathsf{Empty}}$)}\\
 &=& [x_1] &\text{(${\mathsf{Empty}}$)}
\end{array}$$

$x_1 = <u_1,v_1>, x_2 =
<u_2,v_2> \in ({\mathcal{F}}_1\times
{\mathcal{F}}_2)({\mathsf{Exp}}_{{\mathcal{G}}})$ $$\begin{array}{@{}llll}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}&&({\mathcal{F}}_1\times {\mathcal{F}}_2) ([-])({\mathsf{Plus}}_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd
{\mathcal{G}}}(<u_1,v_1>,<u_2,v_2>))\\
&= & <{\mathcal{F}}_1 ([-])({\mathsf{Plus}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}}(u_1,u_2)),{\mathcal{F}}_2 ([-])({\mathsf{Plus}}_{{\mathcal{F}}_2\lhd
{\mathcal{G}}}(v_1,v_2))>&\text{(def. ${\mathsf{Plus}}$)}\\
&=&<{\mathcal{F}}_1 ([-])({\mathsf{Plus}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}}(u_2,u_1)),{\mathcal{F}}_2 ([-])({\mathsf{Plus}}_{{\mathcal{F}}_2\lhd
{\mathcal{G}}}(v_2,v_1))>&\text{(ind. hyp.)}\\
&=& ({\mathcal{F}}_1\times {\mathcal{F}}_2)([-])({\mathsf{Plus}}_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd
{\mathcal{G}}}(<u_2,v_2>,<u_1,v_1>)) &\text{(def. ${\mathsf{Plus}}$)}\\[1.5ex]
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {3};
  \end{tikzpicture}}&&({\mathcal{F}}_1\times {\mathcal{F}}_2)([-])({\mathsf{Plus}}_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd
{\mathcal{G}}}(<u_1,v_1>,<u_1,v_1>)) \\
&= & <{\mathcal{F}}_1 ([-])({\mathsf{Plus}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}}(u_1,u_1)),{\mathcal{F}}_2 ([-])({\mathsf{Plus}}_{{\mathcal{F}}_2\lhd
{\mathcal{G}}}(v_1,v_1))>&\text{(def. ${\mathsf{Plus}}$)}\\
&=&<{\mathcal{F}}_1 ([-])(u_1), {\mathcal{F}}_2 ([-])(v_1)>&\text{(ind. hyp.)}\\
&=& ({{\mathcal{F}}_1\times {\mathcal{F}}_2})([-])(<u_1,v_1>) & 
\end{array}$$

$x_1, x_2, x_3 \in \pow {\mathcal{F}}_1({\mathsf{Exp}}_{{\mathcal{G}}})$ $$\begin{array}{p{.5cm}cll}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}&&\pow {\mathcal{F}}_1 ([-])({\mathsf{Plus}}_{\pow {\mathcal{F}}_1\lhd {\mathcal{G}}}(x_1,{\mathsf{Plus}}_{\pow {\mathcal{F}}_1\lhd
{\mathcal{G}}}(x_2,x_3)))\\
&=& \pow {\mathcal{F}}_1 ([-])(x_1\cup(x_2\cup x_3))&\text{(def. ${\mathsf{Plus}}$)}\\
&=& \pow {\mathcal{F}}_1 ([-])((x_1\cup x_2)\cup x_3)&\\
&=& \pow {\mathcal{F}}_1 ([-])({\mathsf{Plus}}_{\pow {\mathcal{F}}_1\lhd {\mathcal{G}}}({\mathsf{Plus}}_{\pow {\mathcal{F}}_1\lhd
{\mathcal{G}}}(x_1,x_2),x_3))&\text{(def. ${\mathsf{Plus}}$)}\\
\end{array}$$ In the last but one step, we use the fact that, for any set $X$, $(\pow(X), \cup, \emptyset)$ is a joinsemilattice (hence, $x_1\cup(x_2\cup x_3)=(x_1\cup x_2)\cup x_3$). Due to this fact, in the case ${\mathcal{F}}=\pow {\mathcal{F}}_1$, in this particular proof, the induction hypothesis will not be used. Thus, we have a well-defined function $$\overline{\delta}_{{\mathcal{F}}\lhd
{\mathcal{G}}}\colon{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv_{\mathit{ACIE}}}\to {\mathcal{F}}(
{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv_{\mathit{ACIE}}})$$ such that $\overline{\delta}_{{\mathcal{F}}\lhd
{\mathcal{G}}} ([{\varepsilon}]_{\mathit{ACIE}}) = ({\mathcal{F}}[-]_{\mathit{ACIE}})({\delta}_{{\mathcal{F}}\lhd
{\mathcal{G}}} ({\varepsilon}))$.

We are ready to state and prove the second half of Kleene’s theorem.

\[kleene2\] Let ${\mathcal{G}}$ be a nondeterministic functor. For every ${\varepsilon}\in {\mathsf{Exp}}_{\mathcal{G}}$, there exists $\Delta_{\mathcal{G}}({\varepsilon})=(S,g)$ such that $S$ is finite and there exists $s\in
S$ with ${\varepsilon}\sim s$.

For every ${\varepsilon}\in  {\mathsf{Exp}}_{\mathcal{G}}$, we set $\Delta_{\mathcal{G}}({\varepsilon}) =
<[{\varepsilon}]_{\mathit{ACIE}}>$ (recall that $<s>$ denotes the smallest subcoalgebra generated by $s$). First note that, by Lemma \[lemma:equivACIE\], the map $[-]_\mathit{ACIE}$ is a homomorphism and thus ${\varepsilon}\sim [{\varepsilon}]_\mathit{ACIE}$. We prove, for every ${\varepsilon}\in  {\mathsf{Exp}}_{\mathcal{G}}$, that the subcoalgebra $<[{\varepsilon}]_{\mathit{ACIE}}> =
(V, \overline\delta_{{\mathcal{G}}})$ has a finite state space $V$ (here, $ \overline\delta_{\mathcal{G}}$ actually stands for the restriction of $ \overline\delta_{\mathcal{G}}$ to $V$). Again, in order to improve readability, below we will use $[-]$ to denote $[-]_{\mathit{ACIE}}$.

More precisely, we prove, for all ${\varepsilon}\in  {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$, the following inclusion $$\label{eq:incl_kleene2}
V \subseteq \overline V = \{[{\varepsilon}_1\oplus \ldots \oplus {\varepsilon}_k] \mid
{\varepsilon}_1,\ldots,{\varepsilon}_k \in \mathit{cl}({\varepsilon}) \text{ all distinct}, {\varepsilon}_1,\ldots, {\varepsilon}_k
\in {\mathsf{Exp}}_{\mathcal{G}}\}$$ Here, if $k=0$ we take the sum above to be ${\underline\emptyset}$ and $\mathit{cl}({\varepsilon})$ denotes the smallest set containing all subformulas of ${\varepsilon}$ and the unfoldings of $\mu$ (sub)formulas, that is, the smallest subset satisfying: $$\begin{array}{lcllcl}
\mathit{cl}({\underline\emptyset}) &= &\{{\underline\emptyset}\}&\mathit{cl}(l[{\varepsilon}_1]) &=& \{l[{\varepsilon}_1]\}
\cup \mathit{cl}({\varepsilon}_1)\\
\mathit{cl}({\varepsilon}_1\oplus {\varepsilon}_2) &=&  \{{\varepsilon}_1\oplus{\varepsilon}_2\}\cup
\mathit{cl}({\varepsilon}_1)\cup \mathit{cl}({\varepsilon}_2)&\mathit{cl}(r[{\varepsilon}_1]) &=&
\{r[{\varepsilon}_1]\} \cup \mathit{cl}({\varepsilon}_1)\\
\mathit{cl}(\mu x. {\varepsilon}_1) &=& \{\mu x.\,{\varepsilon}_1\}\cup \mathit{cl}({\varepsilon}_1
[\mu x. {\varepsilon}_1/x]) & \mathit{cl}(a({\varepsilon}_1)) &=& \{a({\varepsilon}_1)\} \cup
\mathit{cl}({\varepsilon}_1)\\
\mathit{cl}(l<{\varepsilon}_1>) &=& \{l<{\varepsilon}_1>\} \cup \mathit{cl}({\varepsilon}_1)&\mathit{cl}(\{{\varepsilon}_1\}) &=& \{\{{\varepsilon}_1\}\} \cup
\mathit{cl}({\varepsilon}_1)
\\
\mathit{cl}(r<{\varepsilon}_1>) &=& \{r<{\varepsilon}_1>\} \cup
\mathit{cl}({\varepsilon}_1)\end{array}$$ Note that the set $\mathit{cl}({\varepsilon})$ is finite (the number of different unfoldings is finite) and has the property ${\varepsilon}\in
\mathit{cl}({\varepsilon})$.

We prove the inclusion in equation (\[eq:incl\_kleene2\]) in the following way. First, we observe that $[{\varepsilon}] \in \overline V$, because ${\varepsilon}\in \mathit{cl}({\varepsilon})$. Then, we prove that $(\overline V, \overline\delta_{\mathcal{G}})$ (again, $\overline\delta_{\mathcal{G}}$ actually stands for the restriction of $\overline\delta_{\mathcal{G}}$ to $\overline V$) is a subcoalgebra of $({\mathsf{Exp}}_{\mathcal{G}},\overline\delta_{\mathcal{G}})$. Thus, $V \subseteq \overline V$, since $V$, the state space of $<[{\varepsilon}]>$ is equal to the intersection of all subcoalgebras of $({\mathsf{Exp}}_{\mathcal{G}},\overline\delta_{\mathcal{G}})$ containing $[{\varepsilon}]$.

To prove that $(\overline V, \overline\delta_{\mathcal{G}})$ is a subcoalgebra we prove that, for ${\varepsilon}_1,\ldots, {\varepsilon}_k
\in {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$, $$\label{eq:kleene2_1_5}
{\varepsilon}_1,\ldots,{\varepsilon}_k \in \mathit{cl}({\varepsilon}) \text{ all distinct} \Rightarrow \overline\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}([{\varepsilon}_1\oplus\ldots \oplus {\varepsilon}_k]) \in {\mathcal{F}}(\overline V)$$ The intended result then follows by taking ${\mathcal{F}}={\mathcal{G}}$.

We first prove two auxiliary results, by induction on the structure of ${\mathcal{F}}$: $$\begin{array}{@{}cl}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}& ({\mathcal{F}}[-])({\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}}) \in {\mathcal{F}}(\overline
V)\\[1.2ex]
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}& ({\mathcal{F}}[-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}(u,v)) \in {\mathcal{F}}(\overline V)
\Leftrightarrow ({\mathcal{F}}[-])(u) \in {\mathcal{F}}(\overline V)\text{ and } ({\mathcal{F}}[-])(v) \in
{\mathcal{F}}(\overline V)
\end{array}$$ for $u,v\in {\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}})$.

$$\begin{array}{clr}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}& ({\mathcal{F}}[-])({\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}}) = [{\underline\emptyset}] \in \overline V\\[1.2ex]
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}& ({\mathcal{F}}[-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}(u,v)) = [u \oplus v]\in \overline
V  
\Leftrightarrow [u] \in \overline V\text{ and } [v] \in
\overline V& u,v\in {\mathsf{Exp}}_{\mathcal{G}}\end{array}$$ The right to left implication follows because, using the $(\mathit{Associativity})$, $(\mathit{Commutativity})$ and $(\mathit{Idempotency})$ axioms, we can rewrite $u\oplus v$ as ${\varepsilon}_1\oplus\ldots\oplus {\varepsilon}_k$, with all ${\varepsilon}_1,\ldots,{\varepsilon}_k \in \mathit{cl}({\varepsilon})$ distinct.

$$\begin{array}{@{}cl@{\ }r}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}& ({\mathsf{B}}[-])({\mathsf{Empty}}_{{\mathsf{B}}\lhd {\mathcal{G}}}) = \bot_{\mathsf{B}}\in {\mathsf{B}}(\overline
V)\\[1.2ex]
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}& ({\mathsf{B}}[-])({\mathsf{Plus}}_{{\mathsf{B}}\lhd {\mathcal{G}}}(u,v)) = u \vee v \in {\mathsf{B}}(\overline
V)
\Leftrightarrow u \in {\mathsf{B}}(\overline V)\text{ and } v \in
{\mathsf{B}}(\overline V)& u,v\in {\mathsf{B}}({\mathsf{Exp}}_{\mathcal{G}})= {\mathsf{B}}\end{array}$$ $$\begin{array}{@{}clr}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}& ({\mathcal{F}}_1\times {\mathcal{F}}_2 [-])({\mathsf{Empty}}_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}}) \\&=
<({\mathcal{F}}_1 [-])({\mathsf{Empty}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}}),({\mathcal{F}}_2 [-])({\mathsf{Empty}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}})> \in {\mathcal{F}}_1\times {\mathcal{F}}_2(\overline
V)\\[1.2ex]
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}& ({\mathcal{F}}_1\times {\mathcal{F}}_2 [-])({\mathsf{Plus}}_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd
{\mathcal{G}}}(<u_1,u_2>,<v_1,v_2>))= 
\\
&<({\mathcal{F}}_1 [-])({\mathsf{Plus}}_{{\mathcal{F}}_1 \lhd
{\mathcal{G}}}(u_1,v_1)), ({\mathcal{F}}_2 [-])({\mathsf{Plus}}_{{\mathcal{F}}_2\lhd
{\mathcal{G}}}(u_2,v_2))>  \in {\mathcal{F}}_1\times {\mathcal{F}}_2(\overline
V)\\ &
\stackrel{\mathit{(IH)}}\Leftrightarrow u_1,v_1 \in {\mathcal{F}}_1(\overline V)
\text{ and } u_2,v_2 \in {\mathcal{F}}_2(\overline V) \\ & 
\Leftrightarrow <u,v> \in
{\mathcal{F}}_1\times {\mathcal{F}}_2(\overline V),\ \ \ u=<u_1,u_2>,v=<v_1,v_2>\in {\mathcal{F}}_1\times {\mathcal{F}}_2({\mathsf{Exp}}_{\mathcal{G}})
\end{array}$$ and : similar to ${\mathcal{F}}_1\times {\mathcal{F}}_2$.

 \
$$\begin{array}{@{}clr}
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}& (\pow {\mathcal{F}}[-])({\mathsf{Empty}}_{\pow {\mathcal{F}}\lhd {\mathcal{G}}}) = \emptyset
 \in \pow {\mathcal{F}}(\overline
V)\\[1.2ex]
{  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}& (\pow {\mathcal{F}}[-])({\mathsf{Plus}}_{\pow {\mathcal{F}}\lhd
{\mathcal{G}}}(u,v))= 
((\pow {\mathcal{F}}[-]) (u) \cup (\pow {\mathcal{F}}[-])(v))\in \pow {\mathcal{F}}(\overline V) \\ &
\Leftrightarrow (\pow {\mathcal{F}}[-] (u))\in \pow {\mathcal{F}}(\overline V)
\text{ and } (\pow {\mathcal{F}}[-] (v))\in \pow {\mathcal{F}}(\overline V) \end{array}$$ Using ${  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}$, we can simplify our proof goal (equation (\[eq:kleene2\_1\_5\])) as follows: $$\overline\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}([{\varepsilon}_1\oplus\ldots \oplus {\varepsilon}_k]) \in {\mathcal{F}}(\overline V)
\Leftrightarrow ({\mathcal{F}}[-])(\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}({\varepsilon}_i)) \in {\mathcal{F}}(\overline V), \ {\varepsilon}_i\in \mathit{cl}({\varepsilon}),\ i=1,\ldots,k$$ Next, using induction on the product of types of expressions and expressions (using the order in equation (\[ind:order5\])), ${  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {1};
  \end{tikzpicture}}$ and ${  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {2};
  \end{tikzpicture}}$, we prove that $({\mathcal{F}}[-])(\delta_{{\mathcal{F}}\lhd
{\mathcal{G}}}({\varepsilon}_i)) \in {\mathcal{F}}(\overline V)$, for any ${\varepsilon}_i\in \mathit{cl}({\varepsilon})$.

  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------
  $({\mathcal{F}}[-])(\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}  ({\underline\emptyset})) = ({\mathcal{F}}[-])({\mathsf{Empty}}_{{\mathcal{F}}\lhd                                                                                                                         $(\text{by }{  \begin{tikzpicture}[baseline=(C.base)]
  {\mathcal{G}}})\in {\mathcal{F}}(\overline V)$                                                                                                                                                                                                                              \node[draw,circle,inner sep=1pt](C) {1};
                                                                                                                                                                                                                                                                            \end{tikzpicture}})$

  \[1.1ex\] $({\mathcal{F}}[-])(\overline\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}  ({\varepsilon}_1\oplus{\varepsilon}_2))                                                                                                                                                $(\text{$\mathit{IH}$ and }{  \begin{tikzpicture}[baseline=(C.base)]
  = ({\mathcal{F}}[-])({\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}(\delta_{{\mathcal{F}}\lhd                                                                                                                                                                            \node[draw,circle,inner sep=1pt](C) {2};
  {\mathcal{G}}}  ({\varepsilon}_1), \delta_{{\mathcal{F}}\lhd {\mathcal{G}}}  ({\varepsilon}_2))\in {\mathcal{F}}(\overline V)$                                                                                                                                            \end{tikzpicture}})$

  \[1.1ex\] $({\mathcal{G}}[-])(\delta_{{\mathcal{G}}\lhd {\mathcal{G}}}  (\mu x. {\varepsilon})) = ({\mathcal{G}}[-])(\delta_{{\mathcal{G}}\lhd {\mathcal{G}}} ({\varepsilon}[\mu x.                                                                                     $(\text{$\mathit{IH}$})$
  {\varepsilon}/x]))\in {\mathcal{G}}(\overline V)$                                                                                                                                                                                                                       

  \[1.1ex\] $({\mathsf{Id}}[-])(\delta_{{\mathsf{Id}}\lhd {\mathcal{G}}}({\varepsilon}_i)) = [{\varepsilon}_i]\in {\mathsf{Id}}(\overline V) \ \ \textrm{for} \ {\mathcal{G}}\neq                                                                                         $({\varepsilon}_i\in \mathit{cl}({\varepsilon}))$
  {\mathsf{Id}}$                                                                                                                                                                                                                                                          

  \[1.1ex\] $({\mathsf{B}}[-])\delta_{{\mathsf{B}}\lhd {\mathcal{G}}} (b) = b\in {\mathsf{B}}(\overline V)$                                                                                                                                                               $({\mathsf{B}}(\overline
                                                                                                                                                                                                                                                                          V)={\mathsf{B}})$

  \[1.1ex\] $({\mathcal{F}}_1\times {\mathcal{F}}_2[-])(\delta_{{\mathcal{F}}_1\times {\mathcal{F}}_2 \lhd {\mathcal{G}}} (l<{\varepsilon}>))$                                                                                                                            

  $ \ = <                                                                                                                                                                                                                                                                 $(\text{$\mathit{IH}$ and }{  \begin{tikzpicture}[baseline=(C.base)]
  ({\mathcal{F}}_1[-])(\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon})), ({\mathcal{F}}_2 [-])({\mathsf{Empty}}_{{\mathcal{F}}_2\lhd                                                                                                                                \node[draw,circle,inner sep=1pt](C) {1};
  {\mathcal{G}}}) >\in                                                                                                                                                                                                                                                      \end{tikzpicture}})$
  {\mathcal{F}}_1\times {\mathcal{F}}_2(\overline V)$                                                                                                                                                                                                                     

  \[1.3ex\] $({\mathcal{F}}_1\times {\mathcal{F}}_2[-])(\delta_{{\mathcal{F}}_1\times {\mathcal{F}}_2 \lhd {\mathcal{G}}} (r<{\varepsilon}>))$                                                                                                                            

  $\ = <({\mathcal{F}}_1                                                                                                                                                                                                                                                  $(\text{$\mathit{IH}$ and }{  \begin{tikzpicture}[baseline=(C.base)]
  [-])({\mathsf{Empty}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}}),                                                                                                                                                                                                                 \node[draw,circle,inner sep=1pt](C) {1};
  ({\mathcal{F}}_2[-])(\delta_{{\mathcal{F}}_2\lhd {\mathcal{G}}}({\varepsilon})) >\in                                                                                                                                                                                      \end{tikzpicture}})$
  {\mathcal{F}}_1\times {\mathcal{F}}_2(\overline V)                                                                                                                                                                                                                      
  $                                                                                                                                                                                                                                                                       

  \[1.1ex\] $({\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2[-])(\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd {\mathcal{G}}} (l[{\varepsilon}])) =   $(\text{$\mathit{IH}$})$
  \kappa_1(({\mathcal{F}}_1[-])(\delta_{{\mathcal{F}}_1                                                                                                                                                                                                                   
  \lhd {\mathcal{G}}}({\varepsilon})))\in                                                                                                                                                                                                                                 
  {\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2(\overline V)$                                                                                                                                                         

  \[1.1ex\] $({\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2[-])(\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd {\mathcal{G}}} (r[{\varepsilon}])) =   $(\text{$\mathit{IH}$})$
  \kappa_2(({\mathcal{F}}_2[-])(\delta_{{\mathcal{F}}_2                                                                                                                                                                                                                   
  \lhd {\mathcal{G}}}({\varepsilon})))\in                                                                                                                                                                                                                                 
  {\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2(\overline V)                                                                                                                                                          
  $                                                                                                                                                                                                                                                                       

  \[1.1ex\] $({\mathcal{F}}^A[-])(\delta_{{\mathcal{F}}^A \lhd {\mathcal{G}}} (a({\varepsilon}))) = \left(\lambda a' .\left\{                                                                                                                                             $(\text{$\mathit{IH}$ and }{  \begin{tikzpicture}[baseline=(C.base)]
  \begin{array}{ll}({\mathcal{F}}[-])(\delta_{{\mathcal{F}}\lhd {\mathcal{G}}} ({\varepsilon}))                                                                                                                                                                               \node[draw,circle,inner sep=1pt](C) {1};
  &\text{if }a=a'\\{\mathsf{Empty}}_{{\mathcal{F}}\lhd                                                                                                                                                                                                                      \end{tikzpicture}})$
  {\mathcal{G}}}&\text{otherwise}\end{array}\right.\right)\in                                                                                                                                                                                                             
  {\mathcal{F}}^A(\overline V)                                                                                                                                                                                                                                            
  $                                                                                                                                                                                                                                                                       

  \[2.1ex\] $(\pow {\mathcal{F}}[-])(\delta_{\pow {\mathcal{F}}\lhd {\mathcal{G}}} (\{{\varepsilon}\})) = \{\,({\mathcal{F}}[-])(\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon}))\,\}\in                                                                          $(\text{$\mathit{IH}$})$
  \pow {\mathcal{F}}(\overline V)$                                                                                                                                                                                                                                        
  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------

### Examples {#sec:examples_synt}

n this subsection we will illustrate the construction described in the proof of Theorem \[kleene2\]: given an expression ${\varepsilon}\in {\mathsf{Exp}}_{\mathcal{G}}$ we construct a ${\mathcal{G}}$-coalgebra $(S,g)$ such that there is $s\in S$ with $s\sim {\varepsilon}$. For simplicity, we will consider deterministic and partial automata expressions over $A=\{a,b\}$.

Let us start by showing the synthesised automata for the most simple deterministic expressions – ${\underline\emptyset}$, $l<0>$ and $l<1>$. $$\xymatrix{*++[o][F]{{\underline\emptyset}} \ar@(r,u)[]_{a,b}} \ \ \
\xymatrix{*++[o][F]{l<0>} \ar[r]^{a,b}&  *++[o][F]{{\underline\emptyset}} \ar@(r,u)[]_{a,b}}
\ \ \ \xymatrix{*++[o][F=] {l<1>} \ar[r]^{a,b}&  *++[o][F]{{\underline\emptyset}}
\ar@(r,u)[]_{a,b}}$$ The first two automata recognize the empty language $\emptyset$ and the last the language $\{\epsilon \}$ containing only the empty word.

We note that the generated automata are not minimal (for instance, the automata for $l<0>$ and ${\underline\emptyset}$ are bisimilar). Our goal has been to generate a finite automaton from an expression. From this the minimal automaton can always be obtained by identifying bisimilar states.

The following automaton, generated from the expression $r<a(l<1>)>$, recognizes the language {a}, $$\xymatrix{ *+[F-:<3pt>]{r<a(l<1>)>} \ar[r]^-{a}\ar[dr]_{b}& *++[o][F=]{l<1>}
\ar[d]^{a,b}  \\
& *++[o][F]{{\underline\emptyset}}  \ar@(r,d)[]^{a,b}}$$ For an example of an expression containing fixed points, consider ${\varepsilon}=
\mu x.\, r<a(l<0>\oplus l<1>\oplus x)>$. One can easily compute the synthesised automaton: $$\xymatrix{*+[F-:<3pt>]{\mu x.\, r<a(l<0>\oplus l<1>\oplus x)>}
\ar[r]^-{a}\ar@/{}_{2 pc}/[rr]_{b}&
*+[F=:<3pt>]{{l<0>\oplus l<1>\oplus {\varepsilon}}} \ar@(r,u)[]_{a}\ar[r]^-{b} &
*++[o][F]{{\underline\emptyset}}  \ar@(r,d)[]^{a,b}}$$ and observe that it recognizes the language $aa^*$. Here, the role of the joinsemilattice structure is also visible: $l<0>\oplus l<1>\oplus
{\varepsilon}$ specifies that this state is supposed to be non-final ($l<0>$) and final ($l<1>$). The conflict of these two specifications is solved, when they are combined with $\oplus$, using the semilattice: because $1\vee 0 = 1$ the state is set to be final.

As a last example of deterministic expressions consider . Applying $\delta_{\mathcal{D}}$ to ${\varepsilon}_1$ one gets the following (partial) automaton: $$\xymatrix{*+[F-:<3pt>]{\mu
x.\, r<a(x \oplus \mu y.\, r<a(y)>)>}
\ar[r]^-{a}\ar@/{}_{2 pc}/[rr]_{b}&
*+[F-:<3pt>]{{\varepsilon}_1 \oplus \mu y.\, r<a(y)>}
&*++[o][F]{{\underline\emptyset}} }$$ Calculating $\delta_{\mathcal{D}}({\varepsilon}_1 \oplus \mu y.\, r<a(y)>)$ yields $$\begin{array}{lcl}
\delta_{\mathcal{D}}({\varepsilon}_1 \oplus \mu y.\, r<a(y)>)& =& <0,t>\\
&\text{where}& t(a) = {\varepsilon}_1 \oplus \mu y.\,
r<a(y)>\oplus \mu y.\, r<a(y)>>\\
&& t(b) = {\underline\emptyset}\end{array}$$ Note that the expression ${\varepsilon}_1 \oplus \mu y.\,
r<a(y)>\oplus \mu y.\, r<a(y)>$ is in the same equivalence class as ${\varepsilon}_1 \oplus \mu y.\, r<a(y)>$, which is a state that already exists. As we saw in the beginning of Section \[sec:expressions\_coalg\], by only applying $\delta_{\mathcal{D}}$, without $\mathit{ACI}$, one would always generate syntactically different states which instead of the automaton computed now: $$\xymatrix{*+[F-:<3pt>]{\mu
x.\,r< a(x \oplus \mu y.\, r<a(y)>)>}
\ar[r]^-{a}\ar@/{}_{2 pc}/[rr]_{b}& *+[F-:<3pt>]{
{\varepsilon}_1 \oplus \mu y.\, r<a(y)>}\ar@(r,u)[]_-{a}\ar[r]^-{b}
&*++[o][F]{{\underline\emptyset}} \ar@(r,d)[]^{a,b} }$$ would yield the following infinite automaton (with ${\varepsilon}_2 = \mu y.\,
r<a(y)>$): $$\xymatrix{*+[F-:<3pt>]{\mu
x.\, r<a(x \oplus \mu y.\, r<a(y)>)>} \ar[r]^-{a}\ar[dr]_{b}&
*+[F-:<3pt>]{{\varepsilon}_1 \oplus {\varepsilon}_2}\ar[r]^-{a}\ar[d]^{b}&
*+[F-:<3pt>]{{\varepsilon}_1 \oplus {\varepsilon}_2 \oplus {\varepsilon}_2}\ar[r]^-{a}\ar[dl]^{b}&\ldots\\
&*++[o][F]{{\underline\emptyset}} \ar@(r,d)[]^{a,b} &}$$ Let us next see a few examples of synthesis for partial automata expressions, where we will illustrate the role of $\bot$ and $\top$. In the graphical representation of a partial automaton $(S,p)$, we will omit transitions for inputs $a$ with $g(s)(a) = \kappa_1(*)$ and we will draw $\xymatrix{*++[o][F]{s} \ar@{~>}[r]^-{a}&
*++[F]{g(s)(a)}}$ whenever $g(s)(a)\in\{\bot,\top\}$. Note however that $\bot\not\in S$ and $\top\not\in S$ and thus will have no defined transitions. As before, let us first present the corresponding automata for simple expressions – ${\underline\emptyset}$, $a(l[*])$, $a({\underline\emptyset})$ and $a(l[*]) \oplus b(l[*])$. $$\xymatrix{*++[o][F]{{\underline\emptyset}} \ar@{~>}[r]^-{a,b}& *++[F]{\bot}} \ \ \
\xymatrix{*++[o][F]{a(l[*])} \ar@{~>}[r]^-{b}&  *++[F]{\bot }}
\ \ \ \xymatrix{*++[o][F] {a({\underline\emptyset})}
\ar[r]^-{a}\ar@{~>}@/^0.7cm/[rr]^-{b}&  *++[o][F]{{\underline\emptyset}} \ar@{~>}[r]^-{a,b}&
*++[F]{\bot}}\ \ \ \xymatrix{*+[F-:<3pt>]{a(l[*]) \oplus
b(l[*])} }$$ Note how $\bot$ is used to encode underspecification, working as a kind of deadlock state. In the first three expressions the behaviour for one or both of the inputs is missing, whereas in the last expression the specification is complete.

The element $\top$ is used to deal with inconsistent specifications. For instance, consider the expression $a(l[*])
\oplus b(l[*]) \oplus a(r[a(l[*]) \oplus b(l[*])])$. All inputs are specified, but note that at the outermost level input $a$ appears in two different sub-expressions – $a(l[*])$ and $a(r[a(l[*]) \oplus b(l[*])])$ – specifying at the same time that input $a$ leads to successful termination and that it leads to a state where $a(l[*]) \oplus b (l[*])$ holds, which is contradictory, giving rise to the following automaton. $$\xymatrix{*+[F-:<3pt>]{a(l[*]) \oplus b(l[*]) \oplus a(r[a(l[*])
\oplus b(l[*])])
} \ar@{~>}[r]^-{a}& *++[F]{\top}}$$

A sound and complete axiomatization {#sec:axiom}
===================================

In the previous section, we have shown how to derive from the type of a system, given by a functor ${\mathcal{G}}$, a language ${\mathsf{Exp}}_{\mathcal{G}}$ that allows for specification of ${\mathcal{G}}$-behaviours. Analogously to Kleene’s theorem, we have proved the correspondence between the behaviours denoted by ${\mathsf{Exp}}_{\mathcal{G}}$ and locally finite ${\mathcal{G}}$-coalgebras. In this section, we will show how to provide ${\mathsf{Exp}}_{\mathcal{G}}$ with a sound and complete axiomatization. Again, the functor ${\mathcal{G}}$ will serve as a main guide for the definition. The defined axiomatization is closely related to Kleene algebra (the set of expressions has a join semilattice structure) and to the axiomatization provided by Milner for CCS (uniqueness of fixed points will be required). When instantiating the definition below to concrete functors one will recover known axiomatizations, such as the one for CCS mentioned above or the one for labelled transition systems (with explicit termination) presented in [@AcetoH92]. The latter will be discussed in detail in Section \[sec:appl\].

Next, we introduce an equational system for expressions of type ${\mathcal{F}}\lhd {\mathcal{G}}$. We define the relation $\mathord{\equiv}\subseteq {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}\times {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$, written infix, as the least equivalence relation containing the following identities:

1.  $({\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}, \oplus, {\underline\emptyset})$ is a join-semilattice. $$\begin{aligned}
       &{\varepsilon}\oplus {\varepsilon}\equiv {\varepsilon}&& \mathit{(Idempotency)}\\
     &{\varepsilon}_1 \oplus {\varepsilon}_2  \equiv {\varepsilon}_2 \oplus {\varepsilon}_1 &&\mathit{(Commutativity)} \\
      &{\varepsilon}_1 \oplus ({\varepsilon}_2 \oplus {\varepsilon}_3)   \equiv ({\varepsilon}_1 \oplus
    {\varepsilon}_2) \oplus {\varepsilon}_3 && \mathit{(Associativity)} \\
     &{\underline\emptyset}\oplus {\varepsilon}\equiv {\varepsilon}&&\mathit{(Empty)}     \end{aligned}$$

2.  $\mu$ is the unique fixed point. $$\begin{aligned}
    &\gamma[\mu x.\gamma/x] \equiv \mu x . \gamma && \mathit{(FP)}  \\
    &{\gamma[{\varepsilon}/x]  \equiv  {\varepsilon}\Rightarrow \mu
    x.\gamma \equiv {\varepsilon}} &&\mathit{(Unique)}\end{aligned}$$

3.  The join-semilattice structure propagates through the expressions. $$\begin{array}{lcll@{\hspace{.5cm}}lcll}
    {\underline\emptyset}&\equiv& \bot_{\mathsf{B}}& ({\mathsf{B}}- {\underline\emptyset}) &  b_1 \oplus b_2 &\equiv& b_1 \vee_{\mathsf{B}}b_2
    &({\mathsf{B}}- \oplus)  \\
      l<{\underline\emptyset}> &\equiv& {\underline\emptyset}& (\times - {\underline\emptyset}- L) &   l<{\varepsilon}_1 \oplus {\varepsilon}_2>
    &\equiv& l<{\varepsilon}_1> \oplus l<{\varepsilon}_2> &(\times - \oplus - L)\\
     r<{\underline\emptyset}> &\equiv& {\underline\emptyset}&(\times - {\underline\emptyset}- R)  &
    r<{\varepsilon}_1 \oplus {\varepsilon}_2> &\equiv& r<{\varepsilon}_1> \oplus r<{\varepsilon}_2> &(\times - \oplus - R) 
    \\
      a({\underline\emptyset}) &\equiv& {\underline\emptyset}&(-^A - {\underline\emptyset})  &
      a({\varepsilon}_1 \oplus {\varepsilon}_2) &\equiv& a({\varepsilon}_1) \oplus a({\varepsilon}_2)&(-^A - \oplus)\\
    && &&  l[{\varepsilon}_1 \oplus {\varepsilon}_2] &\equiv& l[{\varepsilon}_1] \oplus l[{\varepsilon}_2] &(+ - \oplus - L) 
    \\ &&&&     r[{\varepsilon}_1 \oplus {\varepsilon}_2] &\equiv& r[{\varepsilon}_1] \oplus
    r[{\varepsilon}_2]&(+ - \oplus - R) \\
    & &&&  l[{\varepsilon}_1] \oplus r[{\varepsilon}_2] &\equiv& l[{\underline\emptyset}] \oplus r[{\underline\emptyset}]
    &{(+ - \oplus - \top)} 
    \end{array}$$

4.  $\equiv$ is a congruence. $$\begin{aligned}
    {\varepsilon}_1\equiv {\varepsilon}_2 \Rightarrow {\varepsilon}[{\varepsilon}_1/x]\equiv {\varepsilon}[{\varepsilon}_2/x]& \text{\ \ \ \
    for $x$ free in ${\varepsilon}$}&(\mathit{Cong})\end{aligned}$$

5.  $\alpha$-equivalence $$\begin{aligned}
    \mu x.\gamma \equiv \mu y. \gamma[y/x] &\ \ \   \text{ for 
    $y$  not free in $\gamma$}&& \mathit {(\alpha-\mathit{equiv})} \end{aligned}$$

It is important to remark that in the third group of rules there does not exist any rule applicable to expressions of type $\pow {\mathcal{F}}$.

Consider the nondeterministic automata over the alphabet $A=\{a\}$: $$\xymatrix{*++[o][F]{s_1}
\ar@(l,u)^-{a}}\hspace{2cm}\xymatrix{*++[o][F]{s_2} \ar@/^/[r]^-{a}&
*++[o][F]{s_3} \ar@/^/[l]^-{a}}$$ Applying $\expr -$ (as defined in the proof of Theorem \[kleene1\]) one can easily compute the expressions corresponding to $s_1$ and $s_2$: $$\begin{array}{l}
{\varepsilon}_1 = \expr{s_1} = \mu x_1. l<0> \oplus r<a(\{x_1\})>\\ 
{\varepsilon}_2 = \expr{s_2} = \mu y_1. l<0> \oplus r< a(\{\mu y_2. l<0> \oplus r<a(\{\mu y_1. l<0> \oplus r<a(\{y_2\})> \})>\})>
\end{array}$$ We prove that ${\varepsilon}_2\equiv {\varepsilon}_1$. In the following calculations let ${\varepsilon}= \mu x_1. r<a(\{x_1\})>$. $$\begin{array}{@{}lcll}
&& {\varepsilon}_2\equiv {\varepsilon}_1 \\
&\Leftrightarrow & r<a(\{\mu y_2. r<a(\{r<a(\{y_2\})>\})>\})>
\equiv {\varepsilon}& \text{($({\mathsf{B}}-{\underline\emptyset})$, $(\times - {\underline\emptyset}- L)$, $\mathit{(FP)}$ and $\mathit{(Empty)}$)}\\
&\Leftrightarrow& \mu y_2. r<a(\{r<a(\{y_2\})>\})> \equiv {\varepsilon}&\text{($(\mathit{FP})$ on ${\varepsilon}$ and $(\mathit{Cong})$ twice)}\\
&\Leftarrow &  r<a(\{r<a(\{{\varepsilon}\})>\})>  \equiv {\varepsilon}& \text{(uniqueness of fixed points)}
\\
&\Leftrightarrow &  r<a(\{{\varepsilon}\})> \equiv {\varepsilon}&\text{(fixed point axiom)}
\\
&\Leftrightarrow & {\varepsilon}\equiv {\varepsilon}&\text{(fixed point axiom)}\end{array}$$ Note that the $(\mathit{Cong})$ rule was used in almost every step.

For another example, consider the nondeterministic automaton over the alphabet $A=\{a,b\}$: $$\xymatrix{*++[o][F]{s_1} \ar[r]^-{a,b}& *++[o][F]{s_2} &
*++[o][F]{s_3}\ar[l]^-{a,b} \ar[r]^-{b}& *++[o][F]{s_4} }$$ Using the definition of $\expr -$ one can compute the following expressions for $s_1$, $s_2$, $s_3$ and $s_4$: $$\begin{array}{l}
{\varepsilon}_1 =  \expr{s_1} =\mu x_1. l<0> \oplus r<a(\{{\varepsilon}_2\})\oplus
b(\{{\varepsilon}_2\})> \\
{\varepsilon}_2 =\expr{s_2} = \mu x_2. l<0> \oplus {\underline\emptyset}\\
{\varepsilon}_3 = \expr{s_3} =\mu x_3. l<0> \oplus r< a(\{{\varepsilon}_2\}) \oplus
b(\{{\varepsilon}_2\}\oplus\{{\varepsilon}_4\})>\\
{\varepsilon}_4 = \expr{s_4} =\mu x_4. l<0> \oplus {\underline\emptyset}\\
\end{array}$$ For ${\varepsilon}_2$ we calculate: $$\begin{array}{lcll}
{\varepsilon}_2 &\equiv& l<0>\oplus {\underline\emptyset}& \text{($\mathit{FP}$)}\\
&\equiv& l<{\underline\emptyset}> &  \text{($\mathit{Empty}$) and (${\mathsf{B}}-
{\underline\emptyset}$)}\\
&\equiv& {\underline\emptyset}&  \text{($\times -
{\underline\emptyset}- L$)}
\end{array}$$ Similarly, one has that ${\varepsilon}_4\equiv {\underline\emptyset}$. Next, we prove ${\varepsilon}_1\equiv{\varepsilon}_3$: $$\hspace{-.3cm}\begin{array}{@{}lcll}
&& {\varepsilon}_1\equiv {\varepsilon}_3 \\
&\Leftrightarrow &l<0> \oplus r<a(\{{\varepsilon}_2\})\oplus b(\{{\varepsilon}_2\})>\equiv  l<0> \oplus r< a(\{{\varepsilon}_2\}) \oplus
b(\{{\varepsilon}_2\}\oplus\{{\varepsilon}_4\})> & \text{($\mathit{FP}$)}\\
&\Leftrightarrow& l<0> \oplus r<a(\{{\underline\emptyset}\})\oplus
b(\{{\underline\emptyset}\})>\equiv  l<0> \oplus r< a(\{{\underline\emptyset}\}) \oplus
b(\{{\underline\emptyset}\}\oplus\{{\underline\emptyset}\})> &\text{(${\varepsilon}_2\equiv
{\underline\emptyset}\equiv {\varepsilon}_4$)}\\
&\Leftrightarrow& l<0> \oplus r<a(\{{\underline\emptyset}\})\oplus
b(\{{\underline\emptyset}\})>\equiv  l<0> \oplus r< a(\{{\underline\emptyset}\}) \oplus
b(\{{\underline\emptyset}\})> &\text{($\mathit{Idempotency}$)}\\
\end{array}$$

The relation $\equiv$ gives rise to the (surjective) equivalence map $[-]\colon {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}} \to {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv}$ defined by $[{\varepsilon}] =
\{{\varepsilon}'\mid {\varepsilon}\equiv{\varepsilon}'\}$. The following diagram summarizes the maps we have defined so far: $$\xymatrix{
{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}\ar[d]_{\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}} \ar[r]^{[-]} &
{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv}\\
{\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}})\ar[r]_{{\mathcal{F}}([-])} & {\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}) 
}$$ In order to complete the diagram, we next prove that $\equiv$ is contained in the kernel of ${\mathcal{F}}([-]) \circ \delta_{{\mathcal{F}}\lhd {\mathcal{G}}}$. This will guarantee the existence of a well-defined function $$\partial_{{\mathcal{F}}\lhd
{\mathcal{G}}}\colon
{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv} \to {\mathcal{F}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv})$$ which, when ${\mathcal{F}}={\mathcal{G}}$, provides ${\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}$ with a coalgebraic structure $\partial_{\mathcal{G}}\colon
{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}\to {\mathcal{G}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv})$ (as before, we write $\partial_{\mathcal{G}}$ to abbreviate $\partial_{{\mathcal{G}}\lhd {\mathcal{G}}}$) and which makes $[-]$ a homomorphism of coalgebras.

\[lemma:h\_welldef\] Let ${\mathcal{G}}$ and ${\mathcal{F}}$ be nondeterministic functors, with ${\mathcal{F}}\lhd {\mathcal{G}}$. For all ${\varepsilon}_1,{\varepsilon}_2\in {\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$ with ${\varepsilon}_1\equiv{\varepsilon}_2$, $${\mathcal{F}}([-])\circ
\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon}_1) = {\mathcal{F}}([-])\circ
\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon}_2)$$

By induction on the length of derivations of $\equiv$.

First, let us consider derivations of length 1. We need to prove the result for all the axioms in items $1.$ and $3.$ plus the axioms $\mathit{FP}$ and $(\alpha-\mathit{equiv})$.

For the axioms in $1.$ the result follows by Lemma \[lemma:equivACIE\]. The axiom $\mathit{FP}$ follows trivially because of the definition of $\delta_{{\mathcal{G}}}$, since $\delta_{{\mathcal{G}}}(\mu x . \gamma) =
\delta_{{\mathcal{G}}}(\gamma[\mu x.\gamma/x])$ and thus ${\mathcal{G}}([-]) \circ
\delta_{\mathcal{G}}(\mu x . \gamma)= {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\gamma[\mu x.\gamma/x])$.

For the axiom $(\alpha-\mathit{equiv})$ we use the $(\mathit{Cong})$ rule, which is proved below: $$\begin{array}{@{}l@{\ }ll}
&{\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\mu x.\gamma) \\
=& {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\gamma[\mu
x.\gamma/x]) & \text{(def. of $\delta_{\mathcal{G}}$)}\\
=&  {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\gamma[\mu
y.\gamma[y/x]/x])&\text{(by $(\mathit{Cong})$)}\\
=& {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\gamma[y/x][\mu
y.\gamma[y/x]/y])& \text{\small($A[B[y/x]/x] = A[y/x][B[y/x]/y]$, $y$ not
free in $\gamma$)}\\
=& {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\mu y. \gamma[y/x])) & \text{(def. of ${\mathcal{G}}([-])\circ \delta_{\mathcal{G}}$)}
\end{array}$$

Let us next show the proof for some of the axioms in $3.$. The omitted cases are similar. We show for each axiom ${\varepsilon}_1\equiv {\varepsilon}_2$ that $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}} ({\varepsilon}_1)=\delta_{{\mathcal{F}}\lhd {\mathcal{G}}} ({\varepsilon}_2)$.

[@ll]{} &\
$
\delta_{{\mathsf{B}}\lhd {\mathcal{G}}}(\bot_{\mathsf{B}})
= \bot_{\mathsf{B}}= \delta_{{\mathsf{B}}\lhd {\mathcal{G}}}({\underline\emptyset})
$ & $\delta_{{\mathsf{B}}\lhd {\mathcal{G}}}(b_1\vee_{\mathsf{B}}b_2)
= b_1\vee_{\mathsf{B}}b_2
= \delta_{{\mathsf{B}}\lhd {\mathcal{G}}}(b_1\oplus b_2)
$\
\
\
\
\
\
\
\
\
\
&\
$
\begin{array}{@{}c@{\ }l}
&\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}(l[{\varepsilon}_1\oplus{\varepsilon}_2])\\
=
&\kappa_1(\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon}_1\oplus{\varepsilon}_2))\\
 =& {\mathsf{Plus}}_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}(\kappa_1(\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon}_1)),
\kappa_1(\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon}_2))\\
=&
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}(l[{\varepsilon}_1]\oplus l[{\varepsilon}_2])
\end{array}$& $
\begin{array}{@{}c@{\ }l}
&\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}(l[{\varepsilon}_1]\oplus r[{\varepsilon}_2])\\
=& {\mathsf{Plus}}_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}(\kappa_1(\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon}_1)),
\kappa_2(\delta_{{\mathcal{F}}_2\lhd {\mathcal{G}}}({\varepsilon}_2)))\\
=&\top\\
=& {\mathsf{Plus}}_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}(\kappa_1(\delta_{{\mathcal{F}}_1\lhd
{\mathcal{G}}}({\underline\emptyset})),
\kappa_2(\delta_{{\mathcal{F}}_2\lhd {\mathcal{G}}}({\underline\emptyset})))\\
=&
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}(l[{\underline\emptyset}]\oplus r[{\underline\emptyset}])
\end{array}$

Note that if we would have the axioms $l[{\underline\emptyset}] \equiv {\underline\emptyset}$ and $r[{\underline\emptyset}] \equiv {\underline\emptyset}$ in the axiomatization presented above, this theorem would not hold. $$\begin{array}{l}
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}(l[{\underline\emptyset}])
=\kappa_1([\bot])
\neq 
\bot 
=
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}({\underline\emptyset})\\
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}(r[{\underline\emptyset}])
=\kappa_2([\bot])
\neq 
\bot 
=
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}({\underline\emptyset})

\end{array}$$ Derivations with length $k\gr1$ can be obtained by two rules: $(\mathit{Unique})$ or $(\mathit{Cong})$. For the first (which uses the second), suppose that we have derived $\mu
x.\gamma \equiv {\varepsilon}$ and that we have already proved $\gamma[{\varepsilon}/x] \equiv
{\varepsilon}$. Then, we have: $$\begin{array}{@{}lcll}
{\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\mu x.\gamma) 
&=& {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\gamma [\mu x.\gamma/x]) &\text{(def. $\delta_{\mathcal{G}}$)}\\
&=& {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}(\gamma [{\varepsilon}/x]) &\text{(by $(\mathit{Cong})$)}\\
&{=}& {\mathcal{G}}([-])\circ \delta_{\mathcal{G}}({\varepsilon})&\text{(induction hypothesis)}
\end{array}$$ For $(\mathit{Cong})$, suppose that we have derived ${\varepsilon}[{\varepsilon}_1/x] \equiv {\varepsilon}[{\varepsilon}_2/x_2]$ and that we have already derived ${\varepsilon}_1\equiv {\varepsilon}_2$, which gives us, as induction hypothesis, the equality $$\label{eq:ind}
({\mathcal{F}}[-])(\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon}_1))=({\mathcal{F}}[-])(\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon}_2))$$ This equation is precisely what we need to prove the case ${\varepsilon}=x$ (and thus ${\varepsilon}_1,{\varepsilon}_2:{\mathcal{G}}\lhd {\mathcal{G}}$): $$\begin{array}{lcll}
({\mathcal{G}}[-])(\delta_{{\mathcal{G}}}(x[{\varepsilon}_1/x] ) &=& ({\mathcal{G}}[-])(\delta_{{\mathcal{G}}}({\varepsilon}_1))\\
&=& ({\mathcal{G}}[-])(\delta_{{\mathcal{G}}}({\varepsilon}_2)) &\text{(\ref{eq:ind})} \\
&=& ({\mathcal{G}}[-])(\delta_{{\mathcal{G}}}(x[{\varepsilon}_2/x]))
\end{array}$$ For the cases ${\varepsilon}\neq x$, we prove that $\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon}[{\varepsilon}_1/x]) =
\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon}[{\varepsilon}_2/x])$, by induction on the product of types of expressions and expressions (using the order defined in equation (\[ind:order5\])). We show a few cases, the omitted ones are similar. $$\begin{array}{@{}lcl}
\delta_{{\mathcal{G}}\lhd {\mathcal{G}}}  ((\mu y. {\varepsilon})[{\varepsilon}_1/x]) &=& \delta_{{\mathcal{G}}\lhd {\mathcal{G}}}
({\varepsilon}[{\varepsilon}_1/x][\mu y.
{\varepsilon}/y]))\\
& \stackrel{\mathit{(IH)}}=& \delta_{{\mathcal{G}}\lhd {\mathcal{G}}}
({\varepsilon}[{\varepsilon}_2/x][\mu y.
{\varepsilon}/y]))= \delta_{{\mathcal{G}}\lhd {\mathcal{G}}}  ((\mu y. {\varepsilon})[{\varepsilon}_2/x])\\[1.1ex]
\delta_{{\mathcal{F}}_1\times {\mathcal{F}}_2 \lhd {\mathcal{G}}} (l<{\varepsilon}>[{\varepsilon}_1/x]) &=& <
\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon}[{\varepsilon}_1/x]), {\mathsf{Empty}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}} >\\&
\stackrel{\mathit{(IH)}}=& <
\delta_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\varepsilon}[{\varepsilon}_2/x]), {\mathsf{Empty}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}} >
=\delta_{{\mathcal{F}}_1\times {\mathcal{F}}_2 \lhd {\mathcal{G}}} (l<{\varepsilon}>[{\varepsilon}_2/x])\\[1.1ex]
\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd {\mathcal{G}}} (l[{\varepsilon}][{\varepsilon}_1/x])& =&
\kappa_1(\delta_{{\mathcal{F}}_1
\lhd {\mathcal{G}}}({\varepsilon}[{\varepsilon}_1/x]))\\&\stackrel{(\mathit{IH})}= &\kappa_1(\delta_{{\mathcal{F}}_1
\lhd {\mathcal{G}}}({\varepsilon}[{\varepsilon}_2/x]))=\delta_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd {\mathcal{G}}} (l[{\varepsilon}][{\varepsilon}_2/x])
\end{array}$$ Thus, we have a well-defined function $\partial_{{\mathcal{F}}\lhd
{\mathcal{G}}}\colon{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv}\to
{\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{G}}}/_{\equiv})$, which makes the diagram above commute, that is $\partial_{{\mathcal{F}}\lhd {\mathcal{G}}}([{\varepsilon}]) = ({\mathcal{F}}[-])\circ
\delta_{{\mathcal{F}}\lhd {\mathcal{G}}}({\varepsilon})$. This provides the set ${\mathsf{Exp}}_{\mathcal{G}}/_\equiv$ with a coalgebraic structure $\partial_{\mathcal{G}}\colon {\mathsf{Exp}}_{\mathcal{G}}/_\equiv \to {\mathcal{G}}({\mathsf{Exp}}_{\mathcal{G}}/_\equiv)$ which makes $[-]$ a homomorphism between the coalgebras $({\mathsf{Exp}}_{\mathcal{G}}, \delta_{\mathcal{G}})$ and $({\mathsf{Exp}}_{\mathcal{G}}/_\equiv, \partial_{\mathcal{G}})$.

Soundness and Completeness {#sec:sound_compl}
--------------------------

Next we show that the axiomatization introduced in the previous section is sound and complete.

Soundness is a direct consequence of the fact that the equivalence map $[-]$ is a coalgebra homomorphism.

Let ${\mathcal{G}}$ be a nondeterministic functor. For all ${\varepsilon}_1,{\varepsilon}_2\in {\mathsf{Exp}}_{{\mathcal{G}}}$, $${\varepsilon}_1 \equiv {\varepsilon}_2 \Rightarrow {\varepsilon}_1 \sim {\varepsilon}_2$$

Let ${\mathcal{G}}$ be a nondeterministic functor, let ${\varepsilon}_1,{\varepsilon}_2\in {\mathsf{Exp}}_{{\mathcal{G}}}$ and suppose that ${\varepsilon}_1\equiv{\varepsilon}_2$. Then, $[{\varepsilon}_1] = [{\varepsilon}_2]$ and, thus $$\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}([{\varepsilon}_1])=
\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}([{\varepsilon}_2])$$ where $\mathbf{beh}_S$ denotes, for any ${\mathcal{G}}$-coalgebra $(S,g)$, the unique map into the final coalgebra. The uniqueness of the map into the final coalgebra and the fact that $[-]$ is a coalgebra homomorphism implies that $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}\circ [-] = \mathbf{beh}_{{\mathsf{Exp}}_{{\mathcal{G}}}}$ which then yields $$\mathbf{beh}_{{\mathsf{Exp}}_{{\mathcal{G}}}}({\varepsilon}_1)
=  \mathbf{beh}_{{\mathsf{Exp}}_{{\mathcal{G}}}}({\varepsilon}_2)$$ Since in the final coalgebra only the bisimilar elements are identified, ${\varepsilon}_1\sim{\varepsilon}_2$ follows. 

For completeness a bit more of work is required. Let us explain upfront the key steps of the proof. The goal is to prove that ${\varepsilon}_1\sim {\varepsilon}_2 \Rightarrow {\varepsilon}_1\equiv {\varepsilon}_2$. First, note that we have $$\label{eq:comp}
{\varepsilon}_1\sim {\varepsilon}_2 \Leftrightarrow \mathbf{beh}_{{\mathsf{Exp}}_{{\mathcal{G}}}}({\varepsilon}_1)
=  \mathbf{beh}_{{\mathsf{Exp}}_{{\mathcal{G}}}}({\varepsilon}_2)\Leftrightarrow \mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}([{\varepsilon}_1])=
\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}([{\varepsilon}_2])$$ We then prove that $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}$ is injective, which is a sufficient condition to guarantee that ${\varepsilon}_1\equiv {\varepsilon}_2$ (since it implies, together with (\[eq:comp\]), that $[{\varepsilon}_1]=[{\varepsilon}_2]$).

We proceed as follows. First, we factorize the map $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}$ into an epimorphism followed by a monomorphism [@Rutten00 Theorem 7.1] as shown in the following diagram (where $I= \mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv})$): $$\xymatrix{
{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}\ar@{-->}@/{}^{1.4pc}/[rr]^-{\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}}
\ar@{>>}[r]^-{e}
\ar[d]_{\partial_{{\mathcal{G}}}} &
I\ar@{^{(}->}[r]^-{m} \ar[d]_{\overline\omega_{\mathcal{G}}} &
\Omega_{\mathcal{G}}\ar[d]^{\omega_{\mathcal{G}}}\\
{\mathcal{G}}({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv})\ar[r]& {\mathcal{G}}(I)\ar[r]
& {\mathcal{G}}(\Omega_{\mathcal{G}})\\
}$$ Then, we prove that (1) $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$ is a locally finite coalgebra (Lemma \[lemma:h\_locally\_finite\]) and (2) both coalgebras $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$ and $(I,
\overline\omega_{\mathcal{G}})$ are final in the category of locally finite ${\mathcal{G}}$-coalgebras (Lemmas \[lemma:final1\] and \[lemma:final2\], respectively). Since final coalgebras are unique up to isomorphism, it follows that $e\colon {\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}\to I$ is in fact an isomorphism and therefore $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}$ is injective, which will give us completeness.

In the case of the deterministic automata functor ${\mathcal{D}}=2\times {\mathsf{Id}}^A$, the set $I$ will be precisely the set of regular languages, the class of languages that can be denoted by regular expressions. This means that final locally finite coalgebras generalize regular languages (in the same way that final coalgebras generalize the set of all languages).

We proceed with presenting and proving the extra lemmas needed in order to prove completeness. We start by showing that the coalgebra $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$ is locally finite (note that this implies that $(I,
\overline\omega_{\mathcal{G}})$ is also locally finite) and that $\partial_{{\mathcal{G}}}$ is an isomorphism.

\[lemma:h\_locally\_finite\] The coalgebra $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$ is a locally finite coalgebra. Moreover, $\partial_{{\mathcal{G}}}$ is an isomorphism.

Local finiteness is a direct consequence of the generalized Kleene’s theorem (Theorem \[kleene2\]). In the proof of Theorem \[kleene2\] we showed that, given ${\varepsilon}\in {\mathsf{Exp}}_{{\mathcal{G}}}$, the subcoalgebra $<[{\varepsilon}]_{\mathit{ACIE}}>$ is finite. Thus, the subcoalgebra $<[{\varepsilon}]>$ is also finite (since ${\mathsf{Exp}}_{\mathcal{G}}/_\equiv$ is a quotient of ${\mathsf{Exp}}_{\mathcal{G}}/_{\equiv_{ACIE}}$).

To see that $\partial_{{\mathcal{G}}}$ is an isomorphism, first define, for every ${\mathcal{F}}\lhd {\mathcal{G}}$, $$\label{eq:h_inv}
\partial^{-1}_{{\mathcal{F}}\lhd {\mathcal{G}}} (c) = [\overline\gamma^{\mathcal{F}}_{c}]$$ where $\overline\gamma^{\mathcal{F}}_{c}$ is defined, for ${\mathcal{F}}\neq {\mathsf{Id}}$, as $\gamma^{\mathcal{F}}_{c}$ in the proof of Theorem \[kleene1\], and for ${\mathcal{F}}={\mathsf{Id}}$ as $\overline\gamma^{{\mathsf{Id}}}_{[{\varepsilon}]} = {\varepsilon}$. Then, we prove that $\partial^{-1}_{{\mathcal{F}}\lhd {\mathcal{G}}}$ has indeed the properties

\(C) [1]{};

$\partial^{-1}_{{\mathcal{F}}\lhd {\mathcal{G}}} \circ \partial_{{\mathcal{F}}\lhd {\mathcal{G}}}  = \mathit{id}_{{\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_\equiv}$ and

\(C) [2]{};

$\partial_{{\mathcal{F}}\lhd {\mathcal{G}}} \circ
\partial^{-1}_{{\mathcal{F}}\lhd {\mathcal{G}}} = \mathit{id}_{{\mathcal{F}}({\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_\equiv)}$. Instantiating ${\mathcal{F}}={\mathcal{G}}$ one derives that $\delta_{\mathcal{G}}$ is an isomorphism. It is enough to prove for

\(C) [1]{};

that $\overline\gamma^{\mathcal{F}}_{\partial_{{\mathcal{F}}\lhd {\mathcal{G}}}([{\varepsilon}])}\equiv {\varepsilon}$ and for

\(C) [2]{};

that $\partial_{{\mathcal{F}}\lhd {\mathcal{G}}}([\overline\gamma^{\mathcal{F}}_{c}])=c$. We illustrate a few cases. The omitted ones are similar.

\(C) [1]{};

By induction on the product of types of expressions and expressions (using the order defined in equation (\[ind:order5\])). $$\begin{array}{@{}l}
\overline\gamma^{\mathsf{Id}}_{\partial_{{\mathsf{Id}}\lhd {\mathcal{G}}}([{\varepsilon}])} = {\varepsilon}\\[1.5ex]
 \overline\gamma^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{\partial_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}}([r<{\varepsilon}>])} =
l<\overline\gamma^{{\mathcal{F}}_1}_{\partial_{{\mathcal{F}}_1\lhd {\mathcal{G}}}({\underline\emptyset})}>\oplus
r<\overline\gamma^{{\mathcal{F}}_2}_{\partial_{{\mathcal{F}}_2\lhd {\mathcal{G}}}({\varepsilon})}>
\stackrel{(\mathit{IH})}\equiv l<{\underline\emptyset}>\oplus
r<{\varepsilon}> \equiv r<{\varepsilon}>\\[1.5ex]
\overline\gamma^{\mathcal{G}}_{\partial_{{\mathcal{G}}}([\mu x.{\varepsilon}])} =
\overline\gamma^{\mathcal{G}}_{\partial_{{\mathcal{G}}}([{\varepsilon}[\mu x.{\varepsilon}/x]])}
\stackrel{(\mathit{IH})}\equiv
{\varepsilon}[\mu x.{\varepsilon}/x]\equiv \mu x.{\varepsilon}\end{array}$$ Note that the cases ${\varepsilon}={\underline\emptyset}$ and ${\varepsilon}={\varepsilon}_1\oplus{\varepsilon}_2$ require an extra proof (by induction on ${\mathcal{F}}$). More precisely, one needs to prove that $${  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {$a$};
  \end{tikzpicture}}\ \ 
 \overline\gamma^{\mathcal{F}}_{{\mathcal{F}}[-]({\mathsf{Empty}}_{{\mathcal{F}}\lhd {\mathcal{G}}})} \equiv {\underline\emptyset}\text{ and } {  \begin{tikzpicture}[baseline=(C.base)]
    \node[draw,circle,inner sep=1pt](C) {$b$};
  \end{tikzpicture}}\ \  \overline\gamma^{\mathcal{F}}_{{\mathcal{F}}[-]({\mathsf{Plus}}_{{\mathcal{F}}\lhd {\mathcal{G}}}(x_1,x_2))} \equiv \overline\gamma^{\mathcal{F}}_{{\mathcal{F}}[-](x_1)}\oplus
\overline\gamma^{\mathcal{F}}_{{\mathcal{F}}[-](x_2)}$$ It is an easy proof by induction. We illustrate here only the cases ${\mathcal{F}}={\mathsf{Id}}$, ${\mathcal{F}}={\mathsf{B}}$ and ${\mathcal{F}}={\mathcal{F}}_1\times {\mathcal{F}}_2$.

  ---------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------
  ${  \begin{tikzpicture}[baseline=(C.base)]           $\overline\gamma^{\mathsf{Id}}_{[{\underline\emptyset}]} = {\underline\emptyset}$                                                      
      \node[draw,circle,inner sep=1pt](C) {$a$};                                                                                                                                              
    \end{tikzpicture}}$                                                                                                                                                                       

  \[1.2ex\]                                            $\overline\gamma^{\mathsf{B}}_{[\bot_{\mathsf{B}}]} = \bot_{\mathsf{B}}\equiv {\underline\emptyset}$                                   

  \[1.2ex\]                                            $\overline\gamma^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{<{\mathcal{F}}_1[-]({\mathsf{Empty}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}}),   $=
                                                       {\mathcal{F}}_2[-]({\mathsf{Empty}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}})>}$                                                            l<\overline\gamma^{{\mathcal{F}}_1}_{{\mathcal{F}}_1[-]({\mathsf{Empty}}_{{\mathcal{F}}_1\lhd {\mathcal{G}}})}>\oplus
                                                                                                                                                                                              r<\overline\gamma^{{\mathcal{F}}_2}_{{\mathcal{F}}_2[-]({\mathsf{Empty}}_{{\mathcal{F}}_2\lhd {\mathcal{G}}})}>$

                                                                                                                                                                                              $\stackrel{(\mathit{IH})}\equiv l<{\underline\emptyset}>\oplus  r<{\underline\emptyset}> \equiv
                                                                                                                                                                                              {\underline\emptyset}$

  \[2ex\] ${  \begin{tikzpicture}[baseline=(C.base)]   $\overline\gamma^{\mathsf{Id}}_{[x_1\oplus x_2]} = x_1\oplus x_2 =                                                                     
      \node[draw,circle,inner sep=1pt](C) {$b$};       \overline\gamma^{\mathsf{Id}}_{[x_1]}\oplus \overline\gamma^{\mathsf{Id}}_{[x_2]}$                                                     
    \end{tikzpicture}}$                                                                                                                                                                       

  \[1.4ex\]                                            $\overline\gamma^{\mathsf{B}}_{[x_1\vee_{\mathsf{B}}x_2]} = x_1\vee_{\mathsf{B}}x_2 \equiv  x_1\oplus                                  $= \overline\gamma^{\mathsf{B}}_{[x_1]}\oplus \overline\gamma^{\mathsf{B}}_{[x_2]}$
                                                       x_2$                                                                                                                                   

  \[1.4ex\]                                            $\overline\gamma^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{{{\mathcal{F}}_1\times                                                       $\stackrel{\phantom{(\mathit{IH})}}= 
                                                       {\mathcal{F}}_2}[-]({\mathsf{Plus}}_{{{\mathcal{F}}_1\times {\mathcal{F}}_2}\lhd {\mathcal{G}}}(<u_1,v_1>,<u_2,v_2>))}$                \overline\gamma^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{<{\mathsf{Plus}}_{{\mathcal{F}}_1}(u_1,v_1),
                                                                                                                                                                                              {\mathsf{Plus}}_{{\mathcal{F}}_2}(u_2,v_2)>}$

                                                                                                                                                                                              $\stackrel{\phantom{(\mathit{IH})}}=
                                                                                                                                                                                              l<\overline\gamma^{{\mathcal{F}}_1}_{{\mathsf{Plus}}_{{\mathcal{F}}_1}(u_1,v_1)}>\oplus
                                                                                                                                                                                              r<\overline\gamma^{{\mathcal{F}}_2}_{{\mathsf{Plus}}_{{\mathcal{F}}_2}(u_2,v_2)}>$

  \[1.2ex\]                                                                                                                                                                                   $
                                                                                                                                                                                              \stackrel{(\mathit{IH})}\equiv
                                                                                                                                                                                              l<\gamma^{{\mathcal{F}}_1}_{u_1}\oplus\gamma^{{\mathcal{F}}_1}_{v_1}>\oplus
                                                                                                                                                                                              r<\gamma^{{\mathcal{F}}_2}_{u_2}\oplus \gamma^{{\mathcal{F}}_2}_{v_2}>$

  \[1.2ex\]                                                                                                                                                                                   $\stackrel{\phantom{(\mathit{IH})}}\equiv
                                                                                                                                                                                              (l<\gamma^{{\mathcal{F}}_1}_{u_1}>\oplus r<\gamma^{{\mathcal{F}}_2}_{u_2}>) \oplus
                                                                                                                                                                                              (l<\gamma^{{\mathcal{F}}_1}_{v_1}>\oplus r<\gamma^{{\mathcal{F}}_2}_{v_2}>)$

  \[1.2ex\]                                                                                                                                                                                   $\stackrel{\phantom{(\mathit{IH})}}=
                                                                                                                                                                                              \overline\gamma^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{<u_1,u_2>} \oplus
                                                                                                                                                                                              \overline\gamma^{{\mathcal{F}}_1\times {\mathcal{F}}_2}_{<v_1,v_2>}$
  ---------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------

\(C) [2]{};

By induction on the structure of ${\mathcal{F}}$. $$\begin{array}{lcl}
\partial_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd {\mathcal{G}}}([\overline\gamma^{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2}_{c}])&=&
\begin{cases} \partial_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd
{\mathcal{G}}}([l[\overline\gamma^{{\mathcal{F}}_1}_{c'}]])= \kappa_1(\partial_{{\mathcal{F}}_1\lhd
{\mathcal{G}}}([\overline\gamma^{{\mathcal{F}}_1}_{c'}]))&c= \kappa_1(c')\\
\partial_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd
{\mathcal{G}}}([r[\overline\gamma^{{\mathcal{F}}_2}_{c'}]]) = \kappa_2(\partial_{{\mathcal{F}}_2\lhd
{\mathcal{G}}}([\overline\gamma^{{\mathcal{F}}_2}_{c'}]))
&c=\kappa_2(c') \\ \partial_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2\lhd {\mathcal{G}}}([{\underline\emptyset}])=\bot &c=\bot \\
\partial_{{\mathcal{F}}_1{\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}{\mathcal{F}}_2 \lhd
{\mathcal{G}}}([l[{\underline\emptyset}]\oplus r[{\underline\emptyset}]])=\top & c=\top \end{cases}\\
&\stackrel {(\mathit{IH})}=& c
\end{array}$$ $$\begin{array}{lcl}
\partial_{\pow {\mathcal{F}}\lhd {\mathcal{G}}}([\overline\gamma^{\pow {\mathcal{F}}}_{C}])&=&
\begin{cases} \partial_{\pow {\mathcal{F}}\lhd
{\mathcal{G}}}([{\underline\emptyset}])= \emptyset & C=\emptyset\\
\partial_{\pow {\mathcal{F}}\lhd
{\mathcal{G}}}([\bigoplus_{c\in C}\overline\gamma^{{\mathcal{F}}_1}_{c}])=\{\partial_{{\mathcal{F}}\lhd
{\mathcal{G}}}([\overline\gamma^{{\mathcal{F}}_1}_{c}])\mid c\in C\} &
\text{otherwise}\end{cases} \\
&\stackrel {(\mathit{IH})}=& C
\end{array}$$

Next, we prove the analogue of the following useful and intuitive equality on regular expressions. Given a deterministic automaton $<o,t>\colon S\to 2\times S^A$ and a state $s\in S$, the associated regular expression $r_s$ can be written as $$\label{eq:regexp_decomp}
r_s = o(s) + \sum_{a\in A} a\cdot r_{t(s)(a)}$$ using the axioms of Kleene algebra [@Brz64 Theorem 4.4].

\[lemma:gamma\] Let $(S,g)$ be a locally finite ${\mathcal{G}}$-coalgebra, with ${\mathcal{G}}\neq {\mathsf{Id}}$, and let $s\in S$, with $<s>=\{s_1,\ldots,s_n\}$ (where $s_1=s$). Then: $$\begin{aligned}
\label{gamma_eq} 
\expr{s_i} &\equiv& \gamma_{g(s_i)}^{\mathcal{G}}\{\expr {s_1}/x_1\} \ldots \{\expr
{s_n}/x_n\}\end{aligned}$$

Let $A_i^k$, where $i$ and $k$ range from $1$ to $n$, be the terms defined as in the proof of Theorem \[kleene1\]. Recall that $\expr{s_i}=A^n_i$. We calculate: $$\begin{array}{@{}l@{\ }l@{\ \ }l@{}}
& \expr{ s_i }\\ = & A^n_i \\
=& (\mu x_i. \gamma^{\mathcal{G}}_{g(s_i)}) \{A^0_1/x_1\} \ldots
\{A_n^{n-1}/x_n\}\\[1ex] 
=& \mu x_i. (\gamma^{\mathcal{G}}_{g(s_i)} \{A^0_1/x_1\} \ldots
\{A_{i-1}^{i-2}/x_{i-2}\}\{A^i_{i+1}/x_{i+1}\} \ldots \{A_n^{n-1}/x_n\}
)\\[1ex] 
\equiv& \gamma^{\mathcal{G}}_{g(s_i)} \{A^0_1/x_1\} \ldots
\{A_{i-1}^{i-2}/x_{i-2}\}\{A^i_{i+1}/x_{i+1}\} \ldots \{A_n^{n-1}/x_n\}
\{A^n_i/x_i\} &\text{(fixed point axiom\footnotemark )}\\[1ex] 
=& \gamma^{\mathcal{G}}_{g(s_i)} \{A^0_1/x_1\} \ldots \{A_n^{n-1}/x_n\} &  \text{(by
\ref{eq:subst1})}\\[1ex] 
=&  \gamma^{\mathcal{G}}_{g(s_i)} \{A^0_1\{A^1_2/x_2\}\ldots \{A_n^{n-1}/x_n\}/x_1\} \ldots \{A_n^{n-1}/x_n\} &  \text{(by
\ref{eq:subst2})}\\[1ex] 
=&  \gamma^{\mathcal{G}}_{g(s_i)} \{A^n_1/x_1\}\{A_2^1/x_2\}
\ldots \{A_n^{n-1}/x_n\} &  \text{(def. $A_1^{n}$)}\\[2ex] 
\vdots& \text{(repeat last 2 steps for $A_2^1,\ldots,
A_{n-1}^{n-2}$)}\\[2ex]
=&  \gamma^{\mathcal{G}}_{g(s_i)} \{A^n_1/x_1\}\{A_2^n/x_2\}
\ldots \{A_n^n/x_n\} &  \text{($A_{n-1}^{n} = A^n_n$)}\\
\end{array}$$

Instantiating (\[gamma\_eq\]) for $<o,t>\colon S\to
2\times S^A$, one can easily spot the similarity with equation (\[eq:regexp\_decomp\]) above: $$\expr s \equiv l<o(s)> \oplus r\Big<\bigoplus_{a\in A} a\big(\expr{
t(s)(a)}\big)\Big>$$

Next, we prove that there exists a coalgebra homomorphism between any locally finite ${\mathcal{G}}$- coalgebra $(S,g)$ and $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$.

\[lemma:ceil-exists\] Let $(S,g)$ be a locally finite ${\mathcal{G}}$-coalgebra. There exists a coalgebra homomorphism $\ceil{-}
\colon S \to {\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}$.

We define $\ceil{-}= [-]\circ \expr{-}$, where $\expr{-}$ is as in the proof of Theorem \[kleene1\], associating to a state $s$ of a locally finite coalgebra an expression $\expr s$ with $s\sim \expr s$. To prove that $\ceil{-}$ is a homomorphism we need to verify that $({\mathcal{G}}\ceil -)\circ g = \partial_{\mathcal{G}}\circ
\ceil -$.

If ${\mathcal{G}}={\mathsf{Id}}$, then $({\mathcal{G}}\ceil -)\circ g (s_i) = [{\underline\emptyset}] = \partial_{\mathcal{G}}(\ceil
{s_i})$. For ${\mathcal{G}}\neq {\mathsf{Id}}$ we calculate, using Lemma \[lemma:gamma\]: $$\begin{aligned}
\partial_{\mathcal{G}}(\ceil {s_i})
= \partial_{\mathcal{G}}([\gamma_{g(s_i)}^{\mathcal{G}}[\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]]) \end{aligned}$$ and we then prove the more general equality, for ${\mathcal{F}}\lhd {\mathcal{G}}$ and $c\in {\mathcal{F}}<s>$: $$\label{eq:interm}
\partial_{{\mathcal{F}}\lhd {\mathcal{G}}} ([\gamma_{c}^{\mathcal{F}}[\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]]) = {\mathcal{F}}\ceil - (c)$$ The intended equality then follows by taking ${\mathcal{F}}={\mathcal{G}}$ and $c=g(s_i)$. Let us prove the equation (\[eq:interm\]) by induction on ${\mathcal{F}}$.

$c= s_j \in <s>$ $$\begin{aligned}
\partial_{{\mathsf{Id}}\lhd {\mathcal{G}}} ([\gamma_{s_j}^{{\mathsf{Id}}} [\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]])= [\expr {s_j}]
 =  \ceil{s_j}\end{aligned}$$

$c= b \in {\mathsf{B}}$ $$\begin{aligned}
\partial_{{\mathsf{B}}\lhd {\mathcal{G}}} ([\gamma_{b}^{{\mathsf{B}}} [\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]]) = [b]
 =  {\mathsf{B}}\ceil{-} (b)\end{aligned}$$

$c=<c_1,c_2> \in ({\mathcal{F}}_1\times {\mathcal{F}}_2) <s>$

$$\begin{aligned}
&&\partial_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}} ([\gamma_{<c_1,c_2>}^{{\mathcal{F}}_1\times {\mathcal{F}}_2} [\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]])\\ &=& \partial_{{\mathcal{F}}_1\times {\mathcal{F}}_2\lhd {\mathcal{G}}} ([l(\gamma_{c_1}^{{\mathcal{F}}_1})\oplus
r(\gamma_{c_2}^{{\mathcal{F}}_2})[\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]])\\
&=& < \partial_{{\mathcal{F}}_1\lhd {\mathcal{G}}} ([\gamma_{c_1}^{{\mathcal{F}}_1}[\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]]), \partial_{{\mathcal{F}}_2\lhd {\mathcal{G}}}
([\gamma_{c_2}^{{\mathcal{F}}_2}[\expr {s_1}/x_1] \ldots [\expr
{s_n}/x_n]]) >\\
& \stackrel{(\mathit{IH})}= & <{\mathcal{F}}_1 \ceil - (c_1), {\mathcal{F}}_2 \ceil - (c_2)>\\
&=& ({\mathcal{F}}_1\times {\mathcal{F}}_2 \ceil -) (c)\end{aligned}$$

, and : similar to ${\mathcal{F}}_1\times {\mathcal{F}}_2$.

We can now prove that the coalgebras $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv},
\partial_{{\mathcal{G}}})$ and $(I,\overline \omega_{\mathcal{G}})$ are both final in the category of locally finite ${\mathcal{G}}$-coalgebras.

\[lemma:final1\] The coalgebra $(I,\overline \omega_{\mathcal{G}})$ is final in the category $\mathit{Coalg}({\mathcal{G}})_{{\mathbf{LF}}}$.

We want to show that for any locally finite ${\mathcal{G}}$-coalgebra $(S,g)$, there exists a [*unique*]{} homomorphism $(S,g) \to (I,\overline \omega_{\mathcal{G}})$. The existence is guaranteed by Lemma \[lemma:ceil-exists\], where the homomorphism [$\ceil{-}\colon S
\to {\mathsf{Exp}}_{\mathcal{G}}/_{\equiv} $]{} is defined. Post-composing this homomorphism with $e$ (defined above) we get a coalgebra homomorphism $e\circ \ceil - \colon S \to I$. If there is another homomorphism $f\colon S\to I$, then by post-composition with the inclusion $m\colon I\hookrightarrow \Omega$ we get two homomorphisms ($m\circ f$ and $m\circ e\circ \ceil -$) into the final ${\mathcal{G}}$-coalgebra. Thus, $f$ and $e\circ \ceil -$ must be equal.

\[lemma:final2\] The coalgebra $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$ is final in the category $\mathit{Coalg}({\mathcal{G}})_{\mathbf{LF}}$.

We want to show that for any locally finite ${\mathcal{G}}$-coalgebra $(S,g)$, there exists a [*unique*]{} homomorphism $(S,g) \to ({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$. We only need to prove uniqueness, since the existence is guaranteed by Lemma \[lemma:ceil-exists\], where [$\ceil{-}\colon S \to {\mathsf{Exp}}_{\mathcal{G}}/_{\equiv} $]{} is defined.

Suppose we have another homomorphism $f\colon S\to {\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}$. Then, we shall prove that $f=\ceil -$. Let, for any $s\in S$, $f_s$ denote any representative of $f(s)$ (that is, $f(s)=[f_s]$). First, observe that because $f$ is a homomorphism the following holds for every $s\in S$: $$\label{eq:m}
f(s) = (\partial_{{\mathcal{G}}}^{-1} \circ {\mathcal{G}}(f) \circ g)(s) \Leftrightarrow
f_s\equiv  \gamma_{g(s)}^{\mathcal{G}}[f_{s_1}/x_1]\ldots [f_{s_n}/x_n]$$ where $<s> = \{s_1,\ldots,s_n\}$, with $s_1=s$ (recall that $\partial^{-1}_{{\mathcal{G}}}$ was defined in (\[eq:h\_inv\]) and note that $\overline\gamma^{\mathcal{G}}_{({\mathcal{G}}(f) \circ g)(s)} = \gamma^{\mathcal{G}}_{g(s)} [f_{s_i}/x_{i}]$).

Next, we prove that $f_{s_i}\equiv \expr{s_i}$ (which is equivalent to $f(s_i) = \ceil {s_i}$), for all $i=1,\ldots n$. For simplicity we will here prove the case $n=3$. The general case is identical but notationally heavier. First, we prove that $f_{s_1} \equiv A_1[f_{s_2}/x_2][f_{s_3}/x_3]$. $$\begin{array}{@{}lll}
&f_{s_1} \equiv \gamma_{g(s_1)}^{\mathcal{G}}[f_{s_1}/x_1]  [f_{s_2}/x_2]  [f_{s_3}/x_3] &\text{(by~(\ref{eq:m})})\\[.8ex]
\Leftrightarrow& f_{s_1} \equiv \gamma_{g(s_1)}^{\mathcal{G}}[f_{s_2}/x_2]  [f_{s_3}/x_3] [f_{s_1}/x_1]  &\text{(all $f(s_i)$ are closed)}\\[.8ex]
\Rightarrow& f_{s_1} \equiv \mu x_1. \gamma_{g(s_1)}^{\mathcal{G}}[f_{s_2}/x_2]  [f_{s_3}/x_3]  &\text{(by uniqueness of fixed points)}\\[.8ex]
\Leftrightarrow& f_{s_1} \equiv A_1[f_{s_2}/x_2]  [f_{s_3}/x_3]  &\text{(def. of $A_1$)}
\end{array}$$ Now, using what we have computed for $f_{s_1}$ we prove that $f_{s_2} \equiv A_2^1[f_{s_3}/x_3]$. [ $$\begin{array}{@{}lll} 
&f_{s_2} \equiv \gamma_{g(s_2)}^{\mathcal{G}}[f_{s_1}/x_1]  [f_{s_2}/x_2]  [f_{s_3}/x_3] &\text{(by~(\ref{eq:m})})\\[.8ex]
\Leftrightarrow&f_{s_2} \equiv \gamma_{g(s_2)}^{\mathcal{G}}[A_1/x_1]  [f_{s_2}/x_2]  [f_{s_3}/x_3]
&\text{(expressions for $f_{s_1}$ and (\ref{eq:subst2}))}\\[.8ex]
\Leftrightarrow& f_{s_2} \equiv \gamma_{g(s_2)}^{\mathcal{G}}[A_1/x_1]  [f_{s_3}/x_3] [f_{s_2}/x_2] &\text{(all $f(s_i)$ are closed)}\\[.8ex]
\Rightarrow& f_{s_2} \equiv \mu x_2. \gamma_{g(s_2)}^{\mathcal{G}}[A_1/x_1]  [f_{s_3}/x_3]  &\text{(by uniqueness of fixed points)}\\[.8ex]
\Leftrightarrow& f_{s_2} \equiv A_2^1[f_{s_3}/x_3]  &\text{(def. of $A_2^1$)}
\end{array}$$]{} At this point we substitute $f_{s_2}$ in the expression for $f_{s_1}$ by $A_2^1[f_{s_3}/x_3]$ which yields: $$f_{s_1} \equiv  A_1[A^1_2 [f_{s_3}/x_3]  /x_2]  [f_{s_3}/x_3]  \equiv A_1[A^1_2/x_2]  [f_{s_3}/x_3]$$ Finally, we prove that $f_{s_3} \equiv A_3^2$: $$\begin{array}{@{}lll} 
&f_{s_3} \equiv \gamma_{g(s_3)}^{\mathcal{G}}[f_{s_1}/x_1]  [f_{s_2}/x_2]  [f_{s_3}/x_3] &\text{(by~(\ref{eq:m})})\\[.8ex]
\Leftrightarrow&f_{s_3} \equiv \gamma_{g(s_3)}^{\mathcal{G}}[A_1/x_1]  [A_2^1/x_2]  [f_{s_3}/x_3]
&\text{(expr. for $f(s_i)$ and (\ref{eq:subst2}))}\\[.8ex]
\Rightarrow& f_{s_3} \equiv \mu x_3. \gamma_{g(s_3)}^{\mathcal{G}}[A_1/x_1]  [A_2^1/x_2]  &\text{(by uniqueness of fixed points)}\\[.8ex]
\Leftrightarrow& f_{s_3} \equiv A_3^2  &\text{(def. of $A_3^2$)}
\end{array}$$ Thus, we have $f_{s_1} \equiv A_1[A^1_2/x_2]  [A^2_3/x_3] $, $f_{s_2}
\equiv A_2^1  [A^2_3/x_3]$ and $f_{s_3} \equiv A^2_3$. Note that $A_2^1  [A^2_3/x_3]  \equiv A_2^1  \{A^2_3/x_3\} $ since $x_2$ is not free in $A^2_3$. Similarly, since $x_1$ is not free in $A^1_2$ and $A^2_3$, we have that $A_1[A^1_2/x_2]  [A^2_3/x_3]  \equiv A_1\{A^1_2/x_2\}  \{A^2_3/x_3\}$. Thus $f(s_i) = \ceil{s_i}$, for all $i=1,2,3$.

As a consequence of Lemma \[lemma:final2\], we have that if ${\mathcal{G}}_1$ and ${\mathcal{G}}_2$ are isomorphic functors then ${\mathsf{Exp}}_{{\mathcal{G}}_1}/_\equiv$ and ${\mathsf{Exp}}_{{\mathcal{G}}_2}/_\equiv$ are also isomorphic (for instance, this would be true for ${\mathcal{G}}_1(X) = {\mathsf{B}}\times (X \times A)$ and ${\mathcal{G}}_2(X) =  A \times ({\mathsf{B}}\times X)$).

We remark that Lemma \[lemma:final1\] could have been proved as a consequence of Lemma \[lemma:final2\], by observing that $(I,\overline \omega_{\mathcal{G}})$ is, by construction, a quotient of $({\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}, \partial_{{\mathcal{G}}})$.

At this point, because final objects are unique up-to isomorphism, we know that $e\colon {\mathsf{Exp}}_{\mathcal{G}}/_\equiv \to I$ is an isomorphism and hence we can conclude that the map $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}$ is injective, since it factorizes into an isomorphism followed by a mono. This fact is the last thing we need to prove completeness.

Let ${\mathcal{G}}$ be a nondeterministic functor. For all ${\varepsilon}_1,{\varepsilon}_2\in {\mathsf{Exp}}_{{\mathcal{G}}}$, $${\varepsilon}_1 \sim {\varepsilon}_2 \Rightarrow {\varepsilon}_1 \equiv {\varepsilon}_2$$

Let ${\mathcal{G}}$ be a nondeterministic functor, let ${\varepsilon}_1,{\varepsilon}_2\in {\mathsf{Exp}}_{{\mathcal{G}}}$ and suppose that ${\varepsilon}_1\sim{\varepsilon}_2$. Because only bisimilar elements are identified in the final coalgebra we know that it must be the case that $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}}({\varepsilon}_1)
=  \mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}}({\varepsilon}_2) $ and thus, since the equivalence class map $[-]$ is a homomorphism, $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}([{\varepsilon}_1])=
\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}([{\varepsilon}_2])$. Because $\mathbf{beh}_{{\mathsf{Exp}}_{\mathcal{G}}/_{\equiv}}$ is injective we have that $[{\varepsilon}_1]=
[{\varepsilon}_2]$. Hence, ${\varepsilon}_1\equiv{\varepsilon}_2$.

Two more examples {#sec:appl}
=================

In this section we apply our framework to two other examples: labelled transition systems (with explicit termination) and automata on guarded strings. These two automata models are directly connected to, respectively, basic process algebra and Kleene algebra with tests. To improve readability we will present the corresponding languages using a more user-friendly syntax than the canonically derived one.

#### **Labelled transition systems.**

Labelled transition systems (with explicit termination) are coalgebras for the functor $1+(\pow {\mathsf{Id}})^A$. As we will show below, instantiating our framework for this functor produces a language that is equivalent to the closed and guarded expressions generated by the following grammar, where $a\in A$ and $x\in X$ ($X$ is a set of fixed point variables): $$P\, ::= \mathbf{0} \mid P+P \mid a.P \mid \delta\mid \surd \mid \mu x. P
\mid x$$ together with the equations (omitting the congruence and $\alpha$-equivalence rules)

$$\begin{aligned}
&P_1 + P_2 \equiv P_2+P_1 && P_1 + (P_2+P_3) \equiv (P_1+P_2)+P_3\\
&P+P  \equiv P &&  P+ \mathbf{0} \equiv P\\
&P+ \delta \equiv P\ (\star)&
&\surd + \delta \equiv \surd + P\ (\star)& (\star) \text{ if }  P\not\equiv
\mathbf{0}\text{ and } P\not\equiv \surd\\
&P[\mu x.P/x] \equiv \mu x . P && P[Q/x]  \equiv  Q \Rightarrow (\mu
x.P)  \equiv Q\end{aligned}$$

Note that, as expected, there is no law that allows us to prove $a.(P+Q)\equiv a.P+a.Q$. Moreover, observe that this syntax and axiomatization is very similar to the one presented in [@AcetoH92]. In the syntax above, $\delta$ represents deadlock, $\surd$ successful termination and $\mathbf 0$ the totally undefined process.

We will next show how the beautified syntax above was derived from the canonically derived syntax for the expressions ${\varepsilon}\in {\mathsf{Exp}}_{1+(\pow
{\mathsf{Id}})^A}$, which is given by the set of closed and guarded expressions defined by the following BNF: $$\begin{array}{l}
{\varepsilon}::= {\underline\emptyset}\mid {\varepsilon}\oplus{\varepsilon}\mid x \mid \mu x.{\varepsilon}\mid l[{\varepsilon}_1]
\mid r[{\varepsilon}_2]\\
{\varepsilon}_1 ::= {\underline\emptyset}\mid {\varepsilon}_1\oplus{\varepsilon}_1 \mid *\\
{\varepsilon}_1 ::= {\underline\emptyset}\mid {\varepsilon}_2\oplus{\varepsilon}_2 \mid a({\varepsilon}')\\
{\varepsilon}' ::= {\underline\emptyset}\mid {\varepsilon}'\oplus{\varepsilon}' \mid \{{\varepsilon}\}
\end{array}$$ We define two maps between this grammar and the grammar presented above. Let us start to show how to translate $P$’s into ${\varepsilon}$’s, by defining a map $(-)^\dagger$ by induction on the structure of $P$: $$\begin{array}{lcl}
(\mathbf{0})^\dagger &=& {\underline\emptyset}\\
(P_1+P_2)^\dagger &=&  (P_1)^\dagger \oplus (P_2)^\dagger\\
(\mu x. P)^\dagger &=& \mu x. P^\dagger\\
x^\dagger  &=& x
\end{array}
\begin{array}{lcl}
(a.P)^\dagger &=& r[a(\{P^\dagger\})]\\ 
(\surd)^\dagger &=& l[*] \\
(\delta)^\dagger &=& r[{\underline\emptyset}]\\
\end{array}$$ And now the converse translation: $$\begin{array}{lcl}
({\underline\emptyset})^\ddagger &=& \mathbf{0}\\
({\varepsilon}_1\oplus{\varepsilon}_2)^\ddagger &=&  ({\varepsilon}_1)^\ddagger + ({\varepsilon}_2)^\ddagger\\
(\mu x. {\varepsilon})^\ddagger &=& \mu x. {\varepsilon}^\ddagger\\
x^\ddagger  &=& x\\
(l[{\underline\emptyset}])^\ddagger &=& \surd \\
(l[{\varepsilon}_1\oplus{\varepsilon}_1'])^\ddagger &=& (l[{\varepsilon}_1])^\ddagger + 
(l[{\varepsilon}_1'])^\ddagger\\
\end{array}
\begin{array}{lcl}
(l[*])^\ddagger &=& \surd \\
(r[{\underline\emptyset}])^\ddagger &=& \delta \\ 
(r[{\varepsilon}_2\oplus{\varepsilon}_2'])^\ddagger &=&(r[{\varepsilon}_2])^\ddagger  + (r[{\varepsilon}_2'])^\ddagger\\ 
(r[a({\underline\emptyset})])^\ddagger &=& \delta \\ 
(r[a({\varepsilon}_1'\oplus{\varepsilon}_2')])^\ddagger &=&(r[a({\varepsilon}_1')])^\ddagger + (r[a({\varepsilon}_2')])^\ddagger \\ 
(r[a(\{{\varepsilon}\})])^\ddagger &=& a.{\varepsilon}^\ddagger \\ 
\end{array}$$ One can prove that if $P_1\equiv P_2$ (using the equations above) then $(P_1)^\dagger\equiv (P_2)^\dagger$ (using the automatically derived equations for the functor) and also that ${\varepsilon}_1\equiv {\varepsilon}_2$ implies $({\varepsilon}_1)^\ddagger \equiv ({\varepsilon}_2)^\ddagger$.

#### **Automata on guarded strings.**

It has recently been shown [@kozen08] that automata on guarded strings (acceptors of the join irreducible elements of the free Kleene algebra with tests on generators $\Sigma, T$) are coalgebras for the functor ${\mathsf{B}}\times {\mathsf{Id}}^{At\times \Sigma}$, where $At$ is the set of atoms, [*i.e.*]{} minimal nonzero elements of the free Boolean algebra ${\mathsf{B}}$ generated by $T$ and $\Sigma$ is a set of actions. Applying our framework to this functor yields a language that is equivalent to the closed and guarded expressions generated by the following grammar, where $b\in {\mathsf{B}}$ and $a\in \Sigma$: $$P\, ::= \mathbf{0} \mid <b> \mid P+P \mid b \to a.P \mid \mu x. P
\mid x$$ accompanied by the equations (omitting the congruence and $\alpha$-equivalence rules) $$\begin{aligned}
&P_1 + P_2 \equiv P_2+P_1 && P_1 + (P_2+P_3) \equiv (P_1+P_2)+P_3\\
&P+P \equiv P&&P+ \mathbf{0} \equiv P \\ 
&<b_1>+<b_2> \equiv <b_1\vee_{\mathsf{B}}b_2> && \mathbf{0} \equiv <\bot_{\mathsf{B}}>\\
& (b \to a.\mathbf{0})\equiv  \mathbf{0} && (\bot_{\mathsf{B}}\to a.P) 
\equiv \mathbf{0}\\
& (b \to a.P_2) +  (b \to a.P_2) 
\equiv  b \to a.(P_1+P_2)&&
 (b_1 \to a.P) +  (b_2 \to a.P) \equiv  (b_1\vee_{\mathsf{B}}b_2) \to a.P\\
&P[\mu x.P/x] \equiv \mu x . P&&
P[Q/x] \equiv  Q \Rightarrow (\mu
x.P) \equiv Q\end{aligned}$$ We will not present a full comparison of this syntax to the one of Kleene algebra with tests [@kozen08] (and propositional Hoare triples). The differences between our syntax and that of KAT are similar to the ones between regular expressions and the language ${\mathsf{Exp}}_{\mathcal{D}}$ for the functor representing deterministic automata (see Definition \[def:regexp\_to\_exp\]). Similarly to the LTS example one can define maps between the beautified syntax and the automatically generated one and prove its correctness.

Polynomial and finitary coalgebras {#sec:pol_fin}
==================================

The functors we considered above allowed us to modularly derive languages and axiomatizations for a large class of coalgebras. If we consider the subset of ${\mathit{NDF}}$ without the $\pow$ functor, the class of coalgebras for these functors almost coincides with polynomial coalgebras (that is, coalgebras for a polynomial functor). The only difference comes from the use of join-semilattices for constant functors and ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$ instead of the ordinary coproduct, which played an important role in order for us to be able to have underspecification and overspecification. We will next show how to derive expressions and axiomatizations directly for polynomial coalgebras, where no underspecification or overspecification is allowed.

Before we show the formal definition, let us provide some intuition. The main changes[^4], compared to the previous sections, would be not to have ${\underline\emptyset}$ and $\oplus$ and consider an expression $<-,->$ for the product instead of the two expressions $l<->$ and $r<->$ which we considered and an expression $<a_1(-), a_2(-), \ldots, a_n(-)>$ for the exponential (with $A=\{a_1,\dots a_n\}$). As an example, take the functor ${\mathcal{D}}(X) =
2\times X^A$ of deterministic automata. The expressions corresponding to this functor would then be the set of closed and guarded expressions given by the following BNF: $${\varepsilon}::= x \mid \mu x.{\varepsilon}\mid <0, <a_1({\varepsilon}), a_2({\varepsilon}), \ldots, a_n({\varepsilon})>>
\mid <1,<a_1({\varepsilon}), a_2({\varepsilon}), \ldots, a_n({\varepsilon})>>$$ This syntax can be perceived as an explicit and complete description of the automaton. This means that underspecification is nonexistent and the compactness of regular expressions is lost. As an example of the verbosity present in this new language, take $A=\{a,b,c\}$ and consider the language that accepts words with only $a$’s and has at last one $a$ (described by $aa^*$ in Kleene’s regular expressions). In the language ${\mathsf{Exp}}_{\mathcal{D}}$ it would be written as $\mu x. a(l<1>\oplus x)$. Using the approach described above it would be encoded as the expression $$\mu x.  <0,
<a(<1,<a(x),b(\mathit{empty}),c(\mathit{empty})>>),b(\mathit{empty}),c(\mathit{empty})>>$$ where $\mathit{empty}= \mu y. <0,<a(y), b(y), c(y)>$ is the expression denoting the empty language. The approach we presented before, by allowing underspecification, provides a more user-friendly syntax and stays close to the know syntaxes for deterministic automata and LTSs.

In what follows we will formally present a language for polynomial coalgebras. We start by introducing the definition of polynomial functor, which we take from [@adamek06].

Sums of the Cartesian power functors are called polynomial functors: $${\mathbf{P}}_\Sigma(X) = \coprod_{\sigma \in \Sigma} X^{\mathit{ar}(\sigma)}$$ Here, $\coprod$ stands for ordinary coproduct and the indexing set $\Sigma$ is a signature, that is a possibly infinite collection of symbols $\sigma$, each of which is equipped with a finite cardinal $\mathit{ar}(\sigma)$, called the arity of $\sigma$.

Let ${\mathbf{P}}_\Sigma$ be a polynomial functor. The set ${\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ of expressions for ${{\mathbf{P}}_\Sigma}$ is given by the closed and guarded expressions generated by the following BNF, where $\sigma\in \Sigma$ and $x\in V$, for $V$ a set of fixed point variables: $${\varepsilon}_i ::= x \mid \mu x. {\varepsilon}\mid \sigma({\varepsilon}_1, \ldots, {\varepsilon}_{\mathit{ar}(\sigma)})$$ accompanied by the equations: $$\begin{aligned}
&\gamma[\mu x.\gamma/x] \equiv \mu x . \gamma && \mathit{(FP)}  \\
&{\gamma[{\varepsilon}/x]  \equiv  {\varepsilon}\Rightarrow \mu
x.\gamma \equiv {\varepsilon}} &&\mathit{(Unique)}
\\
&{\varepsilon}_1\equiv {\varepsilon}_2 \Rightarrow {\varepsilon}[{\varepsilon}_1/x]\equiv {\varepsilon}[{\varepsilon}_2/x], \text{\ \ \ \  if
$x$ is free in ${\varepsilon}$}&& (\mathit{Cong})
\\
&\mu x.\gamma \equiv \mu y. \gamma[y/x],\ \ \   \text{ if
$y$ is not free in $\gamma$}& &\mathit {(\alpha-\mathit{equiv})} \end{aligned}$$

Providing the set ${\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ with a coalgebraic structure is achieved using induction on the number of unguarded occurrences of nested fixed points: $$\begin{array}{l}
\delta \colon {\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}\to \coprod\limits_{\sigma \in \Sigma} ({\mathsf{Exp}}_{{\mathbf{P}}_\Sigma})^{\mathit{ar}(\sigma)}\\
\delta(\mu x.{\varepsilon}) = \delta({\varepsilon}[\mu x.{\varepsilon}/x])\\
\delta(\sigma({\varepsilon}_1,\ldots,{\varepsilon}_{\mathit{ar}(\sigma)})) = \kappa_\sigma(<{\varepsilon}_1,\ldots,{\varepsilon}_{\mathit{ar}(\sigma)}>) 
\end{array}$$ We are now ready to state and prove Kleene’s theorem.

Let ${\mathbf{P}}_\Sigma$ be a polynomial functor.

1.  For every locally finite coalgebra $(S,g\colon S\to {\mathbf{P}}_\Sigma(S))$ and for every $s\in S$ there exists an expression ${\varepsilon}\in {\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ such that ${\varepsilon}\sim s$.

2.  For every expression ${\varepsilon}\in {\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ there is a finite coalgebra $(S, g\colon S\to {\mathbf{P}}_\Sigma(S))$ with $s\in S$ such that $s\sim {\varepsilon}$.

Point $1.$ amounts to solve a system of equations. Let $<s> = \{s_1,\ldots, s_n\}$. We associate with each $s_i \in <s>$ an expression $\expr{s_i} = A^n_i$, where $A^n_i$ is defined inductively as in the proof of \[kleene1\], with $A^{k+1}_i = A^k_i\{A^k_{k+1}/x_{k+1}\}$ and $A^0_i = A_i$ given by $$A_i = \mu x_{s_i}. \sigma(x_{s_1'}, \ldots, x_{s_{\mathit{ar}(\sigma)}'}), \ \ \ g(s_i) = \kappa_\sigma(s_{1}', \ldots, s_{\mathit{ar}(\sigma)}')$$ It remains to prove that $s_i \sim \expr{s_i}$, for all $s_i\in <s>$. We observe that $$R = \{ <s_i, \expr{s_i}> \mid s_i \in <s> \}$$ is a bisimulation, since, for $g(s_i) = \kappa_\sigma(s_{1}', \ldots, s_{\mathit{ar}(\sigma)}')$, we have $$\begin{array}{@{}ll}
\ \ \ \; \delta(\expr{s_i}) \\
= \delta((\mu x_i.  \sigma(x_{s_1'}, \ldots, x_{s_{\mathit{ar}(\sigma)}'}))  \{A^0_{1}/x_{1}\} \ldots \{A^{n-1}_{n}/x_{n}\}) \\[1.5ex]
=\delta(\mu x_i.  \sigma(x_{s_1'}, \ldots, x_{s_{\mathit{ar}(\sigma)}'})  \{A^0_{1}/x_{1}\} \ldots  \{A^{i-2}_{i-1}/x_{i-1}\}  \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\})\\[1.5ex]
=\delta( \sigma(x_{s_1'}, \ldots, x_{s_{\mathit{ar}(\sigma)}'})  \{A^0_{1}/x_{1}\} \ldots  \{A^{i-2}_{i-1}/x_{i-1}\}  \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\}[A^n_i/x_i])&  \\[1.5ex]
=\delta( \sigma(x_{s_1'}, \ldots, x_{s_{\mathit{ar}(\sigma)}'})  \{A^0_{1}/x_{1}\} \ldots  \{A^{i-2}_{i-1}/x_{i-1}\}  \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\}\{A^n_i/x_i\})&\\[1.5ex]
=\delta( \sigma(x_{s_1'}, \ldots, x_{s_{\mathit{ar}(\sigma)}'})\{A^0_{1}/x_{1}\} \ldots  \{A^{i-2}_{i-1}/x_{i-1}\} \{A^n_i/x_i\} \{A^i_{i+1}/x_{i+1}\} \ldots\{A^{n-1}_{n}/x_{n}\})&\\[1.5ex]
=\kappa_\sigma(\expr{s_1'},\ldots, \expr{s_{\mathit{ar}(\sigma)}'})
\end{array}$$ For point $2$, we observe that the subcoalgebra $<{\varepsilon}>$, for any ${\varepsilon}\in {\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ is finite, since the set $\mathit{cl}({\varepsilon})$ containing all sub-formulas and unfoldings of fixed points of ${\varepsilon}$, which is finite, is a subcoalgebra of $({\mathsf{Exp}}_{{\mathbf{P}}_\Sigma},\delta)$. The fact that in this point, contrary to what happened in Theorem \[kleene2\], we do not need to quotient the set of expressions is a direct consequence of the absence of underspecification or, more concretely, of the expressions ${\underline\emptyset}$ and $\oplus$.

The proof of soundness and completeness would follow a similar strategy as in the previous section and we will omit it here.

In order to be able to compare the language introduced in this section with the language obtained in our previous approach, we have to define an infinitary version of the operator ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$ and extend the framework accordingly. We start by defining the aforementioned operator on sets: ${\scalebox{1.5}{${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$}}_{i\in I} X_i = \left(\coprod_{i\in I} X_i\right) \cup \{\bot,\top\} $ and the corresponding functor, for which we shall use the same symbol, is defined pointwise in the same way as for ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$. Note that ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$ is a special case of this operator (resp. functor) for $I$ a two element set. In fact, for simplicity, we shall only consider this operator for index sets $I$ with two or more elements.

There is a natural transformation between polynomial functors and the class of non-deterministic functors extended with ${\scalebox{1.5}{${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$}}$: every polynomial functor ${\mathbf{P}}_\Sigma$ is mapped to $$\overline{{\mathbf{P}}}_\Sigma(X) = {\scalebox{1.5}{${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$}}_{\sigma\in \Sigma} \
X^{\mathit{ar}(\sigma)}$$ Next, we slightly alter the definition of expressions. Instead of the expressions $l[-]$ and $r[-]$ we had before for ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$ we add an expression $i[-]$ for each $i\in I$ and the expected typing rule: $${\mbox{$\frac                      {\mbox{\small \rule[-5pt]{0pt}{14pt} $\vdash {\varepsilon}\colon {\mathcal{F}}_j\lhd {\mathcal{G}}\ \ \ \ \ \ j\in I$}}
                      {\mbox{\small \rule[0pt]{0pt}{10pt}$\vdash j[{\varepsilon}] \colon  {\scalebox{1.5}{${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$}}_{i\in I} {\mathcal{F}}_i\lhd {\mathcal{G}}$}}$}}$$ All the other elements in our story are adjusted in the expected way. We show what happens in the axiomatization. For ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$ we had the rules $$\begin{array}{l}
 l[{\varepsilon}_1 \oplus {\varepsilon}_2] \equiv l[{\varepsilon}_1] \oplus l[{\varepsilon}_2] \ \ \ \ \ 
   r[{\varepsilon}_1 \oplus {\varepsilon}_2] \equiv r[{\varepsilon}_1] \oplus
r[{\varepsilon}_2]\ \ \ \ \ \ 
 l[{\varepsilon}_1] \oplus r[{\varepsilon}_2] \equiv l[{\underline\emptyset}] \oplus r[{\underline\emptyset}]
 \end{array}$$ which are now replaced by $$\begin{array}{l}
i[{\varepsilon}_1]\oplus i[{\varepsilon}_2] \equiv i[{\varepsilon}_1\oplus {\varepsilon}_2]\ \ \ \ \ \ 
i[{\varepsilon}_1]\oplus j[{\varepsilon}_2] \equiv k[{\underline\emptyset}]\oplus l[{\underline\emptyset}], \ \ \ \
i\neq j, k\neq l
\end{array}$$

It is natural to ask what is the relation between the sets of expressions ${\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ and ${\mathsf{Exp}}_{\overline{{\mathbf{P}}}_\Sigma}$. The set ${\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ is bijective to the subset of ${\mathsf{Exp}}_{\overline{{\mathbf{P}}}_\Sigma}$ containing only fully specified expressions, that is expressions ${\varepsilon}$ for which the subcoalgebra $<{\varepsilon}>$ does not contain any state for which $\delta_{\overline{{\mathbf{P}}}_\Sigma}$ evaluates to $\bot$ and $\top$. This condition is purely semantical and we were not able to find a purely syntactic restriction that would capture it.

We next repeat the exercise above for finitary functors. A finitary functor ${\mathbf{F}}$ is a functor that is a quotient of a polynomial functor, [*i.e.*]{} there exists a natural transformation $\eta\colon {\mathbf{P}}_\Sigma \to {\mathbf{F}}$, whose components $\eta_X\colon {\mathbf{P}}_\Sigma(X) \to
{\mathbf{F}}(X)$ are epimorphisms. We define ${\mathsf{Exp}}_{{\mathbf{F}}} =
{\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$.

Let ${\mathbf{F}}$ be a finitary functor.

1.  Let $(S,f)$ be a locally-finite ${\mathbf{F}}$-coalgebra. Then, for any $s \in S$, there exists an expression $\expr s \in {\mathsf{Exp}}_{{\mathbf{F}}}$ such that $s\sim
    \expr s$.

2.  Let ${\varepsilon}\in {\mathsf{Exp}}_{{\mathbf{F}}}$. Then, there exists a finite ${\mathbf{F}}$-coalgebra $(S,f)$ with $s\in S$ such that $s\sim {\varepsilon}$.

Let ${\mathbf{F}}$ be a finitary functor (quotient of a polynomial functor ${\mathbf{P}}_\Sigma$).

\(C) [1]{};

Let $(S,f)$ be a locally finite ${\mathbf{F}}$-coalgebra and let $s\in S$. We denote by $T = \{s_1,\ldots, s_n\}$ the state space of the subcoalgebra $<s>$ (with $s_1=s$). We then have that there exists an $f^\sharp$ making the following diagram commute: $$\xymatrix{T \ar[d]_{f^\sharp}\ar[r]^{\mathit{id}}& T\ar[d]^f\ar[r] & S\ar[d]^f\\
{\mathbf{P}}_\Sigma(T)\ar@{->>}[r]_{\eta_S} & {\mathbf{F}}(T)\ar[r]& {\mathbf{F}}(S)}$$ We then build $\expr{s}$ w.r.t $f^\sharp$ just as in Theorem \[kleene1\] (note that $(T,f^\sharp)$ is finite) and the result follows because $\expr s \sim_{{\mathbf{F}}} s \Leftarrow \expr s
\sim_{{\mathbf{P}}_\Sigma} s$ (consequence of naturality).

\(C) [2]{};

Let ${\varepsilon}\in {\mathsf{Exp}}_{{\mathbf{F}}}$. By Theorem \[kleene2\], there exists a finite ${\mathbf{P}}_\Sigma$-coalgebra $(S, f)$ with $s\in S$ such that $s\sim_{{\mathbf{P}}_\Sigma}
{\varepsilon}$. Thus, we take $(S, \eta_S\circ f)$ and we have a finite ${\mathbf{F}}$-coalgebra with $s\in S$ such that ${\varepsilon}\sim_{{\mathbf{F}}} s$.

For the axiomatization a bit more ingenuity is required. One needs to derive which extra axioms are induced by the epimorphism and then prove that they are sound and complete.

For instance, the finite powerset functor (which we included in the syntax of non-deterministic functors) is the classical example of a finitary functor. It is the quotient of the polynomial functor ${\mathbf{P}}_\Sigma(X)
= 1+X+X^2+\ldots$ (this represents lists of length $n$) by identifying lists that contain precisely the same elements (that is, eliminating repeated elements and abstracting from the ordering).

The syntax for ${\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}$ is the set of closed and guarded expressions given by the following BNF: $${\varepsilon}::= x \mid \mu x.{\varepsilon}\mid i({\varepsilon}_1,\ldots,{\varepsilon}_i), \ \ \ i\in \mathbb{N}\\$$ together with the axioms for the fixed point, $(\alpha-\mathit{equiv})$ and $\mathit{(Cong)}$.

Taking into account the restriction mentioned we would have to include the extra axioms: $$\begin{array}{l}
i({\varepsilon}_1,\ldots,{\varepsilon}_i) \equiv i({\varepsilon}_1',\ldots,{\varepsilon}_i') \text { if }
\{{\varepsilon}_1,\ldots {\varepsilon}_i\} =  \{{\varepsilon}_1',\ldots {\varepsilon}_i'\}\\
i({\varepsilon}_1,{\varepsilon}_2,\ldots,{\varepsilon}_i) \equiv (i-1)({\varepsilon}_1,{\varepsilon}_3,\ldots,{\varepsilon}_i) \text { if }
{\varepsilon}_1\equiv {\varepsilon}_2\\

\end{array}$$ In this case, one can see that this set of axioms is sound and complete, by simply proving, for ${\mathbf{P}}_\Sigma(X)
= 1+X+X^2+\ldots$, ${\mathsf{Exp}}_{{\mathbf{P}}_\Sigma}/_\equiv \cong {\mathsf{Exp}}_\pow/_\equiv$ (since we already had a language and sound and complete axiomatization for the $\pow$ functor). The restricted syntax and axioms needs to be derived for each concrete finitary functor. Finding a uniform way of defining such restricted syntax/axioms and also uniformly proving soundness and completeness is a challenging problem and it is left as future work.

Discussion {#sec:conclusions5}
==========

We presented a systematic way of deriving, from the type of a system, a language of (generalized) regular expressions and a sound and complete axiomatization thereof. We showed the analogue of Kleene’s theorem, proving the correspondence of the behaviours captured by the expressions and the systems under consideration. The whole approach was illustrated with five examples: deterministic finite automata, partial deterministic automata, nondeterministic automata, labelled transition systems and automata on guarded strings. Moreover, all the results presented in [@BRS08] for Mealy machines can be recovered as a particular instance of the present framework.

Iterative theories have been introduced by Elgot [@elgot] as a model of computation and they formalize potentially infinite computations as solutions of recursive equations. The main example of an iterative theory is the theory of regular trees, that is trees which have on finitely many distinct subtrees. Adámek, Milius and Velebil have presented Elgot’s work from a coalgebraic perspective [@AMV03; @adamekmscs2006], simplified some of his original proofs, and generalized the notion of free iterative theory to any finitary endofunctor of every locally presentable category. The language modulo the axioms we will associate with each functor is closely related to the work above: it is an initial iterative algebra. This also shows the connection of our work with the work by Bloom and Ésik on iterative algebras/theories [@BE93]. It would be interesting to investigate the connections with iterative algebras further.

In [@jacobs06], a bialgebraic review of deterministic automata and regular expressions was presented. One of the main results of [@jacobs06] was a description of the free algebra and Brzozowski coalgebra structure on regular expressions as a bialgebra with respect to a GSOS law. We expect that this extends to our framework, but fully working this out is left as future work.

In this paper we studied coalgebras for $\mathbf{Set}$ functors. It is an important and challenging question to extend our results to other categories. Following our work, S. Milius [@milius:lics10] has showed how to derive a language and sound and complete axiomatization for the functor $\mathbb R \times {\mathsf{Id}}$ in the category of vector spaces and linear maps. It would also be interesting to study functors over metric spaces [@TuriR98; @BreugelW06].

In his seminal paper [@kleene], S. Kleene introduced an algebraic description of regular languages: regular expressions. This was the precursor of many papers, including this one. Salomaa [@salomaa] presented a sound and complete axiomatization for proving the equivalence of regular expressions. This was later refined by Kozen in [@kozen]: he showed that Salomaa’s axiomatization is non-algebraic, in the sense that it is unsound under substitution of alphabet symbols by arbitrary regular expressions, and presented an algebraic axiomatization. In [@milner], Milner introduced a set of expressions for finite LTS’s and proved an analogue of Kleene’s theorem: each expression denotes the behaviour of a finite LTS and, conversely, the behaviour of a finite LTS can be specified by an expression. He also provided an axiomatization for his expressions, with the property that two expressions are provably equivalent if and only if they are bisimilar.

Our approach is inspired by the work of Kleene, Kozen and Milner. For that reason, we have ${\underline\emptyset}$ and $\oplus$ in the syntax of our expressions, which allow to have underspecification and overspecification. These features had to be reflected in the type of the coalgebras we are able to deal with: the class of functors considered include join-semilattices as constant functors and ${\mathbin{\rlap{$\myDiamond$}\hspace*{.01cm}\raisebox{.14ex}{$+$}}}$ instead of the ordinary coproduct, which has allowed us to remain in the category $\mathbf{Set}$. The fact that underspecification and overspecification can be captured by a semilattice structure, plus the fact that the axiomatization provides the set of expressions with a join semilattice structure, hint (as one of the reviewers pointed out) that the whole framework could have been studied directly in the category of join-semilattices. This is indeed true, but, for simplicity, we decided to remain in the category $\mathbf{Set}$. It is not clear how much could be gained by directly working on join semi-lattices.

The connection between regular expressions and coalgebras was first explored in [@Rut98c]. There deterministic automata, the set of formal languages and regular expressions are all presented as coalgebras of the functor $2 \times {\mathsf{Id}}^A$ (where $A$ is the alphabet, and $2$ is the two element set). It is then shown that the standard semantics of language acceptance of automata and the assignment of languages to regular expressions both arise as the unique homomorphism into the final coalgebra of formal languages. The coalgebra structure on the set of regular expressions is determined by their so-called [*Brzozowski*]{} derivatives [@Brz64]. In the present paper, the set of expressions for the functor ${\mathcal{D}}(S) = 2 \times S^A$ differs from the classical definition in that we do not have Kleene star and full concatenation (sequential composition) but, instead, the least fixed point operator and action prefixing. Modulo that difference, the definition of a coalgebra structure on the set of expressions in both [@Rut98c] and the present paper is essentially the same. All in all, one can therefore say that standard regular expressions and their treatment in [@Rut98c] can be viewed as a special instance of the present approach. This is also the case for the generalization of the results in [@Rut98c] to automata on guarded strings [@kozen08]. Finally, the present paper extends the results in our FoSSaCS’08 paper [@BRS08], where a sound and complete specification language and a synthesis algorithm for Mealy machines is given. Mealy machines are coalgebras of the functor $({\mathsf{B}}\times {\mathsf{Id}})^A$, where $A$ is a finite input alphabet and ${\mathsf{B}}$ is a finite semilattice for the output alphabet. Part of the material of the present paper is based on two conference papers: our FoSSaCS’09 paper [@regexp] and our LICS’09 paper [@BRS09b].

In the last few years, several proposals of specification languages for coalgebras appeared [@Moss99; @Rossiger00; @Jacobs01; @Gol02; @CirsteaP04; @Bonsangue-Kurz05; @Bonsangue-Kurz06; @SP07; @KV07]. Our approach is similar in spirit to that of [@Gol02; @Rossiger00; @Jacobs01; @SP07] in that we use the ingredients of a functor for typing expressions, and differs from [@Rossiger00; @Jacobs01] because we do not need an explicit “next-state” operator, as we can deduce it from the type information. The modal operators associated to a functor in [@Rossiger00; @Jacobs01; @SP07] can easily be related with the expressions considered in our language. As an example, consider the expression $<\pi_2>[\kappa_1]<\alpha> \bot$, written in the syntax of [@Rossiger00], which belongs to the language associated with the functor $2\times ({\mathsf{Id}}+ 1)$ (the modal operator $<\alpha>$ is next operator associated with the identity functor). In our language, this would be represented by $r<l[{\underline\emptyset}]>$.

Apart from [@KV07], the languages mentioned above do not include fixed point operators. Our language of regular expressions can be seen as an extension of the coalgebraic logic of [@Bonsangue-Kurz05] with fixed point operators, as well as the multi-sorted logics of [@SP07], and it is similar to a fragment of the logic presented in [@KV07]. However, our goal is rather different: we want (1) a finitary language that characterizes exactly all *locally finite* coalgebras; (2) a Kleene like theorem for the language or, in other words, a map (and not a relation) from expressions to coalgebras and vice-versa. Similar to many of the works above, we also derive a modular axiomatization, sound and complete with respect to observational equivalence. From the perspective of modal logic, the second half of Kleene’s theorem, where we show how to construct a coalgebra from an expression, is the same as constructing a canonical model. In [@SP07], the models presented for the multi-sorted logics are multi-sorted coalgebras, whereas here we remain in the world of coalgebras in the category **Set**, constructing, from an expression in ${\mathsf{Exp}}_{\mathcal{G}}$, for a given functor ${\mathcal{G}}$, a ${\mathcal{G}}$-coalgebra. Further exploring the connections with the approach presented in [@SP07] is a promising research path, opening the door to extending our framework for more general classes of functors.

In conclusion, we mention a recent generalization of the present approach: all the results presented in this paper can be extended in order to accommodate systems with *quantities*, such as probability or costs [@BBRS09]. The main technical challenge is that quantitative systems have an inherently non-idempotent behaviour and thus the proof of Kleene’s theorem and the axiomatization require extra care. This extension allows for the derivation of specification languages and axiomatizations for a wide variety of systems, which include weighted automata, simple probabilistic systems (also known as Markov chains) and systems with mixed probability and non-determinism (such as Segala systems). For instance, we have derived a language and an axiomatization for the so-called stratified systems. The language is equivalent to the one presented in [@GSS95], but no axiomatization was known.

The derivation of the syntax and axioms associated with each non-deterministic functor has been implemented in the coinductive prover CIRC [@circ]. This allows for automatic reasoning about the equivalence of expressions specifying systems.

#### **Acknowledgements.**

The authors are grateful for useful comments from several people: Filippo Bonchi, Helle Hansen, Bartek Klin, Dexter Kozen, Clemens Kupke, Stefan Milius, Prakash Panagaden, Ana Sokolova, Yde Venema and Erik de Vink. The title of this paper was inspired by the title of a section of a paper of Dexter Kozen [@kozen08]. The proof of soundness and completeness was simplified (when compared with the one presented in our LICS paper [@BRS09b]) inspired by recent work of Stefan Milius on expressions for linear systems (personal communication). Finally, we would like to thank the three anonymous reviewers for their very detailed reports, which greatly improved the presentation of the paper.

[^1]: [a]{}The first author was partially supported by the Fundação para a Ciência e a Tecnologia, Portugal, under grant number SFRH/BD/27482/2006.

[^2]: Actually, to guarantee finiteness, similar to classical regular expressions, it is enough to eliminate double occurrences of expressions ${\varepsilon}$ at the outermost level of an expression $\cdots \oplus {\varepsilon}\oplus \cdots \oplus {\varepsilon}\oplus \cdots$ (and to do this one needs the ACI axioms). Note that this is weaker than taking expressions modulo the ACI axioms: for instance, the expressions ${\varepsilon}_1\oplus {\varepsilon}_2$ and ${\varepsilon}_2\oplus
    {\varepsilon}_1$, for ${\varepsilon}_1\neq {\varepsilon}_2$, would not be identified in the process above.

[^3]: This is equivalent to prove that ${\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}/_{\equiv_{\mathit{ACIE}}}$, together with $[-]_{\mathit{ACIE}}$, is the coequalizer of the projection morphisms from $\equiv_{\mathit{ACIE}}$ to ${\mathsf{Exp}}_{{\mathcal{F}}\lhd {\mathcal{G}}}$.

[^4]: This syntax was suggested to us by B. Klin, during CONCUR’09.
