55
An algebra for Kripke polynomial coalgebras Marcello Bonsangue 1,2 Jan Rutten 1,3 Alexandra Silva 1 1 Centrum voor Wiskunde en Informatica 2 LIACS - Leiden University 3 Vrije Universiteit Amsterdam January 2009 Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 1 / 19

An Algebra for Kripke Polynomial Coalgebras

Embed Size (px)

Citation preview

An algebra for Kripke polynomial coalgebras

Marcello Bonsangue1,2 Jan Rutten1,3 Alexandra Silva1

1Centrum voor Wiskunde en Informatica2LIACS - Leiden University

3Vrije Universiteit Amsterdam

January 2009

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 1 / 19

Motivation

Deterministic automata (DA)Widely used model inComputer Science.Acceptors of languages

Regular expressionsUser-friendly alternative to DAnotation.Many applications: patternmatching (grep), specificationof circuits, . . .

Kleene’s TheoremLet A ⊆ Σ∗. The following are equivalent.

1 A = L(A), for some finite automaton A.2 A = L(r), for some regular expression r .

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 2 / 19

Motivation

Deterministic automata (DA)Widely used model inComputer Science.Acceptors of languages

Regular expressionsUser-friendly alternative to DAnotation.Many applications: patternmatching (grep), specificationof circuits, . . .

Kleene’s TheoremLet A ⊆ Σ∗. The following are equivalent.

1 A = L(A), for some finite automaton A.2 A = L(r), for some regular expression r .

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 2 / 19

Motivation

Kleene AlgebrasKleene asked for a complete set of axioms which would allowderivation of all equations among regular expressions.Kozen showed that the axioms of Kleene algebras solve thisproblem.

AxiomsE1 + E2 = E2 + E1E1 + (E2 + E3) = (E1 + E2) + E3E1 + E1 = E1E + ∅ = E

...1 + aa∗ ≤ a∗

ax ≤ x → a∗x ≤ x

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 3 / 19

Motivation

Kleene AlgebrasKleene asked for a complete set of axioms which would allowderivation of all equations among regular expressions.Kozen showed that the axioms of Kleene algebras solve thisproblem.

AxiomsE1 + E2 = E2 + E1E1 + (E2 + E3) = (E1 + E2) + E3E1 + E1 = E1E + ∅ = E

...1 + aa∗ ≤ a∗

ax ≤ x → a∗x ≤ x

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 3 / 19

Motivation

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 4 / 19

Motivation

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 4 / 19

Motivation

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 4 / 19

Motivation

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 4 / 19

What do these things have in common?

(S, δ : S → 2× SA)

(S, δ : S → (B × S)A)

(S, δ : S → (1 + S)× A× (1 + S))

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 5 / 19

What do these things have in common?

(S, δ : S → 2× SA)

(S, δ : S → (B × S)A)

(S, δ : S → (1 + S)× A× (1 + S))

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 5 / 19

What do these things have in common?

(S, δ : S → 2× SA)

(S, δ : S → (B × S)A)

(S, δ : S → (1 + S)× A× (1 + S))

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 5 / 19

What do these things have in common?

(S, δ : S → 2× SA)

(S, δ : S → (B × S)A)

(S, δ : S → (1 + S)× A× (1 + S))

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 5 / 19

What do these things have in common?

(S, δ : S → 2×SA)

(S, δ : S → (B×S)A)

(S, δ : S → (1 + S)×A× (1 + S))

(S, δ : S → GS)

G-coalgebras

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 6 / 19

What do these things have in common?

(S, δ : S → 2×SA)

(S, δ : S → (B×S)A)

(S, δ : S → (1 + S)×A× (1 + S))

(S, δ : S → GS)

G-coalgebras

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 6 / 19

What do these things have in common?

(S, δ : S → 2×SA)

(S, δ : S → (B×S)A)

(S, δ : S → (1 + S)×A× (1 + S))

(S, δ : S → GS) G-coalgebras

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 6 / 19

Coalgebras

Kripke polynomial coalgebrasGeneralizations of deterministic automataKripke polynomial coalgebras: set of states S and t : S → GS

G:: = Id | B | G ×G | G + G | GA | PG

Examples

G = 2× IdA Deterministic automataG = (B × Id)A Mealy machinesG = 1 + (PId)A LTS (with explicit termination)G = B × IdAt×Σ Automata on guarded strings. . .

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 7 / 19

Coalgebras

Kripke polynomial coalgebrasGeneralizations of deterministic automataKripke polynomial coalgebras: set of states S and t : S → GS

