Equational Theories for Real-Time Coalgebraic State Machines Sergey - - PowerPoint PPT Presentation

equational theories for real time coalgebraic state
SMART_READER_LITE
LIVE PREVIEW

Equational Theories for Real-Time Coalgebraic State Machines Sergey - - PowerPoint PPT Presentation

Equational Theories for Real-Time Coalgebraic State Machines Sergey Goncharov a Stefan Milius a Alexandra Silva b ICTAC 2018, October 15-19, Stellenbosch a Friedrich-Alexander-Universit at Erlangen-N urnberg b University College London Some


slide-1
SLIDE 1

Equational Theories for Real-Time Coalgebraic State Machines

Sergey Goncharova Stefan Miliusa Alexandra Silvab ICTAC 2018, October 15-19, Stellenbosch

aFriedrich-Alexander-Universit¨

at Erlangen-N¨ urnberg

bUniversity College London

slide-2
SLIDE 2

Some Related Work

  • Deterministic automata as coalgebras [Rutten, 1998]
  • Generalized regular expressions and Kleene theorem for

Kripke-polynomial functors [Silva, 2010]

  • Generalized powerset construction [Silva, Bonchi, Bonsangue, and

Rutten, 2010]

  • Regular expressions for equationally presented functors and

monads [Myers, 2013]

  • Context-free languages, coalgebraically [Winter, Bonsangue, and

Rutten, 2013] This talk is based on

  • Goncharov, Milius, and Silva 2014, Towards a Coalgebraic Chomsky

Hierarchy (TCS 2014)

  • Goncharov, Milius, and Silva 2018, Towards a Uniform Theory of

Effectful State Machines (ArXiv preprint)

1/15

slide-3
SLIDE 3

Overview

What’s in here:

  • A theory of effectful real-time state machines and expressions
  • Semantics over the space of formal power series
  • Equational theories for effects
  • Kleene theorem

What isn’t here:

  • Results on the equational theory of fixpoint expressions, e.g.

completeness

  • Non-linear semantics (e.g. with trees instead of words)
  • Infinite trace semantics
  • Unguarded expressions/non-real-time machines (but see the paper)

2/15

slide-4
SLIDE 4

Prelude: Coalgebraic Powerset Construction

slide-5
SLIDE 5

T-automata and Generalized Powerset Construction

For a monad T and a T-algebra am : TB Ñ B, we dub a triple of maps

  • m : X Ñ B,

tm : X ˆ A Ñ TX, am : TB Ñ B a T-automaton. Equivalently, it is a coalgebra m : X Ñ B ˆ pTXqA X TX BA‹ B ˆ pTXqA B ˆ pBA‹qA

m

η p

m7 m7

  • ut

idˆpp

m7qA

Factorization m “ m7η is unique and we define xm “ ηpxqm7 P BA‹, meaning that the formal power series xm : A‹ Ñ B is the semantics

  • f m in state x

3/15

slide-6
SLIDE 6

T-automata and Generalized Powerset Construction

For a monad T and a T-algebra am : TB Ñ B, we dub a triple of maps

  • m : X Ñ B,

tm : X ˆ A Ñ TX, am : TB Ñ B a T-automaton. Equivalently, it is a coalgebra m : X Ñ B ˆ pTXqA X PX PA‹ 2 ˆ pPXqA 2 ˆ pPA‹qA

m

η p

m7 m7

  • ut

idˆpp

m7qA

Factorization m “ m7η is unique and we define xm “ ηpxqm7 P BA‹, meaning that the formal power series xm : A‹ Ñ B is the semantics

  • f m in state x

3/15

slide-7
SLIDE 7

Towards Kleene Theorem

  • We seek a syntactic counterpart of the generalized powerset

construction

  • Hence, we need a syntax for the corresponding fixpoint expressions,

corresponding to the classical regular expressions

  • Such expressions must include
  • reactive constructs for actions from A and final outputs from B

(Think of prefixing a. -

  • and 0, 1 of Kleene algebra)
  • effectful constructs for representing side-effecting transitions of

