A Type System for Weighted Automata and Rational Expressions Akim - - PowerPoint PPT Presentation

a type system for weighted automata and rational
SMART_READER_LITE
LIVE PREVIEW

A Type System for Weighted Automata and Rational Expressions Akim - - PowerPoint PPT Presentation

A Type System for Weighted Automata and Rational Expressions Akim Demaille 1 , Alexandre Duret-Lutz 1 , Sylvain Lombardy 2 , Luca Saiu 1 , 3 , Jacques Sakarovitch 3 1 EPITA/LRDE, 2 LaBRI, Universit e de Bordeaux, 3 LTCI, CNRS / T el


slide-1
SLIDE 1

A Type System for Weighted Automata and Rational Expressions

Akim Demaille1, Alexandre Duret-Lutz1, Sylvain Lombardy2, Luca Saiu1,3, Jacques Sakarovitch3

1EPITA/LRDE, 2LaBRI, Universit´

e de Bordeaux, 3LTCI, CNRS / T´ el´ ecom-ParisTech

http://vaucanson.lrde.epita.fr http://vaucanson-project.org CIAA 2014; August, 1st 2014

(2014-08-03 00:28:28 +0200 a998c33)

slide-2
SLIDE 2

Vaucanson

General-purpose platform for weighted automata and transducers. Genericity

Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε. . . Letters: chars, ints. . .

Performance

C++ templated library No dynamic polymorphism (virtual) Efficient algorithms and data structures

Flexibility

A dynamic API on top of the templated library A dynamic type system for automata, rational expressions, etc. An interactive GUI on top of IPython

2 / 22

slide-3
SLIDE 3

Vaucanson

General-purpose platform for weighted automata and transducers. Genericity

Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε. . . Letters: chars, ints. . .

Performance

C++ templated library No dynamic polymorphism (virtual) Efficient algorithms and data structures

Flexibility

A dynamic API on top of the templated library A dynamic type system for automata, rational expressions, etc. An interactive GUI on top of IPython

2 / 22

slide-4
SLIDE 4

Vaucanson

General-purpose platform for weighted automata and transducers. Genericity

Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε. . . Letters: chars, ints. . .

Performance

C++ templated library No dynamic polymorphism (virtual) Efficient algorithms and data structures

Flexibility

A dynamic API on top of the templated library A dynamic type system for automata, rational expressions, etc. An interactive GUI on top of IPython

2 / 22

slide-5
SLIDE 5

Vaucanson

General-purpose platform for weighted automata and transducers. Genericity

Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε. . . Letters: chars, ints. . .

Performance

C++ templated library No dynamic polymorphism (virtual) Efficient algorithms and data structures

Flexibility

A dynamic API on top of the templated library A dynamic type system for automata, rational expressions, etc. An interactive GUI on top of IPython

2 / 22

slide-6
SLIDE 6

Typing Automata and Rational Expressions

1

Typing Automata and Rational Expressions

2

A Calculus on Types

3

Use in Vaucanson

3 / 22

slide-7
SLIDE 7

From Recognizers to Weighted Automata

a b b a b bb

4 / 22

slide-8
SLIDE 8

From Recognizers to Weighted Automata

a b b a b ⊤ ∧ ⊤ bb

4 / 22

slide-9
SLIDE 9

From Recognizers to Weighted Automata

a b b a b ⊤ ∧ ⊤ ⊤ ∧ ⊤ bb

4 / 22

slide-10
SLIDE 10

From Recognizers to Weighted Automata

a b b a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤

4 / 22

slide-11
SLIDE 11

From Recognizers to Weighted Automata

a b b a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ a b b 2a 2b bb

4 / 22

slide-12
SLIDE 12

From Recognizers to Weighted Automata

a b b a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ a b b 2a 2b 1 × 1 bb

4 / 22

slide-13
SLIDE 13

From Recognizers to Weighted Automata

a b b a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ a b b 2a 2b 1 × 1 + 2 × 1 bb

4 / 22

slide-14
SLIDE 14

From Recognizers to Weighted Automata

a b b a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ a b b 2a 2b 1 × 1 + 2 × 1 = 3 bb → 3

4 / 22

slide-15
SLIDE 15

Many Different Kinds of Weights

B, ∨, ∧ Z, +, × Q, +, × R, +, × Z, min, + Rational expressions Tuples . . .