G:: = Id | B | G ×G | G + G | GA | PG

Examples

G = 2× IdA Deterministic automataG = (B × Id)A Mealy machinesG = 1 + (PId)A LTS (with explicit termination)G = B × IdAt×Σ Automata on guarded strings. . .

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 7 / 19

Beyond deterministic automata

Deterministic automata

G-coalgebras

Q → 2×QΣ

Q → GQ

m

m

Regular Expressions

Kleene algebra

m

m

Formal Languages

?

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 8 / 19

Beyond deterministic automata

Deterministic automata G-coalgebrasQ → 2×QΣ Q → GQ

m

m

Regular Expressions

Kleene algebra

m

m

Formal Languages

?

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 8 / 19

Beyond deterministic automata

Deterministic automata G-coalgebrasQ → 2×QΣ Q → GQ

m

m

Regular Expressions ?Kleene algebra

m

m

Formal Languages ?

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 8 / 19

Beyond deterministic automata

Deterministic automata G-coalgebrasQ → 2×QΣ Q → GQ

m m

Regular Expressions G-expressionsKleene algebra G-axioms

m m

Formal Languages

?

Final coalgebra

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 8 / 19

In a nutshell

Our contributions are:A (syntactic) notion of G-expressions for polynomial coalgebras:each expression will denote an element of the final coalgebra.We show the equivalence between G-expressions and finiteG-coalgebras (analogously to Kleene’s theorem).For each G, we provide a sound and complete equational systemfor G-expressions.

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 9 / 19

G-expressions

E :: = ∅ | ε | E · E | E + E | E∗

EG :: = ?

How do we define EG?

Untyped expressions

G-typed expressions

Type system parametrized with G

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 10 / 19

G-expressions

E :: = ∅ | ε | E · E | E + E | E∗

EG :: = ?

How do we define EG?

Untyped expressions

G-typed expressions

Type system parametrized with G

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 10 / 19

G-expressions

Exp 3 ε :: = ∅ | ε⊕ ε | µx .γ| b B| l〈ε〉 | r〈ε〉 G1 ×G2| l[ε] | r [ε] G1 + G2| a(ε) GA

| ε PG

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 11 / 19

G-expressions

Exp 3 ε :: = ∅ | ε⊕ ε | µx .γ| b B| l〈ε〉 | r〈ε〉 G1 ×G2| l[ε] | r [ε] G1 + G2| a(ε) GA

| ε PG

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 11 / 19

G-expressions

Exp 3 ε :: = ∅ | ε⊕ ε | µx .γ| b B| l〈ε〉 | r〈ε〉 G1 ×G2| l[ε] | r [ε] G1 + G2| a(ε) GA

| ε PG

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 11 / 19

G-expressions

Exp 3 ε :: = ∅ | ε⊕ ε | µx .γ| b B| l〈ε〉 | r〈ε〉 G1 ×G2| l[ε] | r [ε] G1 + G2| a(ε) GA

| ε PG

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 11 / 19

G-expressions

Exp 3 ε :: = ∅ | ε⊕ ε | µx .γ| b B| l〈ε〉 | r〈ε〉 G1 ×G2| l[ε] | r [ε] G1 + G2| a(ε) GA

| ε PG

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 11 / 19

G-expressions

Exp 3 ε :: = ∅ | ε⊕ ε | µx .γ| b B| l〈ε〉 | r〈ε〉 G1 ×G2| l[ε] | r [ε] G1 + G2| a(ε) GA

| ε PG

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 11 / 19

Examples

Deterministic automata expressions – G = 2× IdA

ε :: = ∅ | ε⊕ ε | µx .γ | l〈1〉 | l〈0〉 | r〈a(ε)〉

Mealy expressions – G = (B × Id)A

ε :: = ∅ | ε⊕ ε | µx .γ | |

LTS expressions – G = 1 + (PId)A

ε :: = ∅ | ε⊕ ε | µx .γ | | |

a.ε︸︷︷︸r [a(ε)]

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 12 / 19

Examples

Deterministic automata expressions – G = 2× IdA

ε :: = ∅ | ε⊕ ε | µx .γ | l〈1〉 | l〈0〉 | r〈a(ε)〉

Mealy expressions – G = (B × Id)A

ε :: = ∅ | ε⊕ ε | µx .γ | a↓b | a(ε)

LTS expressions – G = 1 + (PId)A

ε :: = ∅ | ε⊕ ε | µx .γ | | |

a.ε︸︷︷︸r [a(ε)]

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 12 / 19

