NON-DETERMINISTIC KLEENE COALGEBRAS

Similar documents
Coalgebra, Lecture 15: Equations for Deterministic Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Handout: Natural deduction for first order logic

CS 275 Automata and Formal Language Theory

Lecture 1. Functional series. Pointwise and uniform convergence.

THE EXISTENCE-UNIQUENESS THEOREM FOR FIRST-ORDER DIFFERENTIAL EQUATIONS.

The Regulated and Riemann Integrals

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

1.3 Regular Expressions

Advanced Calculus: MATH 410 Notes on Integrals and Integrability Professor David Levermore 17 October 2004

Lecture 08: Feb. 08, 2019

20 MATHEMATICS POLYNOMIALS

Minimal DFA. minimal DFA for L starting from any other

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

p-adic Egyptian Fractions

Deriving Syntax and Axioms for Quantitative Regular Behaviours

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Theory of Computation Regular Languages

Review of basic calculus

A tutorial on sequential functions

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

Lecture 9: LTL and Büchi Automata

W. We shall do so one by one, starting with I 1, and we shall do it greedily, trying

Bisimulation. R.J. van Glabbeek

UNIFORM CONVERGENCE. Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3

State Minimization for DFAs

Categorical approaches to bisimilarity

CSCI FOUNDATIONS OF COMPUTER SCIENCE

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Relating logic to formal languages

MAA 4212 Improper Integrals

CS 275 Automata and Formal Language Theory

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Duality # Second iteration for HW problem. Recall our LP example problem we have been working on, in equality form, is given below.

1.4 Nonregular Languages

Strong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation

Lecture 09: Myhill-Nerode Theorem

Review of Riemann Integral

3 Regular expressions

Closure Properties of Regular Languages

COMPUTER SCIENCE TRIPOS

Improper Integrals, and Differential Equations

Formal languages, automata, and theory of computation

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

More on automata. Michael George. March 24 April 7, 2014

Harvard University Computer Science 121 Midterm October 23, 2012

Exam 2, Mathematics 4701, Section ETY6 6:05 pm 7:40 pm, March 31, 2016, IH-1105 Instructor: Attila Máté 1

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

How to simulate Turing machines by invertible one-dimensional cellular automata

Chapter 0. What is the Lebesgue integral about?

Finite Automata-cont d

7.2 The Definite Integral

CS375: Logic and Theory of Computing

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

Physics 116C Solution of inhomogeneous ordinary differential equations using Green s functions

and that at t = 0 the object is at position 5. Find the position of the object at t = 2.

Math 1B, lecture 4: Error bounds for numerical methods

Bernoulli Numbers Jeff Morton

1 From NFA to regular expression

Math 61CM - Solutions to homework 9

Formal Languages and Automata

CM10196 Topic 4: Functions and Relations

Parse trees, ambiguity, and Chomsky normal form

Riemann Sums and Riemann Integrals

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

MATH 101A: ALGEBRA I PART B: RINGS AND MODULES 35

Checking NFA equivalence with bisimulations up to congruence

CMSC 330: Organization of Programming Languages

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Regular expressions, Finite Automata, transition graphs are all the same!!

CS5371 Theory of Computation. Lecture 20: Complexity V (Polynomial-Time Reducibility)

Unit #9 : Definite Integral Properties; Fundamental Theorem of Calculus

Integral points on the rational curve

Notes on length and conformal metrics

Probabilistic Model Checking Michaelmas Term Dr. Dave Parker. Department of Computer Science University of Oxford

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

1 Probability Density Functions

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Introduction to Group Theory

Riemann Sums and Riemann Integrals

1.9 C 2 inner variations

Nondeterminism and Nodeterministic Automata

Chapter 14. Matrix Representations of Linear Transformations

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

1 Sets Functions and Relations Mathematical Induction Equivalence of Sets and Countability The Real Numbers...

Recitation 3: More Applications of the Derivative

Automata and Languages

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

arxiv: v1 [math.ra] 1 Nov 2014

Universal coalgebra: a theory of systems

f(x) dx, If one of these two conditions is not met, we call the integral improper. Our usual definition for the value for the definite integral

CS 330 Formal Methods and Models