5 / 22

slide-16
SLIDE 16

Many Different Kinds of Labels

letters a, b nullables ε, a words ε, a, bb tuples (a, x), (b, y) (a, x, u), (b, yy, ε)

6 / 22

slide-17
SLIDE 17

Many Different Kinds of Labels

letters a, b nullables ε, a words ε, a, bb tuples (a, x), (b, y) (a, x, u), (b, yy, ε)

6 / 22

slide-18
SLIDE 18

Many Different Kinds of Labels

letters a, b nullables ε, a words ε, a, bb tuples (a, x), (b, y) (a, x, u), (b, yy, ε)

6 / 22

slide-19
SLIDE 19

Many Different Kinds of Labels

letters a, b nullables ε, a words ε, a, bb tuples (a, x), (b, y) (a, x, u), (b, yy, ε)

6 / 22

slide-20
SLIDE 20

Contexts

context ::= labelset → weightset {a, b} → B a, b (ε + a + b)∗ {a, b, c}? → Z 2 4ε, 2b 2(−2a + b)∗ {a, b, c} × {x, y, z}∗ → Q 5

7

(a, xx), 2

3(b, y)

1

2(a, x) + 1 3(b, y)∗

{a, b} → RatE[{x, y} → Q] x 2

3x∗b

  • xa + 1

3(x + y)∗b

7 / 22

slide-21
SLIDE 21

Contexts

context ::= labelset → weightset {a, b} → B a, b (ε + a + b)∗ {a, b, c}? → Z 2 4ε, 2b 2(−2a + b)∗ {a, b, c} × {x, y, z}∗ → Q 5

7

(a, xx), 2

3(b, y)

1

2(a, x) + 1 3(b, y)∗

{a, b} → RatE[{x, y} → Q] x 2

3x∗b

  • xa + 1

3(x + y)∗b

7 / 22

slide-22
SLIDE 22

Contexts

context ::= labelset → weightset {a, b} → B a, b (ε + a + b)∗ {a, b, c}? → Z 2 4ε, 2b 2(−2a + b)∗ {a, b, c} × {x, y, z}∗ → Q 5

7

(a, xx), 2

3(b, y)

1

2(a, x) + 1 3(b, y)∗

{a, b} → RatE[{x, y} → Q] x 2

3x∗b

  • xa + 1

3(x + y)∗b

7 / 22

slide-23
SLIDE 23

Contexts

context ::= labelset → weightset {a, b} → B a, b (ε + a + b)∗ {a, b, c}? → Z 2 4ε, 2b 2(−2a + b)∗ {a, b, c} × {x, y, z}∗ → Q 5

7

(a, xx), 2

3(b, y)

1

2(a, x) + 1 3(b, y)∗

{a, b} → RatE[{x, y} → Q] x 2

3x∗b

  • xa + 1

3(x + y)∗b

7 / 22

slide-24
SLIDE 24

A Calculus on Types

1

Typing Automata and Rational Expressions

2

A Calculus on Types

3

Use in Vaucanson

8 / 22

slide-25
SLIDE 25

Subtyping

A <: B All values of type A are also values of type B roughly, “A ⊆ B”

9 / 22

slide-26
SLIDE 26

Labelsets and Weightsets Subtypes

{ε} <: A? A <: A? A? <: A∗

10 / 22

slide-27
SLIDE 27

Labelsets and Weightsets Subtypes

{ε} <: A? A <: A? A? <: A∗ With A, B alphabets such that A ⊆ B: A <: B A? <: B? A∗ <: B∗

10 / 22

slide-28
SLIDE 28

Labelsets and Weightsets Subtypes

{ε} <: A? A <: A? A? <: A∗ With A, B alphabets such that A ⊆ B: A <: B A? <: B? A∗ <: B∗ B <: N <: Z <: Q <: R B <: Zmin

10 / 22

slide-29
SLIDE 29

Labelsets and Weightsets Subtypes

{ε} <: A? A <: A? A? <: A∗ With A, B alphabets such that A ⊆ B: A <: B A? <: B? A∗ <: B∗ B <: N <: Z <: Q <: R B <: Zmin L <: RatE[L → W ] W <: RatE[L → W ]

10 / 22

slide-30
SLIDE 30

Subtype On Contexts, Expressions and Automata