Examples

Deterministic automata expressions – G = 2× IdA

ε :: = ∅ | ε⊕ ε | µx .γ | l〈1〉 | l〈0〉 | r〈a(ε)〉

Mealy expressions – G = (B × Id)A

ε :: = ∅ | ε⊕ ε | µx .γ | a↓b︸︷︷︸a(l〈b〉)

| a(ε)︸︷︷︸a(r〈ε〉)

LTS expressions – G = 1 + (PId)A

ε :: = ∅ | ε⊕ ε | µx .γ | | |

a.ε︸︷︷︸r [a(ε)]

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 12 / 19

Examples

Deterministic automata expressions – G = 2× IdA

ε :: = ∅ | ε⊕ ε | µx .γ | l〈1〉 | l〈0〉 | r〈a(ε)〉

Mealy expressions – G = (B × Id)A

ε :: = ∅ | ε⊕ ε | µx .γ | a↓b︸︷︷︸a(l〈b〉)

| a(ε)︸︷︷︸a(r〈ε〉)

LTS expressions – G = 1 + (PId)A

ε :: = ∅ | ε⊕ ε | µx .γ |√| δ | a.ε

a.ε︸︷︷︸r [a(ε)]

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 12 / 19

Examples

Deterministic automata expressions – G = 2× IdA

ε :: = ∅ | ε⊕ ε | µx .γ | l〈1〉 | l〈0〉 | r〈a(ε)〉

Mealy expressions – G = (B × Id)A

ε :: = ∅ | ε⊕ ε | µx .γ | a↓b︸︷︷︸a(l〈b〉)

| a(ε)︸︷︷︸a(r〈ε〉)

LTS expressions – G = 1 + (PId)A

ε :: = ∅ | ε⊕ ε | µx .γ |√︸︷︷︸l[∗]

| δ︸︷︷︸r [∅]

| a.ε︸︷︷︸r [a(ε)]

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 12 / 19

Kleene’s theorem

The goal is:

G− expressions correspond to Finite G− coalgebras and vice-versa.

What does it mean correspond?

Final coalgebras exist for polynomial coalgebras.

Sh //_____

α

ΩG

ωG

ExpG[[ · ]]oo_ _ _ _ _

GSGh

//_____ GΩG

correspond ≡ mapped to the same element of the final coalgebra≡ bisimilar

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 13 / 19

Kleene’s theorem

The goal is:

G− expressions correspond to Finite G− coalgebras and vice-versa.

What does it mean correspond?

Final coalgebras exist for polynomial coalgebras.

Sh //_____

α

ΩG

ωG

ExpG[[ · ]]oo_ _ _ _ _

GSGh

//_____ GΩG

correspond ≡ mapped to the same element of the final coalgebra≡ bisimilar

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 13 / 19

Kleene’s theorem

The goal is:

G− expressions correspond to Finite G− coalgebras and vice-versa.

What does it mean correspond?

Final coalgebras exist for polynomial coalgebras.

Sh //_____

α

ΩG

ωG

ExpG[[ · ]]oo_ _ _ _ _

GSGh

//_____ GΩG

correspond ≡ mapped to the same element of the final coalgebra≡ bisimilar

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 13 / 19

Kleene’s theorem

The goal is:

G− expressions correspond to Finite G− coalgebras and vice-versa.

What does it mean correspond?

Final coalgebras exist for polynomial coalgebras.

Sh //_____

α

ΩG

ωG

ExpG[[ · ]]oo_ _ _ _ _

GSGh

//_____ GΩG

correspond ≡ mapped to the same element of the final coalgebra≡ bisimilar

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 13 / 19

A generalized Kleene theoremG-coalgebras⇔ G-expressions

Theorem1 Let (S,g) be a G-coalgebra. If S is finite then there exists for any

s ∈ S a G-expression εs such that εs ∼ s.2 For all G-expressions ε, there exists a finite G-coalgebra (S,g)

such that ∃s∈S s ∼ ε.

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 14 / 19

Examples of application

ε = µx .a(1⊕ x)

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 15 / 19

Examples of application

ε = µx .0(x)⊕ 1(ε′)⊕ 0↓0⊕ 1↓0ε′ = µy .0(x)⊕ 1(y)⊕ 0↓1⊕ 1↓1

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 15 / 19

Examples of application

ε1 = a.(b.δ ⊕ c.δ) ε2 = a.b.δ ⊕ a.c.δ

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 15 / 19

Axiomatizationε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = ε

G

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

FP

