(co-)algebraic automata theoryober:goncharov.pdf · (co-)algebraic automata theory sergey...
TRANSCRIPT
(Co-)algebraic Automata Theory
Sergey Goncharov, Stefan Milius, Alexandra Silva
Erlangen, 5.11.2013
Chair 8 (Theoretical Computer Science)
Short Histrory of Coalgebraic Invasion to Automata Theory
• Deterministic automata as coalgebras [Rutten, 1998].
• Generalized regular expressions and Kleene’s theorem for
(Kripke-)polinomial functors [Silva, 2010].
• Generalized powerset construction [Silva et al., 2010].
• Regular expressions for equationally presented functors and
monads [Myers, 2013].
• Context-free languages coalgebraically [Winter et al., 2013].
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 2
Base Case: Moore AutomataMoore automaton with input alphabet A and output alphabet B is given by
tm : X × A→ X (transition) and om : X → B (output)
Put differently, a Moore automaton is a coalgebra m : X → B × X A on Set.
A final LA,B -coalgebra is carried by the set BA∗ of formal power series on B.
Its coalgebra structure ι : BA∗ → B × (BA∗)A is given by
oι(σ : A∗ → B) = σ(ε) and t ι(σ : A∗ → B, a) = λw .σ(a · w).
Equivalently, the LA,B-coalgebra structure can be given in terms ifderivatives: given w ∈ A∗,
∂ε(σ) = oι(σ) and ∂a·w(σ) = t ι(∂w(σ), a)
Particular important case is B = 2. Then BA∗ ' P(A∗) is the set of all formal
languages over A.Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 3
Base Case: Moore AutomataMoore automaton with input alphabet A and output alphabet B is given by
tm : X × A→ X (transition) and om : X → B (output)
Put differently, a Moore automaton is a coalgebra m : X → B × X A on Set.
A final LA,B -coalgebra is carried by the set BA∗ of formal power series on B.
Its coalgebra structure ι : BA∗ → B × (BA∗)A is given by
oι(σ : A∗ → B) = σ(ε) and t ι(σ : A∗ → B, a) = λw .σ(a · w).
Equivalently, the LA,B-coalgebra structure can be given in terms ifderivatives: given w ∈ A∗,
∂ε(σ) = oι(σ) and ∂a·w(σ) = t ι(∂w(σ), a)
Particular important case is B = 2. Then BA∗ ' P(A∗) is the set of all formal
languages over A.
LA,BX := B × X A
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 4
Base Case: Moore AutomataMoore automaton with input alphabet A and output alphabet B is given by
tm : X × A→ X (transition) and om : X → B (output)
Put differently, a Moore automaton is a coalgebra m : X → B × X A on Set.
A final LA,B -coalgebra is carried by the set BA∗ of formal power series on B.
Its coalgebra structure ι : BA∗ → B × (BA∗)A is given by
oι(σ : A∗ → B) = σ(ε) and t ι(σ : A∗ → B, a) = λw .σ(a · w).
Equivalently, the LA,B-coalgebra structure can be given in terms ifderivatives: given w ∈ A∗,
∂ε(σ) = oι(σ) and ∂a·w(σ) = t ι(∂w(σ), a)
Particular important case is B = 2. Then BA∗ ' P(A∗) is the set of all formal
languages over A.
LA,BX := B × X A We shall assume finite
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 5
Rationality of Formal Power Series
By the the universal property of the final coalgebra for any m : X → B × X A
there exists a unique LA,B-coalgebra homomorphism m̂ such that:
X
m��
m̂ // BA∗
ι
��
B × X AB×m̂A
// B × (BA∗)A
Given x ∈ X , JxKm := m̂(x) is the “language” recognized by m at x .
A formal power series σ : A∗ → B is rational if the set {∂w(σ) | w ∈ A∗} isfinite.
Theorem. A formal power series σ is rational iff σ = JxKm̂ for somem : X → B × X A and x ∈ X .Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 6
Expressions for Moore Automata
Let σ : A∗ → B be rational, let A = {a1, . . . , an}, and let{σ1, . . . , σk} = {∂w(σ) | w ∈ A∗}. Then σ = σ1 can be found as the solutionof system of recursive equations
σi = a1.σi1 t · · · t an.σin t ci, (F)which should be read: for all i, j , ∂aj(σi) = σij and σi(ε) = ci .
System (F) uniquely determines the σ1, . . . , σn. Any recursive equationof (F) can be rewritten as
σi = µσi. (a1.σi1 t · · · t an.σin t ci)
where µ is the fixpoint operator binding the occurrences of σi in the rightterm. One can successively eliminate σi (i 6= 1) and obtain a “solution” σ = tof (F) in σ where t is a closed term given by
γ ::= µX . (a1.δ t · · · t an.δ t B) δ ::= X | γ
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 7
Expressions for Moore Automata
Let σ : A∗ → B be rational, let A = {a1, . . . , an}, and let{σ1, . . . , σk} = {∂w(σ) | w ∈ A∗}. Then σ = σ1 can be found as the solutionof system of recursive equations
σi = a1.σi1 t · · · t an.σin t ci, (F)which should be read: for all i, j , ∂aj(σi) = σij and σi(ε) = ci .
System (F) uniquely determines the σ1, . . . , σn. Any recursive equationof (F) can be rewritten as
σi = µσi. (a1.σi1 t · · · t an.σin t ci)
where µ is the fixpoint operator binding the occurrences of σi in the rightterm. One can successively eliminate σi (i 6= 1) and obtain a “solution” σ = tof (F) in σ where t is a closed term given by
γ ::= µX . (a1.δ t · · · t an.δ t B) δ ::= X | γ
Finite set of variables
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 8
Kleene’s Theorem for Moore Automata
Expressions
γ ::= µX . (a1.δ t · · · t an.δ t B) δ ::= X | γfaithfully represent all rational formal power series. We can introduceBrzozowski derivatives: given e = µx . (a1.e1 t · · · t an.e1 t c), let
∂ai(e) = ei[e/x ] o(e) = c
By induction, let ∂a·w = ∂a ◦ ∂w . Then, let JeK(w) = o(∂w(e)).
Brzozowski’s theorem: for any expression e, {∂w(e) | w ∈ A∗} is finite.
Kleene’s theorem: for any Moore automaton m and any state x ∈ X thereis an expression e such that JxKm = JeK and converselly, for any expressione there are m and x such that JxKm = JeK.
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 9
Expressions for Deterministic FSM: Example
B = 2
q0start q1 q2
ba
ba
a
b
e0 = a.e0 t b.e1 t 0e1 = a.e0 t b.e2 t 0e2 = a.e0 t b.e0 t 1
Hence: e0 = µx .(a.x t b.µy .(a.x tb.µz.(a.x t b.x t 1) t 0) t 0)
Equivalently: e0 = (a + ba + b)∗b.
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 10
Powerset Construction
Let m : X → B × (PωX )A where B is a join-semilattice with bottom.We can extend it to m ] : m : PωX → B × (PωX )A by defining
tm ]
(s ∈ PωX , a) = {tm(x , a) | x ∈ s} om ]
(s ∈ PωX ) =∨x∈s
o(x)
X{--}
//
m��
PωX m̂ ]//
m ]xxrrrrrrrrrrrrrrrrrr
BA∗
ι
��
B × (PωX )A id×(m̂ ])A// B × (BA∗)A
Let JxKm = m̂{x}.Theorem: JxKm is the formal power series accepted by m at state x ∈ X .
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 11
Powerset Construction
Let m : X → B × (PωX )A where B is a join-semilattice with bottom.We can extend it to m ] : m : PωX → B × (PωX )A by defining
tm ]
(s ∈ PωX , a) = {tm(x , a) | x ∈ s} om ]
(s ∈ PωX ) =∨x∈s
o(x)
X{--}
//
m��
PωX m̂ ]//
m ]xxrrrrrrrrrrrrrrrrrr
BA∗
ι
��
B × (PωX )A id×(m̂ ])A// B × (BA∗)A
Equivalently given by tm : X × A→ PωX and om : X → B
Let JxKm = m̂{x}.Theorem: JxKm is the formal power series accepted by m at state x ∈ X .
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 12
Generalized Powerset Construction and T-automata
Definition: Let T be a monad. A T-automaton is triple of maps
om : X → B, tm : X × A→ TX , am : TB → B
where the latter map satisfies the axioms of T-algebra.
A T-automaton can be identified as a coalgebra m : X → B × (TX )A. Let
tm ]
(p, a) = do x ← p; tm(x , a) om ]
(p) = am(do x ← p; η(om(x))).
ThenX
η//
m��
TX m̂ ]//
m ]yytttttttttttttttttt
BA∗
ι
��
B × (TX )A id×(m̂ ])A// B × (BA∗)A
and we can define JxKm = Jη(x)Km ].
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 13
Algebraic Theories
An algebraic theory is given by a signature Σ and a set of equations.
Any algebraic theory E defines a monad: TX = ‘set of Σ-terms over Xmodulo E ’; η coerces a variable to a term; do x ← p; q substituteseach x in p : TX with q(x).
Definition: We call a monad T finitely presented if it is generated by afinitely axiomatizable algebraic theory E over finite Σ.
Example: Finite powerset monad Pω ⇐⇒ join semilattices with bottom.
Finite state monad TX = (X × S)S ⇐⇒ finite mnemoids(lookupl : X v → X , updatel,v : X → X ).
Non-Example: Distribution monad (TX = ‘set of finitely supportedprobability distributions’).
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 14
Delimited Stores
Definition: Given a set S, let L be a nonempty meet-semilattice ofequivalence relations of finite index on S. An L-delimited store monad is asubmonad T of the store monad on S such that: for any ∼ ∈ L and any〈r , t〉 : S → (X × S) ∈ TX , there exists ≈ ∈ L finer than ∼ such that tpreserves ≈ and r sends ≈-equivalent elements to equal.
Examples: Stack monad: L consists of equivalences ∼n on Γ ∗ identifyingany s and s′ with the same n-prefixes.
Dequeue monad: L consists of equivalences ∼n,m on Γ∗ identifying any sand s′ with the same n-prefixes and m-postfixes.
Tape monad: L consists of equivalences ∼n,m on Γ∗ × (Γ + 1)× Γ∗
identifying any 〈s, x , t〉 and 〈s′, x , t ′〉 for which s and s′ have the samen-postfixes and t and t ′ have the same m-prefixes.
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 15
Delimited Stores
Definition: Given a set S, let L be a nonempty meet-semilattice ofequivalence relations of finite index on S. An L-delimited store monad is asubmonad T of the store monad on S such that: for any ∼ ∈ L and any〈r , t〉 : S → (X × S) ∈ TX , there exists ≈ ∈ L finer than ∼ such that tpreserves ≈ and r sends ≈-equivalent elements to equal.
Examples: Stack monad: L consists of equivalences ∼n on Γ ∗ identifyingany s and s′ with the same n-prefixes.
Dequeue monad: L consists of equivalences ∼n,m on Γ∗ identifying any sand s′ with the same n-prefixes and m-postfixes.
Tape monad: L consists of equivalences ∼n,m on Γ∗ × (Γ + 1)× Γ∗
identifying any 〈s, x , t〉 and 〈s′, x , t ′〉 for which s and s′ have the samen-postfixes and t and t ′ have the same m-prefixes.
Finite tape alphabet
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 16
Stack Automata
For a stack monad T, TX ⊆ (X × Γ∗)Γ∗ consists of those state transformers〈r , t〉 : Γ∗ → (X × Γ∗), for which
r(u · w) = r(u) t(u · w) = t(u) · wwhenever |u| ≥ n for some n.
The stack monad is finitely presentable w.r.t. pop : X Γ+1 → X andpushi : X → X (i ≤ |Γ|):
pushi(pop(x1, . . . , xn, y)) = xi
pop(push1(x), . . . , pushn(x), x) = xpop(x1, . . . , xn, pop(y1, . . . , yn, z)) = pop(x1, . . . , xn, z)
For a deterministic stack automaton m : X → 2L[Γ∗] ×TX am is the
w. p. transformer: for any s ∈ S and 〈r , t〉 : (2L[Γ∗] × Γ∗)Γ∗ ∈ T (2L[Γ∗])
am(f )(s) = 1 iff ∃s′ ∈ Γ∗. s ∈ t−1(s′) ∧ r(s)(s′) = 1Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 17
Stack Automata
For a stack monad T, TX ⊆ (X × Γ∗)Γ∗ consists of those state transformers〈r , t〉 : Γ∗ → (X × Γ∗), for which
r(u · w) = r(u) t(u · w) = t(u) · wwhenever |u| ≥ n for some n.
The stack monad is finitely presentable w.r.t. pop : X Γ+1 → X andpushi : X → X (i ≤ |Γ|):
pushi(pop(x1, . . . , xn, y)) = xi
pop(push1(x), . . . , pushn(x), x) = xpop(x1, . . . , xn, pop(y1, . . . , yn, z)) = pop(x1, . . . , xn, z)
For a deterministic stack automaton m : X → 2L[Γ∗] ×TX am is the
w. p. transformer: for any s ∈ S and 〈r , t〉 : (2L[Γ∗] × Γ∗)Γ∗ ∈ T (2L[Γ∗])
am(f )(s) = 1 iff ∃s′ ∈ Γ∗. s ∈ t−1(s′) ∧ r(s)(s′) = 1
p ∈ 2L[Γ∗] iff it is stable under some ∼n∈ L
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 18
(Deterministic) Real-time CFL
Deterministic real-time context-free languages are exactly those, which arerecognized by deterministic real-time (with no internal transitions)push-down automata.
Theorem. Let m be a stack automaton. Then for any x and any w ∈ Γ∗,JxKm(w) is a deterministic real-time CFL; and conversely: any deterministicreal-time CFL can be obtained in this way.
Conjecture. Real-time CFL (=proper CFL) are recognized exactly bynon-deterministic stack automata. That is, automata overTX ⊆ Pω(X × Γ∗)Γ∗, such that 〈r , t〉 : Γ∗ → Pω(X × Γ∗) ∈ TX iff
r(u · w) = r(u) t(u · w) = {u′ · w | u′ ∈ t(u)}whenever |u| ≥ n for some n.
Theorem. Given x ∈ X and m : X → B× TX A with finite B, JxKm is rational.
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 19
(Deterministic) Real-time CFL
Deterministic real-time context-free languages are exactly those, which arerecognized by deterministic real-time (with no internal transitions)push-down automata.
Theorem. Let m be a stack automaton. Then for any x and any w ∈ Γ∗,JxKm(w) is a deterministic real-time CFL; and conversely: any deterministicreal-time CFL can be obtained in this way.
Conjecture. Real-time CFL (=proper CFL) are recognized exactly bynon-deterministic stack automata. That is, automata overTX ⊆ Pω(X × Γ∗)Γ∗, such that 〈r , t〉 : Γ∗ → Pω(X × Γ∗) ∈ TX iff
r(u · w) = r(u) t(u · w) = {u′ · w | u′ ∈ t(u)}whenever |u| ≥ n for some n.
Theorem. Given x ∈ X and m : X → B× TX A with finite B, JxKm is rational.
T = Pω⊗ “stack monad over Γ∗”
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 20
Tensors
Given two algebraic theories E1 and E2 their tensor E1 ⊗ E2 is obtained byjoining operations and equations and forcing tensor laws of the form
f (g(x11 , . . . , x
1m), . . . , g(xn
1 , . . . , xnm)) = g(f (x1
1 , . . . , xn1 ), . . . , f (x1
m, . . . , xnm))
for any f : X n → X from E1 and any g : X m → X from E2.
This induces tensor of monads; and if T1 and T2 are finitely presentable thenso is T1 ⊗ T2.
Properties: • T⊗ (−× S)S yields state monad transformer T (X × S)S.
• Tape monad is the tensor of stack monad with itself.
• Finite powermonad T⊗ Pω can be axiomatized in terms of unary
operations, + and 0 due to tensor law
f (x1, . . . , xn) = f (x1, . . . , 0) + . . . + f (0, . . . , xn)Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 21
Effectful Fixpoint Expressions
Let E be an algebraic theory over signature Σ corresponding to T. Given afinite A = {a1, . . . , an} and a T-algebra B effectful fixpoint expressions EB
are closed terms γ given by the following grammar
γ ::= µX . (a1.δ t · · · t an.δ t B) δ ::= X | γ | f (δ, . . . , δ) (f ∈ Σ)
These form a Σ-algebra: given ek = µX .(a1.ek
1 t · · · t an.ekn t bk
),
f (e1, . . . , em) = µX .(a1.f (e1
1, . . . , em1 ) t · · · t an.f (e1
n, . . . , emn ) t f (b1, . . . , bm)
)but also a LA,B-coalgebra:
o(µX . (a1.e1 t · · · t an.en t b)) = b∂ai(µX . (a1.e1 t · · · t an.en t b)) = ei[e/X ]
Let e ∼ e′ iff for all w ∈ A∗, o(∂w(e)) = o(∂w(e′)).
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 22
Kleene’s Theorem for Effectful Fixpoint Expressions
Given e ∈ ET,B and w ∈ A∗, let JeK(w) = o(∂w(e)).
Conjecture (Kleene’s Theorem): for any T-automaton with a finitelypresentable T and any x ∈ X there is e ∈ ET,B such that JxKm = JeK.Conversely, for any e ∈ ET,B there is m and x ∈ X , such that JxKm = JeK.
Conjecture: ∼ is properly Π01 (by reduction to CFL).
Conjecture: Let T be the tensor product of n instances of the stack monadand let m be a delimited store monad over T. Then deciding if w ∈ JeKm islinear time. Deciding if w ∈ JeKm with T replaced by T⊗ Pω isnondeterministic linear time.
Open Question: Does it generalize to any delimited store monad?
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 23
Push-down Expressions
Push-down expressions are effectful fixpoint expressions fornondeterministic stack automata. Concretely,
γ ::= 0 | µX . ξ | πξ ::= a.δ | a.δ + ξ | a.δ + π
π ::= pops(π) | empty(0) | empty(1)
δ ::= X | γ | pops(δ) | pushs(δ) | empty(δ)
Example: Consider CFG (in Greibach normal form):
X → aXX X → b
This corresponds to expression
µx . (a.pushc(x) + b.popc(x) + b.empty(1))
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 24
Thank You for Your Attention!
Myers, R. (2013).
Rational Coalgebraic Machines in Varieties: Languages, Completeness
and Automatic Proofs.
PhD thesis, Imperial College London.
Rutten, J. J. M. M. (1998).
Automata and coinduction (an exercise in coalgebra).
In Sangiorgi, D. and de Simone, R., editors, CONCUR, volume 1466 of
Lecture Notes in Computer Science, pages 194–218. Springer.
Silva, A. (2010).
Kleene coalgebra.
PhD thesis, Radboud Universiteit Nijmegen.
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 26
Silva, A., Bonchi, F., Bonsangue, M. M., and Rutten, J. J. M. M. (2010).
Generalizing the powerset construction, coalgebraically.
In FSTTCS, volume 8 of LIPIcs, pages 272–283.
Winter, J., Bonsangue, M. M., and Rutten, J. J. M. M. (2013).
Coalgebraic characterizations of context-free languages.
Logical Methods in Computer Science, 9, abs/1308.1228(3).
Erlangen, 5.11.2013 | Sergey Goncharov, Stefan Milius, Alexandra Silva | Chair 8 (Theoretical Computer Science) | 27