L1 <: L2 W1 <: W2 (L1 → W1) <: (L2 → W2) C1 <: C2 RatE[C1] <: RatE[C2] C1 <: C2 Aut[C1] <: Aut[C2]

11 / 22

slide-31
SLIDE 31

Labelset Subtypes

Let A, B be alphabets: A B A ∩ B A ∪ B A? B? (A ∩ B)? (A ∪ B)? A∗ B∗ (A ∩ B)∗ (A ∪ B)∗ {ε}

12 / 22

slide-32
SLIDE 32

Meet and Join

V1 ∨ V2 (join) The least upper bound between V1 and V2. V1 ∧ V2 (meet) The greatest lower bound between V1 and V2. Q ∨ RatE[{x, y, z} → B] = RatE[{x, y, z} → Q] {a, b, c} ∧ {a, b, d} = {a, b}

13 / 22

slide-33
SLIDE 33

Meet and Join

V1 ∨ V2 (join) The least upper bound between V1 and V2. V1 ∧ V2 (meet) The greatest lower bound between V1 and V2. Q ∨ RatE[{x, y, z} → B] = RatE[{x, y, z} → Q] {a, b, c} ∧ {a, b, d} = {a, b}

13 / 22

slide-34
SLIDE 34

Meet and Join

V1 ∨ V2 (join) The least upper bound between V1 and V2. V1 ∧ V2 (meet) The greatest lower bound between V1 and V2. Q ∨ RatE[{x, y, z} → B] = RatE[{x, y, z} → Q] {a, b, c} ∧ {a, b, d} = {a, b}

13 / 22

slide-35
SLIDE 35

Union of Automata

A1 : L1 → W1 A2 : L2 → W2 A1 ∪ A2 : L1 ∨ L2 → W1 ∨ W2

14 / 22

slide-36
SLIDE 36

Union of Automata

A1 : L1 → W1 A2 : L2 → W2 A1 ∪ A2 : L1 ∨ L2 → W1 ∨ W2 A1 : {a, b, c} → Q A2 : {a, b, d} → RatE[{x, y, z} → B] A1 ∪ A2 : →

14 / 22

slide-37
SLIDE 37

Union of Automata

A1 : L1 → W1 A2 : L2 → W2 A1 ∪ A2 : L1 ∨ L2 → W1 ∨ W2 A1 : {a, b, c} → Q A2 : {a, b, d} → RatE[{x, y, z} → B] A1 ∪ A2 : →

14 / 22

slide-38
SLIDE 38

Union of Automata

A1 : L1 → W1 A2 : L2 → W2 A1 ∪ A2 : L1 ∨ L2 → W1 ∨ W2 A1 : {a, b, c} → Q A2 : {a, b, d} → RatE[{x, y, z} → B] A1 ∪ A2 : {a, b, c, d} → because {a, b, c} ∨ {a, b, d} = {a, b, c, d}

14 / 22

slide-39
SLIDE 39

Union of Automata

A1 : L1 → W1 A2 : L2 → W2 A1 ∪ A2 : L1 ∨ L2 → W1 ∨ W2 A1 : {a, b, c} → Q A2 : {a, b, d} → RatE[{x, y, z} → B] A1 ∪ A2 : {a, b, c, d} → because {a, b, c} ∨ {a, b, d} = {a, b, c, d}

14 / 22

slide-40
SLIDE 40

Union of Automata

A1 : L1 → W1 A2 : L2 → W2 A1 ∪ A2 : L1 ∨ L2 → W1 ∨ W2 A1 : {a, b, c} → Q A2 : {a, b, d} → RatE[{x, y, z} → B] A1 ∪ A2 : {a, b, c, d} → RatE[{x, y, z} → Q] because {a, b, c} ∨ {a, b, d} = {a, b, c, d} because Q ∨ RatE[{x, y, z} → B] = RatE[{x, y, z} → Q]

14 / 22

slide-41
SLIDE 41

Synchronized Product of Automata

A1 : A1 → W1 A2 : A2 → W2 A1 & A2 :

15 / 22

slide-42
SLIDE 42

Synchronized Product of Automata

A1 : A1 → W1 A2 : A2 → W2 A1 & A2 : A1 ∧ A2 → W1 ∨ W2

15 / 22

slide-43
SLIDE 43