the corresponding T-automaton (Think of nondeterministic ` and 0)

4/15

slide-8
SLIDE 8

Equational Theories for Effects

slide-9
SLIDE 9

Monads for Effects

Mac Lane: A monad T is just a monoid in the category of endofunctors

5/15

slide-10
SLIDE 10

Monads for Effects

Mac Lane: A monad T is just a monoid in the category of endofunctors Moggi: A monad T is a (generalized) computational effect

5/15

slide-11
SLIDE 11

Monads for Effects

Moggi: A monad T is a (generalized) computational effect Any monad T supports inclusion of a value into a computation η : X Ñ TX and a Kleisli lifting pf : X Ñ TY q ÞÑ pf ‹ : TX Ñ TY q Examples:

  • (finitary) nondeterminism: TX “ PωX; “nondeterministic

functions” A Ñ PωB are relations

  • probabilistic nondeterminism: TX “
  • ρ : X Ñ r0, 1s | ř ρ “ 1

( ; “probabilistic functions” A Ñ TB are “probabilistic relations”

  • (finite) background store: TX “ pX ˆ SqS; side-effecting functions

A Ñ TB are functions A ˆ S Ñ B ˆ S

5/15

slide-12
SLIDE 12

Algebraic Theories

Moggi: A monad is a (generalized) computational effect

6/15

slide-13
SLIDE 13

Algebraic Theories

Moggi: A monad is a (generalized) computational effect Plotkin & Power: A monad is a (generalized) algebraic theory

6/15

slide-14
SLIDE 14

Algebraic Theories

Plotkin & Power: A monad is a (generalized) algebraic theory An algebraic theory E can be presented by a signature Σ and a set of

  • equations. Any E defines a monad:
  • TEX “ ‘set of Σ-terms over X modulo E’
  • η coerces a variable to a term
  • σ‹ptq applies substitution σ : X Ñ TEY to t : TEX

Example: Finite powerset monad Pω ð ñ join semilattices with bottom ð ñ idempotent commutative monoids Example: Finite probability distributions Dω ð ñ barycentric algebras; Σ “ t`p | p P r0, 1su, satisfying e.g. “biased associativity”: px `p yq `q z “ x `p{pp`q´pqq py `p`q´pq zq

6/15

slide-15
SLIDE 15

Stack Monad

The store monad TX “ pΓ‹ ˆ XqΓ‹ with Γ “ tγ1, . . . , γnu could be regarded as a monad for stack transformations. But it contains too much! Definition: The stack monad is the submonad Tstk of the store monad p-

  • ˆΓ‹qΓ‹ formed by xr : Γ‹ Ñ X, t : Γ‹ Ñ Γ‹y, which satisfy restriction:
  • Dk. w P Γk. @u P Γ‹. rpwuq “ rpwq ^ tpwuq “ tpwqu

Intuitively, this ensures that the underlying stack may only be finitely

  • read. E.g. nonexample: empty “ xλ -
  • . ‹, λ -
  • . ǫy R Tstk1

The stack signature consists of unary pushi (i ď n) and (n ` 1)-ary pop: pushipp P TstkXqpwq “ ppγiwq poppp1 P TstkX, . . . , pn P TstkX, q P TstkXqpγiwq “ pipwq poppp1 P TstkX, . . . , pn P TstkX, q P TstkXqpǫq “ pipǫq

7/15

slide-16
SLIDE 16

Stack Theory

Theorem: The following stack theory is complete w.r.t. the stack monad pushippoppx1, . . . , xn, yqq “ xi popppush1pxq, . . . , pushnpxq, xq “ x poppx1, . . . , xn, poppy1, . . . , yn, zqq “ poppx1, . . . , xn, zq Moreover, each TstkX is the free algebra of the stack theory over X Proof: Interpreting the axioms as a rewriting system (it is strongly normalizing, no non-trivial critical pairs) and identifying each TstkX with the set of normal forms

8/15

slide-17
SLIDE 17

Adding Nondeterminism

Store-like effects can be sensibly combined by tensoring1: a tensor product of two theories E1 and E2 is obtaining by joining signatures and equations and adding the tensor laws: for all f P E1, g P E2 f pgpx1

1, . . . , x1 k q, . . . gpxn 1 , . . . , xn k qq “ gpf px1 1, . . . , xn 1 q, . . . f pxn k , . . . , xn k qq

Theorem [Freyd]: Tensor product of any theory with a semiring-module theory is again a semiring-module theory This yields a complete axiomatization of Pω b Tstk:

uioi “ 1 uioj “ 0 uie “ 0

  • 1u1 ` . . . ` onun ` e “ 1

eoi “ 0 ee “ e pi ‰ jq

where epxq “ popp∅, . . . , ∅, xq

  • ipxq “ popp∅, . . . , x, . . . , ∅q

pipxq “ pushpxq

1Freyd 1966, Algebra valued functors in general and tensor products in particular

9/15

slide-18
SLIDE 18

(Turing) Tape Monad

The tape monad Ttp is analogously defined as a submonad of p-

  • ˆZ ˆ ΓZqZˆΓZ (Z “ integer numbers)

Signature: rd (n-ary), wri (unary, 1 ď i ď n), mv1, mv-1 (unary) Equations: rdpwr1pxq, . . . , wrnpxqq “ x wriprdpx1, . . . , xnqq “ wripxiq mv-1pmv1pxqq “ x mv1pmv-1pxqq “ x wripwrjpxqq “ wrjpxq wripmvkpwrjpmv-kpxqqqq “ mvkpwrjpmv-kpwripxqqqq pk ‰ 0q Proposition: Tape theory is not finitely axiomatizable

10/15

slide-19
SLIDE 19

Combining Effects with Reactivity

slide-20
SLIDE 20

Reactive Expressions: Syntax

Reactive expressions EΣ,B0 are closed δ-expressions generated by the grammar for a given signature Σ and generators B0 of a Σ-algebra B: δ ::“ x | γ | f pδ, . . . , δq px P X, f P Σq γ ::“ µx. pa1.δ& ¨ ¨ ¨ &ak.δ&βq px P X, ai P Aq β ::“ b | f pβ, . . . , βq pb P B0, f P Σq Example (Nondeterministic Automata) (using 1 ` 1 “ 1 from B): δ ::“ x | γ | ∅ | δ ` δ γ ::“ µx. pa1.δ& ¨ ¨ ¨ &ak.δ&1q Example (Deterministic PDA) (using puship1q “ 0 from B): δ ::“ x | γ | pushipδq | poppδ, . . . , δq γ ::“ µx. pa1.δ& ¨ ¨ ¨ &ak.δ&βq β ::“ 0 | 1 | poppβ, . . . , βq

11/15

slide-21
SLIDE 21

Reactive Expressions: Semantics

For e P EΣ,B0, we define

  • Brzozowski derivatives Bapeq P EΣ,B0 by induction, most notably

Bai ` µx. pa1.t1& ¨ ¨ ¨ &ak.tk&rq ˘ “ tire{xs and by further induction, Bǫpeq “ e, Bawpeq “ BaBwpeq

  • final outputs opeq P B, again by induction, specifically
  • `

µx. pa1.t1& ¨ ¨ ¨ &ak.tk&rq ˘ “ r

12/15

slide-22
SLIDE 22

Reactive Expressions: Semantics

For e P EΣ,B0, we define

  • Brzozowski derivatives Bapeq P EΣ,B0 by induction, most notably

Bai ` µx. pa1.t1& ¨ ¨ ¨ &ak.tk&rq ˘ “ tire{xs and by further induction, Bǫpeq “ e, Bawpeq “ BaBwpeq

  • final outputs opeq P B, again by induction, specifically
  • `

µx. pa1.t1& ¨ ¨ ¨ &ak.tk&rq ˘ “ r This induces the semantics e : A‹ Ñ B, by putting epwq “ opBwpeqq

12/15

slide-23
SLIDE 23

Reactive Expressions: Semantics

For e P EΣ,B0, we define

  • Brzozowski derivatives Bapeq P EΣ,B0 by induction, most notably

Bai ` µx. pa1.t1& ¨ ¨ ¨ &ak.tk&rq ˘ “ tire{xs and by further induction, Bǫpeq “ e, Bawpeq “ BaBwpeq

  • final outputs opeq P B, again by induction, specifically
  • `

µx. pa1.t1& ¨ ¨ ¨ &ak.tk&rq ˘ “ r This induces the semantics e : A‹ Ñ B, by putting epwq “ opBwpeqq Kleene Theorem: for any e P EΣ,B0 there is a T-automaton m over X and a state x P X such that e “ xm and vice versa

12/15

slide-24
SLIDE 24

Classes of Instances

  • If B “ 2, e.g. for non-deterministic or alternating automata,

e P 2A‹ – PA‹ is the formal language of e

  • For weighted automata, B is a semiring, T is the corresponding

B-module monad and we obtain standard semantics

  • For PDA-like machines, e is not the ultimate semantics:

Theorem: if B is finite then e is regular regardless of the monad We take B to be the quotient of Tstk2 by puship0q “ puship1q “ 0, equivalently, B consists of predicates Γ‹ Ñ 2 depending on a bounded portion of stack, hence, e : Γ‹ Ñ PpA‹q

  • For valence automata, T “ Pω b p-
  • ˆMq “ Pωp-
  • ˆMq, B “ PωpMq

where M is a (polycyclic) monoid emulating storage mechanism

13/15

slide-25
SLIDE 25

Expressivity of Stack Machines

Theorem: With m ranging over Tstk-automata, x0 over the respective state spaces and γ0 over Γ, the sets ! w P A‹ | x0mpwqpγ0q “ 1 ) exhaustively cover all real-time deterministic context-free languages Theorem: the classes of languages recognized by Pω b Tstk b . . . b Tstk, where m is the number of copies of Tstk, are as follows:

  • 1. All context-free languages if m “ 1
  • 2. All nondeterministic linear time languages if m ě 3
  • 3. The case m “ 2 correspond to a language class properly between the

above two Proof: Reduction to results on real-time machines from 60-s

14/15

slide-26
SLIDE 26

Further Work

  • Reactive expressions come with a canonical equational calculus,

which cannot always be complete (otherwise equivalence of PDA would be decidable). Can one derive completeness from constraints

  • n the effect theory2?
  • ǫ-elimination: for T-automata over a given B, can we obtain a useful

description of T1-automata over B1 such that every original non-real-time automaton is equivalent to a real-time automaton w.r.t. T1 and B1? In particular, when T “ T1 and B “ B1? This is very hard already for valence automata3

  • Identifying further language and complexity classes. How to describe

the relation between the theory of effects and the complexity of languages recognized?

2Bonsangue, Milius, and Silva 2013, Sound and Complete Axiomatizations of

Coalgebraic Language Equivalence

3Zetzsche 2013, Silent Transitions in Automata with Storage

15/15

slide-27
SLIDE 27

Thank You for Your Attention!

slide-28
SLIDE 28

References I

References

Marcello M. Bonsangue, Stefan Milius, and Alexandra Silva. Sound and complete axiomatizations of coalgebraic language equivalence. ACM

  • Trans. Comput. Log., 14(1):7:1–7:52, 2013.

Peter Freyd. Algebra valued functors in general and tensor products in

  • particular. Colloq. Math., 14:89–106, 1966.

Sergey Goncharov, Stefan Milius, and Alexandra Silva. Towards a coalgebraic chomsky hierarchy. In TCS’14, volume 8705, pages 265–280. Springer, 2014. Sergey Goncharov, Stefan Milius, and Alexandra Silva. Towards a uniform theory of effectful state machines. CoRR, abs/1401.5277,

  • 2018. URL http://arxiv.org/abs/1401.5277.

13/15

slide-29
SLIDE 29

References II

Robert Myers. Rational Coalgebraic Machines in Varieties: Languages, Completeness and Automatic Proofs. PhD thesis, Imperial College London, 2013. Jan J. M. M. Rutten. Automata and coinduction (an exercise in coalgebra). In Davide Sangiorgi and Robert de Simone, editors, CONCUR, volume 1466 of Lecture Notes in Computer Science, pages 194–218. Springer, 1998. Alexandra Silva. Kleene coalgebra. PhD thesis, Radboud Univ. Nijmegen, 2010. Alexandra Silva, Filippo Bonchi, Marcello M. Bonsangue, and Jan J.

  • M. M. Rutten. Generalizing the powerset construction, coalgebraically.

In FSTTCS, volume 8 of LIPIcs, pages 272–283, 2010.

14/15

slide-30
SLIDE 30

References III

Joost Winter, Marcello M. Bonsangue, and Jan J. M. M. Rutten. Coalgebraic characterizations of context-free languages. LMCS, 9(3), 2013. Georg Zetzsche. Silent transitions in automata with storage. In Fedor V. Fomin, Rusins Freivalds, Marta Z. Kwiatkowska, and David Peleg, editors, Automata, Languages, and Programming - 40th International Colloquium, ICALP 2013, Riga, Latvia, July 8-12, 2013, Proceedings, Part II, volume 7966 of Lecture Notes in Computer Science, pages 434–445. Springer, 2013.

15/15