Lecture three: Automata and the algebra-coalgebra duality Jan Rutten CWI Amsterdam & Radboud University Nijmegen IPM, Tehran - 13 January 2016
This lecture will explain two diagrams: 1 x c ε σ A r x X α o c 2 ε? 2 A τ (A ) A (r x ) A X A (o c ) A (2 A ) A Algebra-coalgebra duality in Brzozowski s minimization algorithm Bonchi, Bonsangue, Hansen, Panangaden, Rutten, Silva ACM Transactions on Computational Logic (TOCL) 2013
This lecture will explain two diagrams: 1 x ε σ A A /Eq(X, α) X α c coeq(x, α) 2 ε? 2 A τ (A ) A (A /Eq(X, α)) A X A (coeq(x, α)) A (2 A ) A The dual equivalence of equations and coequations for automata. A. Ballester-Bolinches, E. Cosme-Llopez, J. Rutten. Information and Computation Vol. 244, 2015, pp. 49-75.
Motivation - A modern perspective on a classical subject - A good illustration of the algebra-coalgebra duality - Leading to very efficient algorithms (in Lecture four)
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
1. (Co)algebra - a mini tutorial
Algebras F(X) algebras are pairs (X, α) where: α X
Coalgebras X coalgebras are pairs (X, α) where: α F(X)
Examples of algebras 1 N N + N [0, successor] 1 + N N 0 N successor N
Examples of algebras 1 N N + N [0, successor] 1 + N N 0 N successor N
Examples of coalgebras α X P(A X) x a y a, y α(x)
Examples of coalgebras head, tail 2 ω 2 2 ω 2 2 ω head tail 2 ω
Thus: F(X) X algebras: α X coalgebras: α F(X)
Thus: X algebras: X coalgebras:
All the rest: by example homomorphisms bisimulations initial algebras, final coalgebras induction, coinduction
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
2. A small exam: algebra or coalgebra?
Initial state 1 x where X is a (possibly infinite) set and 1 = {0} X x X We will call X pointed, with point (or: initial state) x.
Accepting states c 2 where X 2 = {0, 1} We will call c a colouring. And: - if c(x) = 1 then we call x accepting. - if c(x) = 0 then we call x non-accepting.
(Deterministic) automaton with - X is the set of states - A is the input alphabet - X A = { g g : A X } - notation: X α X A x a y α(x)(a) = y
(Deterministic) automaton Because X A X = X X A we have: X A α X and X α X A It is both an algebra and a coalgebra
(Deterministic) automaton Because X A X = X X A we have: X A α X and X α X A It is both an algebra and a coalgebra
A pointed automaton (X, x, α) 1 x X α X A It is an algebra, not a coalgebra.
A pointed automaton (X, x, α) 1 x X α X A It is an algebra, not a coalgebra.
A coloured automaton (X, c, α) c 2 X α X A It is a coalgebra, not an algebra.
A coloured automaton (X, c, α) c 2 X α X A It is a coalgebra, not an algebra.
A pointed and coloured automaton (X, x, c, α) 1 x c 2 X α X A is neither an algebra nor a coalgebra.
A pointed and coloured automaton (X, x, c, α) 1 x c 2 X α X A is neither an algebra nor a coalgebra.
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
3. The scene: the algebra-coalgebra duality of automata cf. Kalman s duality [1959] controllability - observability cf. Arbib and Manes categorical approach to automata
The scene: initial algebra and final coalgebra 1 x c ε σ A r x X α o c 2 ε? 2 A τ (A ) A (r x ) A X A (o c ) A (2 A ) A
first: homomorphisms of automata α h X Y X A h A Y A β β( h(x) )(a) = h( α(x)(a) ) x 1 a x 2 h(x 1 ) a h(x 2 )
Initial algebra 1 x c ε σ A r x X α o c 2 ε? 2 A τ (A ) A (r x ) A X A (o c ) A (2 A ) A
The pointed automaton of words 1 ε A σ (A ) A ε = the empty word as initial state
The pointed automaton of words 1 ε A σ (A ) A σ(w)(a) = w a that is, transitions: w a wa b wab
Initial algebra semantics 1 x ε σ A X! r x α (A ) A (r x ) A X A r x (w) = x w : the state reached from x on input w
Initial algebra semantics: reachability 1 x ε σ A r x X α (A ) A (r x ) A X A r x = the reachability map if r x is surjective then (X, x, α) is called reachable
Final coalgebra 1 x c ε σ A r x X α o c 2 ε? 2 A τ (A ) A (r x ) A X A (o c ) A (2 A ) A
The coloured automaton of languages 2 2 A τ ε? (2 A ) A 2 A = {g g : A 2} = {L L A }
The coloured automaton of languages 2 2 A τ ε? (2 A ) A accepting states: ε?(l) = 1 ε L transitions: τ(l)(a) = L a = {w A a w L}
Transitions: L a La where L a = {w A a w L}. For instance, {ab} a {b} b {ɛ} b a a, b a, b Note that every state L accepts... the language L.
Final coalgebra semantics c 2 ε? α X X A! o c 2 A τ (o c ) A (2 A ) A o c (x) = the language accepted by x
Final coalgebra semantics: observability c 2 ε? α X X A o c 2 A τ (o c ) A (2 A ) A o c = the observability map if o c is injective then (X, c, α) is called observable
Example b b x y a b a a z reachable: y = x aa z = x a not observable: o c (y) = o c (z) = 1 + {a, b} a and so: not minimal
Minimality 1 x c ε σ A r x X α o c 2 ε? 2 A τ (A ) A X A (2 A ) A minimal = reachable + observable That is, r x surjective and o c injective.
Synthesis Given a language L 2 A, find minimal accepting L: ε σ 1 A r x (X, x, c, α) x X α c o c 2 2 A τ ε? (A ) A X A (2 A ) A o c (x) = L
Synthesis: finding a man in the middle ε 1 L A r L = o L 2 A ε? L 2 r L (w) = o L (w) = L w = {v A w v L}
Synthesis: finding a man in the middle ε 1 L A r L 2 A ε? L 2 r L (v) = r L (w) iff u A, vu L wu L i.e., ker(r L ) = Myhill-Nerode equivalence
Synthesis by epi-mono factorisation ε 1 L A e A /ker(r L ) L m 2 A 2 ε? r L = m e reachable: e is surjective observable: m is injective hence: A /ker(r L ) = minimal!
Synthesis by epi-mono factorisation ε 1 A L L L 2 A 2 ε? A /ker(r L ) = L = { Lw w A } Myhill-Nerode meet Brzozowski
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
4. The duality of reachability and observability with an application to Brzozowski s minimization algorithm cf. paper: Algebra-coalgebra duality in Brzozowski s minimization algorithm Bonchi, Bonsangue, Hansen, Panangaden, Rutten, Silva ACM Transactions on Computational Logic (TOCL) 2013 contains various generalisations (Moore, weighted, probabilistic)
Recall: reachability and observability 1 x c ε σ A r x X α o c 2 ε? 2 A τ (A ) A X A (2 A ) A if r x is surjective then (X, x, α) is called reachable if o c is injective then (X, c, α) is called observable minimal = reachable + observable
Reversing automata 1 x ε A r X σ α (A ) A X A 2 ( ) 2 X 2 2 x 2 ε 2 r 2 A 2 σ 2 α (2 X ) A (2 A ) A 2 ( ) = contravariant powerset functor (2 X, 2 α ) = deterministic reverse of (X, α)
Contravariant powerset functor V 2 ( ) : g W 2 V 2 W 2 g where 2 V = {S S V } 2 g (S) = g 1 (S) Theorem: g is surjective 2 g is injective. Proof: exercise (use functoriality).
Contravariant powerset functor V 2 ( ) : g W 2 V 2 W 2 g where 2 V = {S S V } 2 g (S) = g 1 (S) Theorem: g is surjective 2 g is injective. Proof: exercise (use functoriality).
Contravariant powerset functor V 2 ( ) : g W 2 V 2 W 2 g where 2 V = {S S V } 2 g (S) = g 1 (S) Theorem: g is surjective 2 g is injective. Proof: exercise (use functoriality).
Reversing transitions X α X A X A X 2 ( ) 2 X A 2 X (2 X ) A 2 X 2 X 2 α (2 X ) A
point colouring 1 x 2 x 2 X 2 ( ) 2 X c 2 1 c X 2 X
Reversing the entire automaton 1 x X c 2 2 ( ) 1 c 2 X 2x 2 α X A 2 α (2 X ) A point and colouring are exchanged... transitions are reversed... the result is again deterministic... (X, x, c, α) accepts L (2 X, c, 2 x, 2 α ) accepts L rev!!
Duality between reachability and observablity 1 x ε A r X σ α (A ) A X A 2 ( ) 2 X 2 2 x 2 ε 2 r 2 A 2 σ 2 α (2 X ) A (2 A ) A Theorem: r is surjective 2 r is injective. Theorem: (X, x, α) is reachable (2 X, 2 x, 2 α ) is observable.
Duality between reachability and observablity 1 x ε A r X σ α (A ) A X A 2 ( ) 2 X 2 2 x 2 ε 2 r 2 A 2 σ 2 α (2 X ) A (2 A ) A Theorem: r is surjective 2 r is injective. Theorem: (X, x, α) is reachable (2 X, 2 x, 2 α ) is observable.
Duality between reachability and observablity 1 x ε A r X σ α (A ) A X A 2 ( ) 2 X 2 2 x 2 ε 2 r 2 A 2 σ 2 α (2 X ) A (2 A ) A Theorem: r is surjective 2 r is injective. Theorem: (X, x, α) is reachable (2 X, 2 x, 2 α ) is observable.
Corollary: Brzozowski s minimization algorithm (i) X accepts L (ii) 2 X accepts L rev (iii) take reachable part: Y = reach(2 X ) (iv) 2 Y accepts (L rev ) rev = L (v) Y is reachable 2 Y is observable (vi) take reachable part (vii) result: reachable + observable = minimal automaton for L
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
5. The coinduction proof method - is here illustrated: equality of languages - is used in various theorem provers (COQ, Isabelle, CIRC) Coinductive proof techniques for language equivalence J. Rot, M. Bonsangue, J. Rutten Proceedings LATA 2013, LNCS 7810
Bisimulation relations on automata X α X A R X X is a bisimulation: (x, y) R, a A : (x a, y a ) R where x a = α(x)(a) y a = α(y)(a)
... on coloured automata c 2 X α X A R X X is a bisimulation if, for all (x, y) R, a A : (x a, y a ) R and c(x) = c(y)
Bisimulations on languages 2 ε? 2 A τ (2 A ) A R 2 A 2 A is a bisimulation if, for all (K, L) R, a A : (K a, L a ) R and ε K ε L
Bisimulations on languages R 2 A 2 A is a bisimulation if, for all (K, L) R, a A : (K a, L a ) R and ε K ε L where we recall that K a = { w a w K } L a = { w a w L }
Coinduction proof principle By the finality of 2 A, we have: (K, L) R, bisimulation K = L
Example: Arden s Rule We will prove Arden s Rule: L = KL + M ε K L = K M by coinduction.
Arden s Rule: L = K M? Assume L = KL + M ε K Is { ( L, K M ) } a bisimulation? Well... L a = (KL + M) a = K a L + M a (K M) a = K a K M + M a... almost: it is a bisimulation-up-to-congruence. {( UL + V, UK M + V ) U, V 2 A } is a bisimulation L = K M, by coinduction! Exercise: check details in the paper.
Arden s Rule: L = K M? Assume L = KL + M ε K Is { ( L, K M ) } a bisimulation? Well... L a = (KL + M) a = K a L + M a (K M) a = K a K M + M a... almost: it is a bisimulation-up-to-congruence. {( UL + V, UK M + V ) U, V 2 A } is a bisimulation L = K M, by coinduction! Exercise: check details in the paper.
Behavioural differential equations c 2 ε? α X X A o c 2 A τ (o c ) A (2 A ) A An aside: the above diagram can be viewed as a system of behavioural differential equations where the solution is given by finality. Cf. streams and SDEs.
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
6. Duality between equations and coequations - defining classes of (non-pointed, non-coloured) automata - words and languages become here tools
Our scene again 1 x c ε σ A r x X α o c 2 ε? 2 A τ (A ) A X A (2 A ) A Sets of equations: quotients of (A, ε, σ) Sets of coequations: subautomata of (2 A, ε?, τ)
Equations and satisfaction a set of equations = bisimulation equivalence E A A (X, x, α) = E (v, w) E, x v = x w (X, α) = E x : 1 X, (X, x, α) = E
Equations: example (Z, x, γ) = b x a b y a (Z, x, γ) = {b = ε, ab = ε, aa = a} Notation: we use (i) v = w instead of (v, w) (ii) shorthand for the induced bisimulation equivalence
Equations: example (Z, y, γ) = b x a b y a (Z, y, γ) = {a = ε, ba = ε, bb = b}
Coequations and satisfaction a set of coequations = a subautomaton D 2 A (X, c, α) = D x X, o c (x) D (X, α) = D c : X 2, (X, c, α) = D
Coequations: example (Z, c, γ) = b x a b y a where c(x) = 1, c(y) = 0. b a image(o c ) = (a b) b a (a b) + (Z, c, γ) = {(a b), (a b) + }
Coequations: example (Z, d, γ) = b x a b y a where d(x) = 0, d(y) = 1. b a image(o d ) = (b a) + b a (b a) (Z, d, γ) = {(b a), (b a) + }
Duality of (co)equations, diagrammatically (X, x, α) = E ε 1 A x A /E X r x X c D 2 2 A ε? (X, c, α) = D o c
Duality of (co)equations, diagrammatically (X, α) = E ε 1 A x A /E X r x X c D 2 2 A ε? (X, α) = D o c
A free and a cofree construction 1 x ε σ A free(x, α) X α c cofree(x, α) 2 ε? 2 A τ (A ) A free(x, α) A X A cofree(x, α) A (2 A ) A free(x, α) represents largest set of equations cofree(x, α) represents smallest set of coequations
free(x, α) = A /Eq(X, α) ε 1 A r x x:1 X X ε 1 A r x free(x, α) where we define free(x, α) im(r) = A /Eq(X, α) with Eq(X, α) ker(r) Eq(X, α) = largest set of equations satisfied by (X, α)
cofree(x, α) = coeq(x, α) Σ c:x 2 X ĉ 2 ĉ 2 ε? ε? o o 2 A cofree(x, α) 2 A where we define cofree(x, α) ΣX/ker(o) and coeq(x, α) image(o) = cofree(x, α) coeq(x, α) = smallest set of coequations satisfied by (X, α)
Equations: example a (Z, γ) = b x b y a (Z, x, γ) = {b = ε, ab = ε, aa = a} (Z, y, γ) = {a = ε, ba = ε, bb = b} Taking the intersection gives Eq(Z, γ) = {aa = a, bb = b, ab = b, ba = a} the largest set of equations satisfied by (Z, γ).
Coequations: example (Z, γ) = b x a b y a a, b coeq(z, γ) = a, b A b (a b) a b b (b a) + a This is the smallest set of coequations satisfied by (Z, γ). b a (a b) + a (b a)
Summarizing 1 x ε A free(x, α) X c cofree(x, α) 2 2 A ε? 1 x ε A A /Eq(X, α) X c coeq(x, α) 2 2 A ε? Eq(X, α) = largest set of equations coeq(x, α) = smallest set of coequations
Recall: minimal automaton for a fixed L ε 1 A L L L 2 A 2 ε?
Free and cofree of L 1 L ε A free L L cofree L 2 A L 2 ε?
The syntactic monoid of L 1 L ε A free L L cofree L 2 A L 2 ε? free L = syn(l) Cf. algebraic language theory.
The syntactic monoid of L 1 L ε A free L L cofree L 2 A L 2 ε? free L = syn(l) Cf. algebraic language theory.
Theorem 1 L ε A q r free L L L cofree L 2 A 2 ε? r(v) = r(w) (v, w) Myhill-Nerode congruence u A, vu L wu L q(v) = q(w) (v, w) syntactic congruence u 1, u 2 A, u 1 vu 2 L u 1 wu 2 L
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
7. A dual equivalence - Between certain classes of equations and coequations. - It is an initial result about expressiveness.
A dual equivalence Theorem: cofree : C = PL op : free where C is the category of all congruence quotients A /C and PL is the category of all preformations of languages: sets V 2 A such that (i) V is a complete atomic Boolean subalgebra of 2 A (ii) L 2 A L V L a V and a L V
Table of contents 1. (Co)algebra - a mini tutorial 2. A small exam: algebra or coalgebra? 3. The scene: the algebra-coalgebra duality of automata 4. Duality of reachability and observability 5. The coinduction proof method 6. Equations and coequations 7. A dual equivalence 8. In conclusion
8. In conclusion Pointed and coloured automata (X, x, c, α)... 1 x c 2 X α X A... are neither algebra nor coalgebra, but...
1 x X α X A in part algebra (X, x, α) and...
c 2 X α X A in part coalgebra (X, c, α).
8. In conclusion The algebra-coalgebra duality of automata leads to - initial algebra - final coalgebra semantics - inductive and coinductive proofs - duality of reachability - observability - duality of equations - coequations - duality of varieties - covarieties