THE QUADRATIC RECIPROCITY LAW OF DUKE-HOPKINS. Circa 1870, G. Zolotarev observed that the Legendre symbol ( a p

Supervisory Control (4CM30)

Transcription:

Logicl Methods in Computer Science Vol. 6 (3:23) 2010, pp. 1 1 39 www.lmcs-online.org Submitted Jn. 3, 2010 Published Sep. 9, 2010 NON-DETERMINISTIC KLEENE COALGEBRAS ALEXANDRA SILVA, MARCELLO BONSANGUE b, AND JAN RUTTEN c CWI, Amsterdm, The Netherlnds e-mil ddress: ms@cwi.nl b LIACS, University of Leiden,The Netherlnds e-mil ddress: mrcello@lics.nl c CWI (Amsterdm), VUA (Amsterdm) nd RUN (Nijmegen), The Netherlnds e-mil ddress: jnr@cwi.nl Abstrct. In this pper, we present systemtic wy of deriving (1) lnguges of (generlised) regulr expressions, nd (2) sound nd complete xiomtiztions thereof, for wide vriety of systems. This generlizes both the results of Kleene (on regulr lnguges nd deterministic finite utomt) nd Milner (on regulr behviours nd finite lbelled trnsition systems), nd includes mny other systems such s Mely nd Moore mchines. 1. Introduction In previous pper [9], we presented lnguge to describe the behviour of Mely mchines nd sound nd complete xiomtiztion thereof. The defined lnguge nd xiomtiztion cn be seen s the nlogue of clssicl regulr expressions [21] nd Kleene lgebr [22], for deterministic finite utomt (DFA), or the process lgebr nd xiomtiztion for lbelled trnsition systems (LTS) [28]. We now extend the previous pproch nd devise frmework wherein lnguges nd xiomtiztions cn be uniformly derived for lrge clss of systems, including DFA, LTS nd Mely mchines, which we will model s colgebrs. Colgebrs provide generl frmework for the study of dynmicl systems such s DFA, Mely mchines nd LTS. For functor G: Set Set, G-colgebr or G-system is pir (S,g), consisting of set S of sttes nd function g: S G(S) defining the trnsitions of the sttes. We cll the functor G the type of the system. For instnce, DFA cn be modelled s colgebrs of the functor G(S) = 2 S A, Mely mchines re obtined by tking G(S) = (B S) A nd imge-finite LTS re colgebrs for the functor G(S) = (P ω (S)) A, where P ω is finite powerset. 2000 ACM Subject Clssifiction: F3.1, F3.2, F4.1. Key words nd phrses: Colgebr, Kleene s theorem, xiomtiztion. The first uthor ws prtilly supported by the Fundção pr Ciênci e Tecnologi, Portugl, under grnt number SFRH/BD/27482/2006. LOGICAL METHODS Ð IN COMPUTER SCIENCE DOI:10.2168/LMCS-6 (3:23) 2010 c A. Silv, M. Bonsngue, nd J. Rutten CC Cretive Commons

2 A. SILVA, M. BONSANGUE, AND J. RUTTEN Under mild conditions, functors G hve finl colgebr (unique up to isomorphism) into which every G-colgebr cn be mpped vi unique so-clled G-homomorphism. The finl colgebr cn be viewed s the universe of ll possible G-behviours: the unique homomorphism into the finl colgebr mps every stte of colgebr to cnonicl representtive of its behviour. This provides generl notion of behviourl equivlence: two sttes re equivlent if nd only if they re mpped to the sme element of the finl colgebr. Instntiting the notion of finl colgebr for the forementioned exmples, the result is s expected: for DFA the finl colgebr is the set 2 A of ll lnguges over A; for Mely mchines it is the set of cusl functions f: A ω B ω ; nd for LTS it is the set of finitely brnching trees with rcs lbelled by A modulo bisimilrity. The notion of equivlence lso specilizes to the fmilir notions: for DFA, two sttes re equivlent when they ccept the sme lnguge; for Mely mchines, if they relize (or compute) the sme cusl function; nd for LTS if they re bisimilr. It is the min im of this pper to show how the type of system, given by the functor G, is not only enough to determine notion of behviour nd behviourl equivlence, but lso llows for uniform derivtion of both set of expressions describing behviour nd corresponding xiomtiztion. The theory of universl colgebr [31] provides stndrd equivlence nd universl domin of behviours, uniquely bsed on the functor G. The min contributions of this pper re (1) the definition of set of expressions Exp G describing G-behviours, (2) the proof of the correspondence between behviours described by Exp G nd loclly finite G-colgebrs (this is the nlogue of Kleene s theorem), nd (3) corresponding sound nd complete xiomtiztion, with respect to bisimultion, of Exp G (this is the nlogue of Kleene lgebr). All these results re solely bsed on the type of the system, given by the functor G. In nutshell, we combine the work of Kleene with colgebr, considering the clss of non-deterministic functors. Hence, the title of the pper: non-deterministic Kleene colgebrs. Orgniztion of the pper. In Section 2 we introduce the clss of non-deterministic functors nd colgebrs. In Section 3 we ssocite with ech non-deterministic functor G generlized lnguge Exp G of regulr expressions nd we present n nlogue of Kleene s theorem, which mkes precise the connection between Exp G nd G-colgebrs. A sound nd complete xiomtiztion of Exp G is presented in Section 4. Section 5 contins two more exmples of ppliction of the frmework nd Section 6 shows lnguge nd xiomtiztion for the clss of polynomil nd finitry colgebrs. Section 7 presents concluding remrks, directions for future work nd discusses relted work. This pper is n extended version of [11, 10]: it includes ll the proofs, more exmples nd explntions, new mteril bout polynomil nd finitry functors nd n extended discussion section. 2. Preliminries We give the bsic definitions on non-deterministic functors nd colgebrs nd introduce the notion of bisimultion. First we fix nottion on sets nd opertions on them. Let Set be the ctegory of sets nd functions. Sets re denoted by cpitl letters X,Y,... nd functions by lower cse f,g,... We write for the empty set nd the collection of ll finite subsets of set X is defined s P ω (X) = {Y X Y finite}. The collection of functions from set X to set

NON-DETERMINISTIC KLEENE COALGEBRAS 3 Y is denoted by Y X. We write id X for the identity function on set X. Given functions f : X Y nd g : Y Z we write their composition s g f. The product of two π 1 π 2 sets X,Y is written s X Y, with projection functions X X Y Y.The set 1 is singleton set typiclly written s 1 = { } nd it cn be regrded s the empty product. We define X + Y s the set X Y {, }, where is the disjoint union of κ 2 sets, with injections X κ 1 X Y Y. Note tht the set X + Y is different from the clssicl coproduct of X nd Y (which we shll denote by X +Y), becuse of the two extr elements nd. These extr elements will lter be used to represent, respectively, underspecifiction nd inconsistency in the specifiction of some systems. The intuition behind the need of these extr elements will become cler when we present our lnguge of expressions nd concrete exmples, in Section 3.3.1, of systems whose type involves +. Note tht X +X = 2 X = X +X. For ech of the opertions defined bove on sets, there re nlogous ones on functions. Let f: X Y, f 1 : X Y nd f 2 : Z W. We define the following opertions: f 1 f 2 : X Z Y W f 1 +f 2 : X +Z Y +W (f 1 f 2 )( x,z ) = f 1 (x),f 2 (z) (f 1 +f 2 )(c) = c, c {, } (f 1 +f 2 )(κ i (x)) = κ i (f i (x)), i {1,2} f A : X A Y A P ω (f): P ω (X) P ω (Y) f A (g) = f g P ω (f)(s) = {f(x) x S} Note tht here we re using the sme symbols tht we defined bove for the opertions on sets. It will lwys be cler from the context which opertion is being used. In our definition of non-deterministic functors we will use constnt sets equipped with n informtion order. In prticulr, we will use join-semilttices. A (bounded) join-semilttice is set B equipped with binry opertion B nd constnt B B, such tht B is commuttive, ssocitive nd idempotent. The element B is neutrl with respect to B. As usul, B gives rise to prtil ordering B on the elements of B: b 1 B b 2 b 1 B b 2 = b 2 Every set S cn be mpped into join-semilttice by tking B to be the set of ll finite subsets of S with union s join. Non-deterministic functors. Non-deterministic functors re functors G: Set Set, built inductively from the identity nd constnts, using, +, ( ) A nd P ω. Definition 2.1. The clss NDF of non-deterministic functors on Set is inductively defined by putting: NDF G:: = Id B G +G G G G A P ω G where B is finite (non-empty) join-semilttice nd A is finite set. Since we only consider finite exponents A = { 1,..., n }, the functor ( ) A is not relly needed, since it is subsumed by product with n components. However, to simplify the presenttion, we decided to include it.

4 A. SILVA, M. BONSANGUE, AND J. RUTTEN Next, weshowtheexplicitdefinitionofthefunctorsboveonsetx ndonmorphism f: X Y (note tht G(f): G(X) G(Y)). Id(X) = X B(X) = B (G 1 +G 2 )(X) = G 1 (X) +G 2 (X) Id(f) = f B(f) = id B (G 1 +G 2 )(f) = G 1 (f) +G 2 (f) (G A )(X) = G(X) A (P ω G)(X) = P ω (G(X)) (G 1 G 2 )(X) = G 1 (X) G 2 (X) (G A )(f) = G(f) A (P ω G)(f) = P ω (G(f)) (G 1 G 2 )(f) = G 1 (f) G 2 (f) Typicl exmples of non-deterministic functors include M = (B Id) A, D = 2 Id A, Q = (1 + Id) A nd N = 2 (P ω Id) A, where 2 = {0,1} is two-element join semilttice with 0 s bottom element (1 0 = 1) nd 1 = { } is one element join-semilttice. These functors represent, respectively, the type of Mely, deterministic, prtil deterministic nd non-deterministic utomt. In this pper, we will use the lst three s running exmples. In [9], we hve studied in detil regulr expressions for Mely utomt. Similrly to wht hppened there, we impose join-semilttice structure on the constnt functor. The product, exponentition nd powerset functors preserve the join-semilttice structure nd thus do not need to be chnged. This is not the cse for the clssicl coproduct nd thus we use + insted, which lso gurntees tht the join semilttice structure is preserved. Next, we give the definition of the ingredient reltion, which reltes non-deterministic functor G with its ingredients, i.e. the functors used in its inductive construction. We shll use this reltion lter for typing our expressions. Definition 2.2. Let NDF NDF be the lest reflexive nd trnsitive reltion on nondeterministic functors such tht G 1 G 1 G 2, G 2 G 1 G 2, G 1 G 1 +G 2, G 2 G 1 +G 2, G G A, G P ω G Here nd throughout this document we use F G s shorthnd for F,G. If F G, then F is sid to be n ingredient of G. For exmple, 2, Id, Id A nd D itself re ll the ingredients of the deterministic utomt functor D = 2 Id A. Non-deterministic colgebrs. A non-deterministic colgebr is pir(s, f: S G(S)), where S is set of sttes nd G is non-deterministic functor. The functor G, together with the function f, determines the trnsition structure (or dynmics) of the G-colgebr [31]. Mely, deterministic, prtil deterministic nd non-deterministic utomt re, respectively, colgebrs for the functors M = (B Id) A, D = 2 Id A, Q = (1 +Id) A nd N = 2 (P ω Id) A. A G-homomorphism from G-colgebr (S, f) to G-colgebr (T, g) is function h: S T preserving the trnsition structure, i.e. such tht g h = G(h) f. Definition 2.3. A G-colgebr (Ω,ω) is sid to be finl if for ny G-colgebr (S,f) there exists unique G-homomorphism beh S : S Ω. For every non-deterministic functor G there exists finl G-colgebr (Ω G,ω G ) [31]. For instnce, s we lredy mentioned in the introduction, the finl colgebr for the functor D is the set of lnguges 2 A over A, together with trnsition function d : 2 A 2 (2 A ) A defined s d(φ) = φ(ǫ), λλw.φ(w). Here ǫ denotes the empty sequence nd w denotes the word resulting from prefixing w with the letter. The notion of finlity will ply key role lter in providing semntics to expressions. Given G-colgebr (S,f) nd subset V of S with inclusion mp i: V S we sy tht V is subcolgebr of S if there exists g: V G(V) such tht i is homomorphism.

NON-DETERMINISTIC KLEENE COALGEBRAS 5 Given s S, s = (T,t), denotes the smllest subcolgebr generted by s, with T given by T = {V V is subcolgebr of S nd s V} If the functor F preserves rbitrry intersections, then the subcolgebr s exists. This will be the cse for every functor considered in this pper. Moreover, ll the functors we will consider preserve monos nd thus the trnsition structure t is unique [31, Proposition 6.1]. We will write Colg(G) for the ctegory of G-colgebrs together with colgebr homomorphisms. WelsowriteColg LF (G) forthectegory ofg-colgebrs thtreloclly finite. Objects re G-colgebrs (S,f) such tht for ech stte s S the generted subcolgebr s is finite. Mps re the usul homomorphisms of colgebrs. Let (S,f) nd (T,g) be two G-colgebrs. We cll reltion R S T bisimultion [18] iff s,t R f(s),g(t) G(R) where G(R) is defined s G(R) = { G(π 1 )(x),g(π 2 )(x) x G(R)}. We write s G t wheneverthereexists bisimultion reltion contining (s,t) ndwecll G thebisimilrity reltion. We shll drop the subscript G whenever the functor G is cler from the context. For ll non-deterministic G-colgebrs (S,f) nd (T,g) nd s S,t T, it holds tht s t beh S (s) = beh T (t) (the left to right impliction lwys holds, wheres the right to left impliction only holds for certin clsses of functors, which include the ones we consider in this pper [31, 35]). 3. A lnguge of expressions for non-deterministic colgebrs In this section, we generlize the clssicl notion of regulr expressions to non-deterministic colgebrs. We strt by introducing n untyped lnguge of expressions nd then we single out the well-typed ones vi n pproprite typing system, thereby ssociting expressions to non-deterministic functors. Definition 3.1 (Expressions). Let A be finite set, B finite join-semilttice nd X set of fixed point vribles. The set Exp of ll expressions is given by the following grmmr, where A, b B nd x X: ε :: = x ε ε µx.γ b l ε r ε l[ε] r[ε] (ε) {ε} where γ is gurded expression given by: γ :: = γ γ µx.γ b l ε r ε l[ε] r[ε] (ε) {ε} The only difference between the BNF of γ nd ε is the occurrence of x. In the expression µx.γ, µ is binder for ll the free occurrences of x in γ. Vribles tht re not bound re free. A closed expression is n expression without free occurrences of fixed point vribles x. We denote the set of closed expressions by Exp c. Intuitively, expressions denote elements of the finl colgebr. The expressions, ε 1 ε 2 nd µx.ε will ply similr role to, respectively, the empty lnguge, the union of lnguges nd the Kleene str in clssicl regulr expressions for deterministic utomt. The expressions l ε nd r ε refer to the left nd right hnd-side of products. Similrly, l[ε] nd r[ε] refer to the left nd right hnd-side of sums. The expressions (ε) nd {ε} denote function ppliction nd singleton set, respectively. We shll soon illustrte, by mens

6 A. SILVA, M. BONSANGUE, AND J. RUTTEN of exmples, the role of these expressions. Here, it is lredy visible tht our pproch (to define lnguge) for the powerset functor differs from clssicl modl logic where nd re used. This is choice, justified by the fct tht our gol is to hve process lgebr like lnguge insted of modl logic one. It lso explins why we only consider finite powerset: every finite set cn be written s the finite union of its singletons. Our lnguge does not hve ny opertor denoting intersection or complement (it only includes the sum opertor ). This is nturl restriction, very much in the spirit of Kleene s regulr expressions for deterministic finite utomt. We will prove tht this simple lnguge is expressive enough to denote exctly ll loclly finite colgebrs. Next, we present typing ssignment system for ssociting expressions to non-deterministic functors. This will llow us to ssocite with ech functor G the expressions ε Exp c tht re vlid specifictions of G-colgebrs. The typing proceeds following the structure of the expressions nd the ingredients of the functors. Definition 3.2 (Type system). We define typing reltion Exp NDF NDF tht will ssocite n expression ε with two non-deterministic functors F nd G, which re relted by the ingredient reltion (F is n ingredient of G). We shll write ε: F G for ε,f,g. The rules tht define re the following: : F G b: B G x: G G ε: G G µx.ε: G G ε 1 : F G ε 2 : F G ε: G G ε: F G ε: F G ε 1 ε 2 : F G ε: Id G {ε}: P ω F G (ε): F A G ε: F 1 G l ε : F 1 F 2 G ε: F 2 G r ε : F 1 F 2 G ε: F 1 G l[ε]: F 1 +F 2 G ε: F 2 G r[ε]: F 1 +F 2 G Intuitively, ε: F G (for closed expression ε) mens tht ε denotes n element of F(Ω G ), where Ω G is the finl colgebr of G. As expected, there is rule for ech expression construct. The extr rule involving Id G reflects the isomorphism between the finl colgebr Ω G nd G(Ω G ) (Lmbek s lemm, cf. [31]). Only fixed points t the outermost level of the functor re llowed. This does not men however tht we disllow nested fixed points. For instnce, µx. (x µy. (y)) would be well-typed expression for the functor D of deterministic utomt, s it will become cler below, when we will present more exmples of well-typed nd non-well-typed expressions. The presented type system is decidble (expressions re of finite length nd the system is inductive on the structure of ε Exp). Note tht the rules bove re ment to be red s n inductive definition rther thn s n lgorithm. In n eventul implementtion, extr cre is needed in the cse G = Id, to void looping in the rule for Id G. We cn formlly define the set of G-expressions: (closed nd gurded) well-typed expressions ssocited with non-deterministic functor G. Definition 3.3 (G-expressions). Let G be non-deterministic functor nd F n ingredient of G. We define Exp F G by: Exp F G = {ε Exp c ε: F G}. We define the set Exp G of well-typed G-expressions by Exp G G.

NON-DETERMINISTIC KLEENE COALGEBRAS 7 Let us instntite the definition of G-expressions to the functors of deterministic utomt D = 2 Id A. Exmple 3.4 (Deterministic expressions). Let A be finite set of input ctions nd let X be set of (recursion or) fixed point vribles. The set Exp D of deterministic expressions is given bytheset ofclosed ndgurded(ech vribleoccursinthescopeof( )) expressions generted by the following BNF grmmr. For A nd x X: Exp D ε :: = ε ε µx.ε x l ε 1 r ε 2 ε 1 :: = 0 1 ε 1 ε 1 ε 2 :: = (ε) ε 2 ε 2 Exmples of well-typed expressions for the functor D = 2 Id A (with 2 = {0,1} two-element join-semilttice with 0 s bottom element; recll tht the ingredients of D re 2, Id A nd D itself) include r ( ), l 1 r (l 0 ) nd µx.r (x) l 1. The expressions l[1], l 1 1 nd µx.1 re exmples of non well-typed expressions for D, becuse the functor D does not involve +, the subexpressions in the sum hve different type, nd recursion is not t the outermost level (1 hs type 2 D), respectively. It is esy to see tht the closed (nd gurded) expressions generted by the grmmr presented bove re exctly the elements of Exp D. The most interesting cse to check is the expression r (ε). Note tht (ε) hs type Id A D s long s ε hs type Id D. And the crucil remrk here is tht, by definition of, Exp Id G Exp G. Therefore, ε hs type Id D if it is of type D D, or more precisely, if ε Exp D, which explins why the grmmr bove is correct. At this point, we should remrk tht the syntx of our expressions differs from the clssicl regulr expressions in the use of µ nd ction prefixing (ε) insted of str nd full conctention. We shll prove lter tht these two syntcticlly different formlisms re eqully expressive (Theorems 3.12 nd 3.14), but, to increse the intuition behind our expressions, let us present the syntctic trnsltion from clssicl regulr expressions to Exp D (this trnsltion is inspired by [28]) nd bck. Definition 3.5. The set of regulr expressions is given by the following syntx RE r:: = 0 1 r+r r r r where A nd denotes sequentil composition. We define the following trnsltions between regulr expressions nd deterministic expressions: ( ) : RE Exp D ( ) : Exp D RE (0) = ( ) = 0 (1) = l 1 (l ) = (l 0 ) = (r ) = 0 () = r (l 1 ) (l 1 ) = 1 (r 1 +r 2 ) = (r 1 ) (r 2 ) (l ε 1 ε 2 ) = (l ε 1 ) +(l ε 2 ) (r 1 r 2 ) = (r 1 ) [(r 2 ) /l 1 ] (r (ε) ) = (ε) (r ) = µx.(r) [x/l 1 ] l 1 (r ε 1 ε 2 ) = (r ε 1 ) +(r ε 2 ) (ε 1 ε 2 ) = (ε 1 ) +(ε 2 ) (µx.ε) = sol(eqs(µx.ε)) The function eqs trnsltes µx.ε into system of equtions in the following wy. Let µx 1.ε 1,...,µx n.ε n bell the fixed point subexpressionsof µx.ε, with x 1 = x nd ε 1 = ε. We

8 A. SILVA, M. BONSANGUE, AND J. RUTTEN define n equtions x i = (ε i ), where ε i is obtined from ε i by replcing ech subexpression µx i.ε i byx i, forlli = 1,...n. Thesolution ofthesystem, sol(eqs(µx.ε)), isthencomputed in the usul wy (the solution of n eqution of shpe x = rx+t is r t). In [32], regulr expressions were given colgebric structure, using Brzozowski derivtives [13]. Lter in this pper, we will provide colgebr structure to Exp D, fter which the soundness of the bove trnsltions cn be stted nd proved: r r nd ε ε, where will coincide with lnguge equivlence. Thus, the regulr expression is trnslted to r (µx.r (x) l 1 ), wheres the expression µx.r (r (x) ) l 1 is trnsformed into (). We present next the syntx for the expressions in Exp Q nd in Exp N (recll tht Q = (1 +Id) A nd N = 2 (P ω Id) A ). Exmple 3.6 (Prtil expressions). Let A be finite set of input ctions nd X be set of (recursion or) fixed point vribles. The set Exp Q of prtil expressions is given by the set of closed nd gurded expressions generted by the following BNF grmmr. For A nd x X: Exp Q ε :: = ε ε µx.ε x (ε 1 ) ε 1 :: = ε 1 ε 1 l[ε 2 ] r[ε] ε 2 :: = ε 2 ε 2 Intuitively, the expressions (l[ ]) nd (r[ε]) specify, respectively, stte which hs no defined trnsition for input nd stte with n outgoing trnsition to nother one specified by ε. Exmple 3.7 (Non-deterministic expressions). Let A be finite set of input ctions nd X be set of (recursion or) fixed point vribles. The set Exp N of non-deterministic expressions is given by the set of closed nd gurded expressions generted by the following BNF grmmr. For A nd x X: Exp N ε :: = x r ε 2 l ε 1 ε ε µx.ε ε 1 :: = ε 1 ε 1 1 0 ε 2 :: = ε 2 ε 2 (ε ) ε :: = ε ε {ε} Intuitively, the expression r ({ε 1 } {ε 2 }) specifies stte which hs two outgoing trnsitions lbelled with the input letter, one to stte specified by ε 1 nd nother to stte specified by ε 2. We hve defined lnguge of expressions which gives us n lgebric description of systems. We should lso remrk t this point tht in the exmples we strictly follow the type system to derive the syntx of the expressions. However, it is obvious tht mny simplifictions cn be mde in order to obtin more polished lnguge. In prticulr, fter the xiomtiztion we will be ble to decrese the number of levels in the bove grmmrs, since will we hve xioms of the shpe (ε) (ε ) (ε ε ). In Section 5, we will sketch two exmples where we pply some simplifiction to the syntx. The gol is now to present generliztion of Kleene s theorem for non-deterministic colgebrs (Theorems 3.12 nd 3.14). Recll tht, for regulr lnguges, the theorem sttes tht lnguge is regulr if nd only if it is recognized by finite utomton. In order to chieve our gol we will first show tht the set Exp G of G-expressions crries G-colgebr structure.

NON-DETERMINISTIC KLEENE COALGEBRAS 9 3.1. Expressions re colgebrs. In this section, we show tht the set of G-expressions for given non-deterministic functor G hs colgebric structure δ G : Exp G G(Exp G ). More precisely, we re going to define function δ F G : Exp F G F(Exp G ) for every ingredient F of G, nd then set δ G = δ G G. Our definition of the function δ F G will mke use of the following. Definition 3.8. For every G NDF nd for every F with F G: (i) we define constnt Empty F G F(Exp G ) by induction on the syntctic structure of F: Empty Id G = Empty F1 +F 2 G = Empty B G = B Empty F A G = λ.empty F G Empty F1 F 2 G = Empty F1 G,Empty F2 G = Empty PωF G (ii) we define function Plus F G : F(Exp G ) F(Exp G ) F(Exp G ) by induction on the syntctic structure of F: Plus Id G (ε 1,ε 2 ) = ε 1 ε 2 Plus B G (b 1,b 2 ) = b 1 B b 2 Plus F1 F 2 G( ε 1,ε 2, ε 3,ε 4 ) = Plus F1 G(ε 1,ε 3 ),Plus F2 G(ε 2,ε 4 ) Plus F1 +F 2 G (κ i(ε 1 ),κ i (ε 2 )) = κ i (Plus Fi G(ε 1,ε 2 )), i {1,2} Plus F1 +F 2 G (κ i(ε 1 ),κ j (ε 2 )) = i,j {1,2} nd i j Plus F1 +F 2 G (x, ) = Plus F 1 +F 2 G (,x) = Plus F1 +F 2 G (x, ) = Plus F 1 +F 2 G (,x) = x Plus F A G(f,g) = λ. Plus F G (f(),g()) Plus PωF G(s 1,s 2 ) = s 1 s 2 Intuitively, one cn think of the constnt Empty F G nd the function Plus F G s liftings of nd to the level of F(Exp G ). We need two more things to define δ F G. First, we define n order on the types of expressions. For F 1, F 2 nd G non-deterministic functors such tht F 1 G nd F 2 G, we define (F 1 G) (F 2 G) F 1 F 2 The order is prtil order (structure inherited from ). Note lso tht (F 1 G) = (F 2 G) F 1 = F 2. Second, we define mesure N(ε) bsed on the mximum number of nested ungurded occurrences of µ-expressions in ε nd ungurded occurrences of. We sy tht subexpression µx.ε 1 of ε occurs ungurded if it is not in the scope of one of the opertors l, r, l[ ], r[ ], ( ) or { }. Definition 3.9. For every gurded expression ε, we define N(ε) s follows: N( ) = N(b) = N((ε)) = N(l ε ) = N(r ε ) = N(l[ε]) = N(r[ε]) = N({ε}) = 0 N(ε 1 ε 2 ) = 1+mx{N(ε 1 ), N(ε 2 )} N(µx.ε) = 1+N(ε) ThemesureN inducesprtil orderon theset of expressions: ε 1 ε 2 N(ε 1 ) N(ε 2 ), where is just the ordinry inequlity of nturl numbers. Now we hve ll we need to define δ F G : Exp F G F(Exp G ).

10 A. SILVA, M. BONSANGUE, AND J. RUTTEN Definition 3.10. For every ingredient F of non-deterministic functor G nd n expression ε Exp F G, we define δ F G (ε) s follows: δ F G ( ) = Empty F G δ F G (ε 1 ε 2 ) = Plus F G (δ F G (ε 1 ),δ F G (ε 2 )) δ G G (µx.ε) = δ G G (ε[µx.ε/x]) δ Id G (ε) = ε for G Id δ B G (b) = b δ F1 F 2 G(l ε ) = δ F1 G(ε),Empty F2 G δ F1 F 2 G(r ε ) = Empty F1 G,δ F2 G(ε) δ F1 +F 2 G (l[ε]) = κ 1(δ F1 G(ε)) δ F1 +F 2 G (r[ε]) = κ 2(δ { F2 G(ε)) δ F A G((ε)) = λ δf G (ε) if =. Empty F G otherwise δ PωF G({ε}) = {δ F G (ε)} Here, ε[µx.ε/x] denotes syntctic substitution, replcing every free occurrence of x in ε by µx.ε. In order to see tht the definition of δ F G is well-formed, we hve to observe tht δ F G cn be seen s function hving two rguments: the type F G nd the expression ε. Then, we use induction on the Crtesin product of types nd expressions with orders nd, respectively. More precisely, given two pirs F 1 G,ε 1 nd F 2 G,ε 2 we hve n order F 1 G,ε 1 F 2 G,ε 2 (i) (F 1 G) (F 2 G) or (ii) (F 1 G) = (F 2 G) nd ε 1 ε 2 (3.1) Observe tht in the definition bove it is lwys true tht F G,ε F G,ε, for ll occurrences of δ F G(ε ) occurring in the right hnd side of the eqution defining δ F G (ε). In ll cses, but the ones tht ε is fixed point or sum expression, the inequlity comes from point (i) bove. For the cse of the sum, note tht F G,ε 1 F G,ε 1 ε 2 nd F G,ε 2 F G,ε 1 ε 2 by point (ii), since N(ε 1 )<N(ε 1 ε 2 ) nd N(ε 2 )<N(ε 1 ε 2 ). Similrly, in the cse of µx.ε we hve tht N(ε) = N(ε[µx.ε/x]), which cn esily be proved by (stndrd) induction on the syntctic structure of ε, since ε is gurded (in x), nd this gurntees tht N(ε[µx.ε/x])<N(µx.ε). Hence, G G,ε G G,µx.ε. Also note tht cluse 4 of the bove definition overlps with cluses 1 nd 2 (by tking F = Id). However, they give the sme result nd thus the function δ F G is well-defined. Definition 3.11. We define, for ech non-deterministic functor G, G-colgebr by putting δ G = δ G G. δ G : Exp G G(Exp G ) The function δ G cn be thought of s the generliztion of the well-known notion of Brzozowski derivtive [13] for regulr expressions nd, moreover, it provides n opertionl semntics for expressions, s we shll see in Section 3.2. The observtion tht the set of expressions hs colgebr structure will be crucil for the proof of the generlized Kleene theorem, s will be shown in the next two sections.

NON-DETERMINISTIC KLEENE COALGEBRAS 11 3.2. Expressions re expressive. Hving G-colgebr structure on Exp G hs two dvntges. First, it provides us, by finlity, directly with nturl semntics becuse of the existence of (unique) homomorphism beh: Exp G Ω G, tht ssigns to every expression ε n element beh(ε) of the finl colgebr Ω G. The second dvntge of the colgebr structure on Exp G is tht it lets us use the notion of G-bisimultion to relte G-colgebrs (S,g) nd expressions ε Exp G. If one cn construct bisimultion reltion between n expression ε nd stte s of given colgebr, then the behviour represented by ε is equl to the behviour of the stte s. This is the nlogue of computing the lnguge L(r) represented by given regulr expression r nd the lnguge L(s) ccepted by stte s of finite stte utomton nd checking whether L(r) = L(s). The following theorem sttes tht every stte in loclly finite G-colgebr cn be represented by n expression in our lnguge. This generlizes hlf of Kleene s theorem for deterministic utomt: if lnguge is ccepted by finite utomton then it is regulr (i.e. it cn be denoted by regulr expression). The generliztion of the other hlf of the theorem (if lnguge is regulr then it is ccepted by finite utomton) will be presented in Section 3.3. It is worth to remrk tht in the usul definition of deterministic utomton the initil stte of the utomton is included nd, thus, in the originl Kleene s theorem, it ws enough to consider finite utomt. In the colgebric pproch, the initil stte is not explicitly modelled nd thus we need to consider loclly-finite colgebrs: colgebrs where ech stte will generte finite subcolgebr. Theorem 3.12. Let G be non-deterministic functor nd let (S, g) be loclly-finite G- colgebr. Then, for ny s S, there exists n expression s Exp G such tht s s. Proof. Let s S nd let s = {s 1,...,s n } with s 1 = s. We construct, for every stte s i s, n expression s i such tht s i s i. If G = Id, we set, for every i, s i =. It is esy to see tht { s i, s i s } is bisimultion nd, thus, we hve tht s s. For G Id, we proceed in the following wy. Let, for every i, A i = µx i.γ G g(s i ) where, for F G nd c F s, the expression γc F Exp F G is defined by induction on the structure of F: γ Id s i = x i γ B b = b γf 1 F 2 c,c = l γ F 1 c r γ F 2 c γ FA f = A(γ F f() ) γ F 1 +F 2 κ 1 (c) = l[γ F 1 c ] γ F 1 +F 2 κ 2 (c) = r[γ F 2 c ] γ F 1 +F 2 = γ F 1 +F 2 = l[ ] r[ ] {γ γ PωF c F} C C = c C otherwise Note tht here the choice of l[ ] r[ ] to represent inconsistency is rbitrry but cnonicl, in the sense tht ny other expression involving sum of l[ε 1 ] nd r[ε 2 ] will be bisimilr. Formlly, the definition of γ bove is prmetrized by function from {s 1,...,s n } to fixed set of vribles {x 1,...,x n }. Itshouldlso benoted tht i Iε i stndsforε 1 (ε 2 (ε 3...)) (this is choice, since lter we will xiomtize to be commuttive nd ssocitive). Let A 0 i = A i, define A k+1 i = A k i {Ak k+1 /x k+1} nd then set s i = A n i. Here, A{A /x} denotes syntctic replcement (tht is, substitution without renming of bound vribles in A which re lso free vribles in A ). The definition of s i does not depend in the

12 A. SILVA, M. BONSANGUE, AND J. RUTTEN chosen order of {s 1,...,s n }: the expressions obtined re just different modulo renming of vribles. Observe tht the term A n i = (µx i.γ G g(s i ) ){A0 1 /x 1}...{A n 1 n /x n } is closed term becuse, for every j = 1,...,n, the term A j 1 j contins t most n j free vribles in the set {x j+1,...,x n }. It remins to prove tht s i s i. We show tht R = { s i, s i s i s } is bisimultion. For tht, we define, for F G nd c F s, ξc F = γc F {A 0 1 /x 1}...{An n 1 /x n } nd the reltion R F G = { c,δ F G (ξc F ) c F s }. Then, we prove tht 1 R F G = F(R) nd 2 g(s i ),δ G ( s i ) R G G. 1 By induction on the structure of F. F = Id Note tht R Id G = { s i,ξs Id i s i s } which is equl to Id(R) = R provided tht ξs Id i = s i. The ltter is indeed the cse: ξ Id s i = γ Id s i {A 0 1 /x 1}...{A n 1 n /x n } = x i {A 0 1 /x 1}...{A n 1 n /x n } (def. ξ Id s i ) (def. γ Id s i ) = Ai i 1 {A i i+1 /x i+1}...{an n 1 /x n } ({A i 1 i /x i }) = A 0 i {A0 1 /x 1}...{An n 1 /x n } (def. A i 1 i ) = s i (def. s i ) F = B Note tht, for b B, ξ B b = γb b {A0 1 /x 1}...{A n 1 n /x n } = b. Thus, we hve tht R B G = { s i,ξ B s i s i B s } = { b,b b B} = B(R). F = F 1 F 2 u,v, e,f F 1 F 2 (R) u,e F 1 (R) nd v,f F 2 (R) (def. F 1 F 2 ) u,e R F1 G nd v,f R F2 G u,e = c,δ F1 G(ξ F 1 c ) nd v,f = c,δ F2 G(ξ F 2 c ) (ind. hyp.) (def. R Fi G) u,v = c,c nd e,f = δ F1 F 2 G(l(ξ F 1 c ) r(ξ F 2 c )) (def. δ F G ) u,v = c,c nd e,f = δ F1 F 2 G(ξ F 1 F 2 c,c ) (def. ξ F ) u,v, e,f R F1 F 2 G F = F 1 +F 2, F = F A 1 nd F = P ω F 1 : similr to F 1 F 2. 2 We wnt to prove tht g(s i ),δ G ( s i ) R G G. For tht, we must show tht g(s i ) G s nd δ G ( s i ) = δ G (ξ G g(s i )). The former follows by definition of s, wheres for the ltter we observe tht: δ G ( s i ) = δ G ((µx i.γ G g(s i) ){A0 1 /x 1}...{A n 1 n /x n }) (def. of s i ) = δ G (µx i.γ G g(s i) {A0 1 /x 1}...{A i 2 i 1 /x i 1}{A i i+1 /x i+1}...{a n 1 n /x n })

NON-DETERMINISTIC KLEENE COALGEBRAS 13 = δ G (γ G g(s i) {A0 1/x 1 }...{A i 2 i 1 /x i 1}{A i i+1 /x i+1}...{a n 1 n /x n }[A n i /x i]) (def. of δ G ) = δ G (γ G g(s i) {A0 1 /x 1}...{A i 2 i 1 /x i 1}{A i i+1 /x i+1}...{an n 1 /x n }{A n i /x i}) ([A n i /x i] = {A n i /x i}) = δ G (γ G g(s i) {A0 1/x 1 }...{A i 2 i 1 /x i 1}{A n i /x i}{a i i+1 /x i+1}...{a n 1 n /x n }) = δ G (ξ G g(s i) ) Here, note tht [A n i /x i] = {A n i /x i}, becuse A n i hs no free vribles. The lst two steps follow, respectively, becuse x i is not free in A i i+1,...,an 1 n nd: {A n i /x i}{a i i+1 /x i+1}...{an n 1 /x n } = {A i 1 i {A i i+1 /x i+1}...{an n 1 /x n }/x i }{A i i+1 /x i+1}...{an n 1 /x n } = {A i 1 i /x i }{A i i+1/x i+1 }...{A n 1 n /x n } (3.2) Eqution (3.2) uses the syntctic identity A{B{C/y}/x}{C/y} = A{B/x}{C/y}, y not free in C (3.3) Let us illustrte the construction ppering in the proof of Theorem 3.12 by some exmples. These exmples will illustrte the similrity with the proof of Kleene s Theorem presented in most textbooks, where regulr expression denoting the lnguge recognized by stte of deterministic utomton is built using system of equtions. Consider the following deterministic utomton over A = {, b}, whose trnsition function g is given by the following picture ( s represents tht the stte s is finl): b s 1 s 2,b We define A 1 = µx 1.γ D g(s 1 ) nd A 2 = µx 2.γ D g(s 2 ) where γ D g(s 1 ) = l 0 r b(x 1) (x 2 ) γ D g(s 2 ) = l 1 r (x 2) b(x 2 ) We hve A 2 1 = A 1{A 1 2 /x 2} nd A 2 2 = A 2{A 0 1 /x 1}. Thus, s 2 = A 2 nd, since A 1 2 = A 2, s 1 is the expression µx 1.l 0 r b(x 1 ) (µx 2.l 1 r (x 2 ) b(x 2 ) ) By construction we hve s 1 s 1 nd s 2 s 2. For nother exmple, tke the following prtil utomton, lso over two letter lphbet A = {,b}: q 1 In the grphicl representtion of prtil utomton (S, p) we omit trnsitions for which p(s)() = κ 1 ( ). In this cse, this hppens in q 1 for the input letter b nd in q 2 for. We will hve the equtions q 2 A 1 = A 0 1 = A1 1 = µx 1.b(l[ ]) (r[x 2 ]) A 2 = A 0 2 = A1 2 = µx 2.(l[ ]) b(r[x 2 ]) b

14 A. SILVA, M. BONSANGUE, AND J. RUTTEN Thus: s 1 = A 2 1 = µx 1.b(l[ ]) (r[µx 2.(l[ ]) b(r[x 2 ])]) s 2 = µx 2.(l[ ]) b(r[x 2 ]) Agin we hve s 1 s 1 nd s 2 s 2. As lst exmple, let us consider the following non-deterministic utomton, over one letter lphbet A = {}: We strt with the equtions: s 1 Then we hve the following itertions: A 1 1 = A 1 s 3 A 1 = µx 1.l 0 r ({x 1 } {x 2 } {x 3 }) A 2 = µx 2.l 0 r ({x 2 } {x 3 }) A 3 = µx 3.l 1 r ({x 1 } {x 3 }) A 2 1 = A 1{A 1 2 /x 2} = µx 1.l 0 r ({x 1 } {A 2 } {x 3 }) A 3 1 = A 1{A 1 2 /x 2}{A 2 3 /x 3} = µx 1.l 0 r ({x 1 } {(A 2 {A 2 3 /x 3})} {A 2 3 }) s 2 A 1 2 = A 2{A 1 /x 1 } = A 2 A 2 2 = A 2{A 1 /x 1 } = A 2 A 3 2 = A 2{A 1 /x 1 }{A 2 3 /x 3} = µx 2.l 0 r ({x 2 } {A 2 3 }) A 1 3 = A 3{A 1 /x 1 } = µx 3.l 1 r ({A 1 } {x 3 }) A 2 3 = A 3{A 1 /x 1 }{A 1 2 /x 2} = µx 3.l 1 r ({(A 1 {A 1 2 /x 2})} {x 3 }) A 3 3 = A2 3 This yields the following expressions: s 1 = µx 1.l 0 r ({x 1 } { s 2 } { s 3 }) s 2 = µx 2.l 0 r ({x 2 } { s 3 }) s 3 = µx 3.l 1 r ({µx 1.l 0 r ({x 1 } {µx 2.l 0 r ({x 2 } {x 3 }) } {x 3 }) } {x 3 }) 3.3. Finite systems for expressions. Next, we prove the converse of Theorem 3.12, tht is, we show how to construct finite G-colgebr (S,g) from n rbitrry expression ε Exp G, such tht there exists stte s S with ε G s. The immedite wy of obtining colgebr from n expression ε Exp G is to compute the subcolgebr ε, since we hve provided the set Exp G with colgebr structure δ G : Exp G G(Exp G ). However, the subcolgebr generted by n expression ε Exp G by repetedly pplying δ G is, in generl, infinite. Tke for instnce the deterministic expression ε 1 = µx.r (x µy.r (y) ) (for simplicity, we consider A = {} nd below we will write,

NON-DETERMINISTIC KLEENE COALGEBRAS 15 in the second component of δ D, n expression ε insted of the function mpping to ε) nd observe tht: δ D (ε 1 ) = 0,ε 1 µy.r (y) δ D (ε 1 µy.r (y) ) = 0,ε 1 µy.r (y) µy.r (y) δ D (ε 1 µy.r (y) µy.r (y) ) = 0,ε 1 µy.r (y) µy.r (y) µy.r (y). As one would expect, ll the new sttes re equivlent nd will be identified by beh (the morphism into the finl colgebr). However, the function δ D does not mke ny stte identifiction nd thus yields n infinite colgebr. This phenomenon occurs lso in clssicl regulr expressions. It ws shown in [13] tht normlizing the expressions using the xioms for ssocitivity, commuttivity nd idempotency ws enough to gurntee finiteness 1. We will show in this section tht this lso holds in our setting. Consider the following xioms (only the first three re essentil, but we include the fourth to obtin smller colgebrs): (Associtivity) ε 1 (ε 2 ε 3 ) (ε 1 ε 2 ) ε 3 (Commuttivity) ε 1 ε 2 ε 2 ε 1 (Idempotency) ε ε ε (Empty) ε ε We define the reltion ACIE Exp F G Exp F G, written infix, s the lest equivlence reltioncontiningthefouridentitiesbove. Thereltion ACIE givesrisetothe(surjective) equivlence mp[ε] ACIE = {ε ε ACIE ε }. Thefollowing digrm showsthempsdefined so fr: Exp F G [ ] ACIE Exp F G / ACIE δ F G F(Exp G ) F([ ] ACIE ) F(Exp G / ACIE ) In order to complete the digrm, we next prove tht ACIE is contined in the kernel of F([ ] ACIE ) δ F G 2. This will gurntee the existence of function δ F G : Exp F G / ACIE F(Exp G / ACIE ) which, when F = G, provides Exp G / with colgebric structure δ G : Exp G / ACIE G(Exp G / ACIE ) (s before we write δ G for δ G G ) nd which mkes [ ] ACIE homomorphism of colgebrs. 1 Actully, to gurntee finiteness, similr to clssicl regulr expressions, it is enough to eliminte double occurrences of expressions ε t the outermost level of n expression ε ε (nd to do this one needs the ACI xioms). Note tht this is weker thn tking expressions modulo the ACI xioms: for instnce, the expressions ε 1 ε 2 nd ε 2 ε 1, for ε 1 ε 2, would not be identified in the process bove. 2 This is equivlenttoprove tht ExpF G / ACIE, together with [ ] ACIE, is the coequlizer of the projection morphisms from ACIE to Exp F G.

16 A. SILVA, M. BONSANGUE, AND J. RUTTEN Lemm 3.13. Let G nd F be non-deterministic functors, with F G. For ll ε 1,ε 2 Exp F G, ε 1 ACIE ε 2 (F([ ] ACIE ))(δ F G (ε 1 )) = (F([ ] ACIE ))(δ F G (ε 2 )) Proof. In order to improve redbility, in this proof we will use [ ] to denote [ ] ACIE. It is enough to prove tht for ll x 1,x 2,x 3 F(Exp G ): 1 F([ ])(Plus F G (Plus F G (x 1,x 2 ),x 3 )) = F([ ])(Plus F G (x 1,Plus F G (x 2,x 3 ))) 2 F([ ])(Plus F G (x 1,x 2 )) = F([ ])(Plus F G (x 2,x 1 )) 3 F([ ])(Plus F G (x 1,x 1 )) = F([ ])(x 1 ) 4 F([ ])(Plus F G (Empty F G,x 1 )) = F([ ])(x 1 ) By induction on the structure of F. We illustrte few cses, the omitted ones re proved in similr wy. F = Id x 1,x 2,x 3 Exp G 1 [Plus Id G (Plus Id G (x 1,x 2 ),x 3 )] = [(x 1 x 2 ) x 3 ] (def. Plus) = [x 1 (x 2 x 3 )] (Associtivity) = [Plus Id G (x 1,Plus Id G (x 2,x 3 ))] (def. Plus) 4 [Plus Id G (Empty Id G,x 1 )] = [ x 1 ] (def. Plus nd Empty) = [x 1 ] (Empty) F = F 1 F 2 x 1 = u 1,v 1,x 2 = u 2,v 2 (F 1 F 2 )(Exp G ) 2 (F 1 F 2 )([ ])(Plus F1 F 2 G( u 1,v 1, u 2,v 2 )) = F 1 ([ ])(Plus F1 G(u 1,u 2 )),F 2 ([ ])(Plus F2 G(v 1,v 2 )) (def. Plus) = F 1 ([ ])(Plus F1 G(u 2,u 1 )),F 2 ([ ])(Plus F2 G(v 2,v 1 )) (ind. hyp.) = (F 1 F 2 )([ ])(Plus F1 F 2 G( u 2,v 2, u 1,v 1 )) (def. Plus) 3 (F 1 F 2 )([ ])(Plus F1 F 2 G( u 1,v 1, u 1,v 1 )) = F 1 ([ ])(Plus F1 G(u 1,u 1 )),F 2 ([ ])(Plus F2 G(v 1,v 1 )) (def. Plus) = F 1 ([ ])(u 1 ),F 2 ([ ])(v 1 ) (ind. hyp.) = (F 1 F 2 )([ ])( u 1,v 1 ) F = P ω F 1 x 1,x 2,x 3 P ω F 1 (Exp G ) 1 P ω F 1 ([ ])(Plus PωF 1 G(x 1,Plus PωF 1 G(x 2,x 3 ))) = P ω F 1 ([ ])(x 1 (x 2 x 3 )) (def. Plus) = P ω F 1 ([ ])((x 1 x 2 ) x 3 ) = P ω F 1 ([ ])(Plus PωF 1 G(Plus PωF 1 G(x 1,x 2 ),x 3 )) (def. Plus) In thelst butonestep, we usethefct tht, for ny setx, (P ω (X),, ) is join-semilttice (hence, x 1 (x 2 x 3 ) = (x 1 x 2 ) x 3 ). Due to this fct, in the cse F = P ω F 1, in this prticulr proof, the induction hypothesis will not be used.

NON-DETERMINISTIC KLEENE COALGEBRAS 17 Thus, we hve well-defined function δ F G : Exp F G / ACIE F(Exp G / ACIE ) such tht δ F G ([ε] ACIE ) = (F[ ] ACIE )(δ F G (ε)). We re redy to stte nd prove the second hlf of Kleene s theorem. Theorem 3.14. Let G be non-deterministic functor. For every ε Exp G, there exists G (ε) = (S,g) such tht S is finite nd there exists s S with ε s. Proof. For every ε Exp G, we set G (ε) = [ε] ACIE (recll tht s denotes the smllest subcolgebr generted by s). First note tht, by Lemm 3.13, the mp [ ] ACIE is homomorphism nd thus ε [ε] ACIE. We prove, for every ε Exp G, tht the subcolgebr [ε] ACIE = (V,δ G ) hs finite stte spce V (here, δ G ctully stnds for the restriction of δ G to V). Agin, in order to improve redbility, below we will use [ ] to denote [ ] ACIE. More precisely, we prove, for ll ε Exp F G, the following inclusion V V = {[ε 1... ε k ] ε 1,...,ε k cl(ε) ll distinct,ε 1,...,ε k Exp G } (3.4) Here, if k = 0 we tke the sum bove to be nd cl(ε) denotes the smllest set contining ll subformuls of ε nd the unfoldings of µ (sub)formuls, tht is, the smllest subset stisfying: cl( ) = { } cl(l[ε 1 ]) = {l[ε 1 ]} cl(ε 1 ) cl(ε 1 ε 2 ) = {ε 1 ε 2 } cl(ε 1 ) cl(ε 2 ) cl(r[ε 1 ]) = {r[ε 1 ]} cl(ε 1 ) cl(µx.ε 1 ) = {µx.ε 1 } cl(ε 1 [µx.ε 1 /x]) cl((ε 1 )) = {(ε 1 )} cl(ε 1 ) cl(l ε 1 ) = {l ε 1 } cl(ε 1 ) cl({ε 1 }) = {{ε 1 }} cl(ε 1 ) cl(r ε 1 ) = {r ε 1 } cl(ε 1 ) Note tht the set cl(ε) is finite (the number of different unfoldings is finite) nd hs the property ε cl(ε). We prove the inclusion in eqution (3.4) in the following wy. First, we observe tht [ε] V, becuse ε cl(ε). Then, we prove tht (V,δ G ) (gin, δ G ctully stnds for the restriction of δ G to V) is subcolgebr of (Exp G,δ G ). Thus, V V, since V, the stte spce of [ε] is equl to the intersection of ll subcolgebrs of (Exp G,δ G ) contining [ε]. To prove tht (V,δ G ) is subcolgebr we prove tht, for ε 1,...,ε k Exp F G, ε 1,...,ε k cl(ε) ll distinct δ F G ([ε 1... ε k ]) F(V) (3.5) The intended result then follows by tking F = G. We first prove two uxiliry results, by induction on the structure of F: 1 (F[ ])(Empty F G ) F(V) 2 (F[ ])(Plus F G (u,v)) F(V) (F[ ])(u) F(V) nd (F[ ])(v) F(V) for u,v F(Exp G ). F = Id 1 (F[ ])(Empty F G ) = [ ] V 2 (F[ ])(Plus F G (u,v)) = [u v] V [u] V nd [v] V u,v Exp G The right to left impliction follows becuse, using the (Associtivity), (Commuttivity) nd (Idempotency) xioms, we cn rewrite u v s ε 1... ε k, with ll ε 1,...,ε k cl(ε) distinct.

18 A. SILVA, M. BONSANGUE, AND J. RUTTEN F = B 1 (B[ ])(Empty B G ) = B B(V) 2 (B[ ])(Plus B G (u,v)) = u v B(V) u B(V) nd v B(V) u,v B(Exp G ) = B F = F 1 F 2 1 (F 1 F 2 [ ])(Empty F1 F 2 G) = (F 1 [ ])(Empty F1 G),(F 2 [ ])(Empty F2 G) F 1 F 2 (V) 2 (F 1 F 2 [ ])(Plus F1 F 2 G( u 1,u 2, v 1,v 2 )) = (F 1 [ ])(Plus F1 G(u 1,v 1 )),(F 2 [ ])(Plus F2 G(u 2,v 2 )) F 1 F 2 (V) (IH) u 1,v 1 F 1 (V) nd u 2,v 2 F 2 (V) u,v F 1 F 2 (V), u = u 1,u 2,v = v 1,v 2 F 1 F 2 (Exp G ) F = F 1 +F 2 nd F = F A 1 : similr to F 1 F 2. F = P ω F 1 1 (PωF[ ])(EmptyPωF G) = PωF(V) 2 (P ω F[ ])(Plus PωF G(u,v)) = ((P ω F[ ])(u) (P ω F[ ])(v)) P ω F(V) (P ω F[ ](u)) P ω F(V) nd (P ω F[ ](v)) P ω F(V) Using 2, we cn simplify our proof gol (eqution (3.5)) s follows: δ F G ([ε 1... ε k ]) F(V) (F[ ])(δ F G (ε i )) F(V), ε i cl(ε), i = 1,...,k Next, using induction on the product of types of expressions nd expressions(using the order in eqution (3.1)), 1 nd 2, we prove tht (F[ ])(δ F G (ε i )) F(V), for ny ε i cl(ε). (F[ ])(δ F G ( )) = (F[ ])(Empty F G ) F(V) (by 1 ) (F[ ])(δ F G (ε 1 ε 2 )) = (F[ ])(Plus F G (δ F G (ε 1 ),δ F G (ε 2 )) F(V) (IH nd 2 ) (G[ ])(δ G G (µx.ε)) = (G[ ])(δ G G (ε[µx.ε/x])) G(V) (Id[ ])(δ Id G (ε i )) = [ε i ] Id(V) for G Id (IH) (ε i cl(ε)) (B[ ])δ B G (b) = b B(V) (B(V) = B) (F 1 F 2 [ ])(δ F1 F 2 G(l ε )) = (F 1 [ ])(δ F1 G(ε)),(F 2 [ ])(Empty F2 G) F 1 F 2 (V) (IH nd 1 ) (F 1 F 2 [ ])(δ F1 F 2 G(r ε )) = (F 1 [ ])(Empty F1 G),(F 2 [ ])(δ F2 G(ε)) F 1 F 2 (V) (IH nd 1 ) (F 1 +F 2 [ ])(δ F1 +F 2 G (l[ε])) = κ 1((F 1 [ ])(δ F1 G(ε))) F 1 +F 2 (V) (IH) (F 1 +F 2 [ ])(δ F1 +F 2 G (r[ε])) = κ 2((F 2 [ ])(δ F2 G(ε))) F 1 +F 2 (V) (IH) ( { (F A [ ])(δ F A G((ε))) = λ (F[ ])(δf G (ε)) if =. ) F Empty F G otherwise A (V) (IH nd 1 ) (P ω F[ ])(δ PωF G({ε})) = {(F[ ])(δ F G (ε))} P ω F(V) (IH)

NON-DETERMINISTIC KLEENE COALGEBRAS 19 3.3.1. Exmples. n this subsection we will illustrte the construction described in the proof of Theorem 3.14: given n expression ε Exp G we construct G-colgebr (S,g) such tht there is s S with s ε. For simplicity, we will consider deterministic nd prtil utomt expressions over A = {, b}. Let us strt by showing the synthesised utomt for the most simple deterministic expressions, l 0 nd l 1.,b,b,b l 0,b l 1,b The first two utomt recognize the empty lnguge nd the lst the lnguge {ǫ} contining only the empty word. We note tht the generted utomt re not miniml (for instnce, the utomt for l 0 nd re bisimilr). Our gol hs been to generte finite utomton from n expression. From this the miniml utomton cn lwys be obtined by identifying bisimilr sttes. The following utomton, generted from the expression r (l 1 ), recognizes the lnguge {}, r (l 1 ) l 1 b,b For n exmple of n expression contining fixed points, consider ε = µx. r (l 0 l 1 x). One cn esily compute the synthesised utomton: µx.r (l 0 l 1 x) b,b l 0 l 1 ε nd observe tht it recognizes the lnguge. Here, the role of the join-semilttice structure is lso visible: l 0 l 1 ε specifies tht this stte is supposed to be non-finl (l 0 ) nd finl (l 1 ). The conflict of these two specifictions is solved, when they re combined with, using the semilttice: becuse 1 0 = 1 the stte is set to be finl. As lst exmple of deterministic expressions consider ε 1 = µx.r (x µy.r (y) ). Applying δ D to ε 1 one gets the following (prtil) utomton: b,b µx.r (x µy.r (y) ) ε 1 µy.r (y) b Clculting δ D (ε 1 µy.r (y) ) yields δ D (ε 1 µy.r (y) ) = 0,t where t() = ε 1 µy.r (y) µy.r (y) t(b) =

20 A. SILVA, M. BONSANGUE, AND J. RUTTEN Note tht the expression ε 1 µy.r (y) µy.r (y) is in the sme equivlence clss s ε 1 µy.r (y), which is stte tht lredy exists. As we sw in the beginning of Section 3.1, by only pplying δ D, without ACI, one would lwys generte syntcticlly different sttes which insted of the utomton computed now: µx.r (x µy.r (y) ) ε 1 µy.r (y) b would yield the following infinite utomton (with ε 2 = µy.r (y) ): µx.r (x µy.r (y) ) b ε 1 ε 2 ε 1 ε 2 ε 2,b... b b b Let us next see few exmples of synthesis for prtil utomt expressions, where we will illustrte the role of nd. In the grphicl representtion of prtil utomton (S,p), we will omit trnsitions for inputs with g(s)() = κ 1 ( ) nd we will drw s g(s)() whenever g(s)() {, }. Note however tht S nd S nd thus will hve no defined trnsitions. As before, let us first present the corresponding utomt for simple expressions, (l[ ]), ( ) nd (l[ ]) b(l[ ]).,b b,b (l[ ]) b ( ),b (l[ ]) b(l[ ]) Note how is used to encode underspecifiction, working s kind of dedlock stte. In the first three expressions the behviour for one or both of the inputs is missing, wheres in the lst expression the specifiction is complete. The element is used to del with inconsistent specifictions. For instnce, consider the expression (l[ ]) b(l[ ]) (r[(l[ ]) b(l[ ])]). All inputs re specified, but note tht t the outermost level input ppers in two different sub-expressions (l[ ]) nd (r[(l[ ]) b(l[ ])]) specifying t the sme time tht input leds to successful termintion nd tht it leds to stte where (l[ ]) b(l[ ]) holds, which is contrdictory, giving rise to the following utomton. (l[ ]) b(l[ ]) (r[(l[ ]) b(l[ ])]) 4. A sound nd complete xiomtiztion In the previous section, we hve shown how to derive from the type of system, given by functor G, lnguge Exp G tht llows for specifiction of G-behviours. Anlogously to Kleene s theorem, we hve proved the correspondence between the behviours denoted by Exp G nd loclly finite G-colgebrs. In this section, we will show how to provide Exp G with sound nd complete xiomtiztion. Agin, the functor G will serve s min guide

NON-DETERMINISTIC KLEENE COALGEBRAS 21 for the definition. The defined xiomtiztion is closely relted to Kleene lgebr (the set of expressions hs join semilttice structure) nd to the xiomtiztion provided by Milner for CCS (uniqueness of fixed points will be required). When instntiting the definition below to concrete functors one will recover known xiomtiztions, such s the one for CCS mentioned bove or the one for lbelled trnsition systems (with explicit termintion) presented in [1]. The ltter will be discussed in detil in Section 5. Next, we introduce n equtionl system for expressions of type F G. We define the reltion Exp F G Exp F G, written infix, s the lest equivlence reltion contining the following identities: (1) (Exp F G,, ) is join-semilttice. ε ε ε ε 1 ε 2 ε 2 ε 1 ε 1 (ε 2 ε 3 ) (ε 1 ε 2 ) ε 3 ε ε (2) µ is the unique fixed point. γ[µx.γ/x] µx.γ γ[ε/x] ε µx.γ ε (Idempotency) (Commuttivity) (Associtivity) (Empty) (FP) (Unique) (3) The join-semilttice structure propgtes through the expressions. B (B ) b 1 b 2 b 1 B b 2 (B ) l ( L) l ε 1 ε 2 l ε 1 l ε 2 ( L) r ( R) r ε 1 ε 2 r ε 1 r ε 2 ( R) ( ) ( A ) (ε 1 ε 2 ) (ε 1 ) (ε 2 ) ( A ) l[ε 1 ε 2 ] l[ε 1 ] l[ε 2 ] (+ L) r[ε 1 ε 2 ] r[ε 1 ] r[ε 2 ] (+ R) l[ε 1 ] r[ε 2 ] l[ ] r[ ] (+ ) (4) is congruence. (5) α-equivlence ε 1 ε 2 ε[ε 1 /x] ε[ε 2 /x] for x free in ε µx.γ µy.γ[y/x] for y not free in γ (Cong) (α equiv) It is importnt to remrk tht in the third group of rules there does not exist ny rule pplicble to expressions of type P ω F. Exmple 4.1. Consider the non-deterministic utomt over the lphbet A = {}: s 1 Applying (s defined in the proof of Theorem 3.12) one cn esily compute the expressions corresponding to s 1 nd s 2 : ε 1 = s 1 = µx 1.l 0 r ({x 1 }) ε 2 = s 2 = µy 1.l 0 r ({µy 2.l 0 r ({µy 1.l 0 r ({y 2 }) }) }) s 2 s 3