Synchronized Product of Automata

A1 : A1 → W1 A2 : A2 → W2 A1 & A2 : A1 ∧ A2 → W1 ∨ W2 A1 : {a, b, c} → Q A2 : {a, b, d} → RatE[{x, y, z} → B] A1 & A2 : {a, b} → RatE[{x, y, z} → Q] because {a, b, c} ∧ {a, b, d} = {a, b} because Q ∨ RatE[{x, y, z} → B] = RatE[{x, y, z} → Q]

15 / 22

slide-44
SLIDE 44

Synchronized Product in Vaucanson

p q 1

2a, c

1

3b

1

2a, c

A1 r s yb, d x∗a zb, d A2 p, r q, r p, s q, s 1

3yb

1

2x∗a

1

2x∗a

1

3zb

A1 & A2

16 / 22

slide-45
SLIDE 45

Synchronized Product in Vaucanson

p q 1

2a, c

1

3b

1

2a, c

A1 r s yb, d x∗a zb, d A2 p, r q, r p, s q, s 1

3yb

1

2x∗a

1

2x∗a

1

3zb

A1 & A2

16 / 22

slide-46
SLIDE 46

Synchronized Product in Vaucanson

p q 1

2a, c

1

3b

1

2a, c

A1 r s yb, d x∗a zb, d A2 p, r q, r p, s q, s 1

3yb

1

2x∗a

1

2x∗a

1

3zb

A1 & A2

16 / 22

slide-47
SLIDE 47

Use in Vaucanson

1

Typing Automata and Rational Expressions

2

A Calculus on Types

3

Use in Vaucanson

17 / 22

slide-48
SLIDE 48

Use of Types

Type objects exist, as values, at a low level Dynamic objects wrap low-level objects The dynamic library resolves calls discriminating on type objects The dispatching routine computes resulting types Types can1 be used to generate code at run time

1After publication: now they are. 18 / 22

slide-49
SLIDE 49

Use of Types

Type objects exist, as values, at a low level Dynamic objects wrap low-level objects The dynamic library resolves calls discriminating on type objects The dispatching routine computes resulting types Types can1 be used to generate code at run time

1After publication: now they are. 18 / 22

slide-50
SLIDE 50

Use of Types

Type objects exist, as values, at a low level Dynamic objects wrap low-level objects The dynamic library resolves calls discriminating on type objects The dispatching routine computes resulting types Types can1 be used to generate code at run time

1After publication: now they are. 18 / 22

slide-51
SLIDE 51

Operations on Rational Expressions

E1 : RatE[L1 → W1] E2 : RatE[L2 → W2] ⊙ ∈ {·, +} E1 ⊙ E2 : RatE[L1 ∨ L2 → W1 ∨ W2] w1 : W1 E2 : RatE[L2 → W2] w1 · E2 : RatE[L2 → W1 ∨ W2] E1 : RatE[L1 → W1] w2 : W2 E1 · w2 : RatE[L1 → W1 ∨ W2]

19 / 22

slide-52
SLIDE 52

Operations on Automata

A1 : L1 → W1 A2 : L2 → W2 ⊙ ∈ {·, +} A1 ⊙ A2 : L1 ∨ L2 → W1 ∨ W2 A1 : A1 → W1 A2 : A2 → W2 ⊙ ∈ {≬, ↑} A1 ⊙ A2 : A1 ∨ A2 → W1 ∨ W2 w1 : W1 A2 : L2 → W2 w1 · A2 : L2 → W1 ∨ W2 A1 : L1 → W1 w2 : W2 A1 · w2 : L1 → W1 ∨ W2

20 / 22

slide-53
SLIDE 53

Conclusion

“State” Acceptors, transducers Efficient static API Flexible dynamic API with runtime compilation User[/student]-friendly IPython interface “Transition” Better transducer support Improved type-checking errors Richer expressions Metadata on states2 . . .

2After publication: now largely done. 21 / 22

slide-54
SLIDE 54

Conclusion

“State” Acceptors, transducers Efficient static API Flexible dynamic API with runtime compilation User[/student]-friendly IPython interface “Transition” Better transducer support Improved type-checking errors Richer expressions Metadata on states2 . . .

2After publication: now largely done. 21 / 22

slide-55
SLIDE 55

Questions?

22 / 22