∅ = ⊥Bb1 ⊕ b2 = b1 ∨ b2

B

l(∅) = ∅l(ε1)⊕ l(ε2) = l(ε1 ⊕ ε2)r(∅) = ∅r(ε1)⊕ r(ε2) = r(ε1 ⊕ ε2)

G1 ×G2

Similar for G1 + G2 and GA

Sound and complete w.r.t ∼

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 16 / 19

Axiomatizationε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = ε

G

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

FP

∅ = ⊥Bb1 ⊕ b2 = b1 ∨ b2

B

l(∅) = ∅l(ε1)⊕ l(ε2) = l(ε1 ⊕ ε2)r(∅) = ∅r(ε1)⊕ r(ε2) = r(ε1 ⊕ ε2)

G1 ×G2

Similar for G1 + G2 and GA

Sound and complete w.r.t ∼

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 16 / 19

Axiomatizationε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = ε

G

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

FP

∅ = ⊥Bb1 ⊕ b2 = b1 ∨ b2

B

l(∅) = ∅l(ε1)⊕ l(ε2) = l(ε1 ⊕ ε2)r(∅) = ∅r(ε1)⊕ r(ε2) = r(ε1 ⊕ ε2)

G1 ×G2

Similar for G1 + G2 and GA

Sound and complete w.r.t ∼

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 16 / 19

Axiomatizationε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = ε

G

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

FP

∅ = ⊥Bb1 ⊕ b2 = b1 ∨ b2

B

l(∅) = ∅l(ε1)⊕ l(ε2) = l(ε1 ⊕ ε2)r(∅) = ∅r(ε1)⊕ r(ε2) = r(ε1 ⊕ ε2)

G1 ×G2

Similar for G1 + G2 and GA

Sound and complete w.r.t ∼

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 16 / 19

Axiomatizationε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = ε

G

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

FP

∅ = ⊥Bb1 ⊕ b2 = b1 ∨ b2

B

l(∅) = ∅l(ε1)⊕ l(ε2) = l(ε1 ⊕ ε2)r(∅) = ∅r(ε1)⊕ r(ε2) = r(ε1 ⊕ ε2)

G1 ×G2

Similar for G1 + G2 and GA

Sound and complete w.r.t ∼

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 16 / 19

Axiomatizationε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = ε

G

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

FP

∅ = ⊥Bb1 ⊕ b2 = b1 ∨ b2

B

l(∅) = ∅l(ε1)⊕ l(ε2) = l(ε1 ⊕ ε2)r(∅) = ∅r(ε1)⊕ r(ε2) = r(ε1 ⊕ ε2)

G1 ×G2

Similar for G1 + G2 and GA

Sound and complete w.r.t ∼

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 16 / 19

Axiomatization – example

LTS expressions – G = 1 + (PId)A

ε :: = ∅ | ε⊕ ε | µx .γ |√︸︷︷︸l[∗]

| δ︸︷︷︸r [∅]

| a.ε︸︷︷︸r [a(ε)]

ε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = εε⊕ δ = ε

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

No rulea.(ε1 ⊕ ε2) = a.ε1 ⊕ a.ε2

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 17 / 19

Axiomatization – example

LTS expressions – G = 1 + (PId)A

ε :: = ∅ | ε⊕ ε | µx .γ |√︸︷︷︸l[∗]

| δ︸︷︷︸r [∅]

| a.ε︸︷︷︸r [a(ε)]

ε1 ⊕ ε2 = ε2 ⊕ ε1ε1 ⊕ (ε2 ⊕ ε3) = (ε1 ⊕ ε2)⊕ ε3ε1 ⊕ ε1 = ε1ε⊕ ∅ = εε⊕ δ = ε

µx .γ = γ[µx .γ/x ]γ[ε/x ] ≤ ε ⇒ µx .γ ≤ ε

No rulea.(ε1 ⊕ ε2) = a.ε1 ⊕ a.ε2

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 17 / 19

Ultimate goal

Functor G

Language + Axiomatization

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 18 / 19

Conclusions and Future work

ConclusionsLanguage of regular expressions for polynomial coalgebrasGeneralization of Kleene theorem and Kleene algebra

Future workModel checkingImplementation : can it be done in Circ?

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 19 / 19

Conclusions and Future work

ConclusionsLanguage of regular expressions for polynomial coalgebrasGeneralization of Kleene theorem and Kleene algebra

Future workModel checkingImplementation : can it be done in Circ?

Alexandra Silva (CWI) An algebra for Kripke polynomial coalgebras January 2009 19 / 19