On Language Equations and Grammar Coalgebras for Context-free - - PowerPoint PPT Presentation

on language equations and grammar coalgebras for context
SMART_READER_LITE
LIVE PREVIEW

On Language Equations and Grammar Coalgebras for Context-free - - PowerPoint PPT Presentation

On Language Equations and Grammar Coalgebras for Context-free Languages Jurriaan Rot and Joost Winter Leiden University and Centrum Wiskunde & Informatica September 2, 2013 Behavioural differential equations CALCO 11


slide-1
SLIDE 1

On Language Equations and Grammar Coalgebras for Context-free Languages

Jurriaan Rot and Joost Winter

Leiden University and Centrum Wiskunde & Informatica

September 2, 2013

slide-2
SLIDE 2

Behavioural differential equations

CALCO ’11 (Winter/Bonsangue/Rutten): Context-free languages,

  • Coalgebraically. . .

. . . behavioural differential equations / Brzozowski derivatives Example:

  • (x)

= 1 xa = xy xb =

  • (y)

= ya = yb = 1

slide-3
SLIDE 3

Behavioural differential equations

CALCO ’11 (Winter/Bonsangue/Rutten): Context-free languages,

  • Coalgebraically. . .

. . . behavioural differential equations / Brzozowski derivatives Example:

  • (x)

= 1 xa = xy xb =

  • (y)

= ya = yb = 1 . . . gives . . . x = {anbn | n ∈ N} y = {b}

slide-4
SLIDE 4

◮ These systems correspond to coalgebras for the functor

2 × Pω(−∗)A. . .

slide-5
SLIDE 5

◮ These systems correspond to coalgebras for the functor

2 × Pω(−∗)A. . .

◮ . . . and can be extended to (infinite) deterministic automata

by enforcing

  • (x + y)

=

  • (x) ∨ o(y)

(x + y)a = xa + ya

  • (xy)

=

  • (x) ∧ o(y)

(xy)a = xay + o(x)ya X ⊂ η

✲ Pω(X ∗)

✲ P(A∗)

2 × Pω(X ∗)A p′

id × −A

✲ ✛

ˆ p′ 2 × P(A∗)A ∼ =

slide-6
SLIDE 6

Grammars and the Greibach normal form

Context-free grammars are systems: p : X → Pω((X + A)∗) A CFG is in Greibach normal form iff p(x) ⊆ 1 + A(X + A)∗ for all x ∈ X giving an isomorphism: Pω((X + A)∗)GNF ∼ = 2 × Pω(X ∗)A Hence, grammars in GNF are 2 × Pω(−∗)A-coalgebras.

slide-7
SLIDE 7

Correctness via grammar derivations

◮ CALCO 2011: coalgebraic semantics coincides with classical

semantics of context-free languages.

◮ Shown via leftmost derivations in a grammar.

slide-8
SLIDE 8

Correctness via grammar derivations

◮ CALCO 2011: coalgebraic semantics coincides with classical

semantics of context-free languages.

◮ Shown via leftmost derivations in a grammar. ◮ Context-free languages can also be seen as (least) solutions to

grammars, regarded as systems of equations.

◮ Question: can we directly relate these systems of equations to

coalgebraic semantics?

slide-9
SLIDE 9

On solutions

Example: x = 1 + axb Unique solution: x = {anbn | n ∈ N}

slide-10
SLIDE 10

On solutions

Example: x = 1 + axb Unique solution: x = {anbn | n ∈ N}

◮ Such systems of equations (based on the Boolean semiring)

always have a least solution.

◮ If it corresponds to a grammar in GNF, this solution is unique.

slide-11
SLIDE 11

Formalizing solutions

Definition: a solution is any mapping s : X → P(A∗) making the following diagram commute: X s

✲ P(A∗)

Pω((X + A)∗) p

[s, η]♯

♯: inductive extension based on union and concatenation

slide-12
SLIDE 12

Solutions and GNF

For grammars in GNF, solutions correspond to mappings making the following diagram commute: X s

✲ P(A∗)

2 × Pω(X ∗)A p′

id × (s♯)A

✲ 2 × P(A∗)A

∼ =

slide-13
SLIDE 13

A lemma

Coalgebraic semantics diagram: X ⊂ η

✲ Pω(X ∗)

✲ P(A∗)

2 × Pω(X ∗)A p′

id × −A

✲ ✛

ˆ p′ 2 × P(A∗)A ∼ =

  • Here − is an algebra homomorphism, or:

x + y = x ∪ y and xy = xy

slide-14
SLIDE 14

A lemma

Coalgebraic semantics diagram: X ⊂ η

✲ Pω(X ∗)

✲ P(A∗)

2 × Pω(X ∗)A p′

id × −A

✲ ✛

ˆ p′ 2 × P(A∗)A ∼ =

  • Here − is an algebra homomorphism, or:

x + y = x ∪ y and xy = xy and hence we obtain:

Lemma

(− ◦ η)♯ = −.

slide-15
SLIDE 15

A theorem

Coalgebraic semantics and classical semantics coincide:

Theorem

Given a (classical) system in GNF, − ◦ η is the unique solution.

slide-16
SLIDE 16

A proof

From the diagram X ⊂ η

✲ Pω(X ∗)

✲ P(A∗)

2 × Pω(X ∗)A p′

id × −A

✲ ✛

ˆ p′ 2 × P(A∗)A ∼ =

slide-17
SLIDE 17

A proof

From the diagram X ⊂ η

✲ Pω(X ∗)

✲ P(A∗)

2 × Pω(X ∗)A p′

id × −A

✲ ✛

ˆ p′ 2 × P(A∗)A ∼ =

  • we obtain (by applying the lemma and deleting the diagonal arrow)

X − ◦ η

✲ P(A∗)

2 × Pω(X ∗)A p′

id × ((− ◦ η)♯)A

✲ 2 × P(A∗)A

∼ =

  • which is precisely the (unique) classical solution diagram for GNF.
slide-18
SLIDE 18

A generalization (1)

◮ Standard generalization: formal languages ⇒ formal power

series

◮ Boolean semiring B ⇒ arbitrary semiring K ◮ generalization of P(A∗):

K A := {f : A∗ → K} (also a semiring)

slide-19
SLIDE 19

A generalization (2)

By applying the following replacements we can generalize our main result to arbitrary commutative semirings: 2 ↔ K Pω(−∗) ↔ K− P(−∗) ↔ K −

slide-20
SLIDE 20

Conclusions and future work

◮ A more categorical look at the coalgebraic view of

context-free languages.

◮ Essence: diagram manipulation + − is an algebra morphism. ◮ Works more generally for power series over a commutative

semiring.

◮ Generalization to other operations, e.g. complement and

intersection: straightforward.

◮ Q: Can these results be further generalized to

noncommutative semirings.