55
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´ ecom-ParisTech http://vaucanson.lrde.epita.fr http://vaucanson-project.org CIAA 2014; August, 1st 2014 (2014-08-03 00:28:28 +0200 a998c33)

A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

  • Upload
    others

  • View
    36

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

A Type System for Weighted Automataand Rational Expressions

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

1EPITA/LRDE, 2LaBRI, Universite de Bordeaux, 3LTCI, CNRS / Telecom-ParisTech

http://vaucanson.lrde.epita.frhttp://vaucanson-project.org

CIAA 2014; August, 1st 2014(2014-08-03 00:28:28 +0200 a998c33)

Page 2: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Vaucanson

General-purpose platform for weighted automata and transducers.

Genericity

Acceptors and transducersRational expressionsWeights: Boolean, Usual, Tropical. . .Labels: letter, word, ε. . .Letters: chars, ints. . .

Performance

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

Flexibility

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

2 / 22

Page 3: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Vaucanson

General-purpose platform for weighted automata and transducers.

Genericity

Acceptors and transducersRational expressionsWeights: Boolean, Usual, Tropical. . .Labels: letter, word, ε. . .Letters: chars, ints. . .

Performance

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

Flexibility

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

2 / 22

Page 4: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Vaucanson

General-purpose platform for weighted automata and transducers.

Genericity

Acceptors and transducersRational expressionsWeights: Boolean, Usual, Tropical. . .Labels: letter, word, ε. . .Letters: chars, ints. . .

Performance

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

Flexibility

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

2 / 22

Page 5: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Vaucanson

General-purpose platform for weighted automata and transducers.

Genericity

Acceptors and transducersRational expressionsWeights: Boolean, Usual, Tropical. . .Labels: letter, word, ε. . .Letters: chars, ints. . .

Performance

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

Flexibility

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

2 / 22

Page 6: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Typing Automata and Rational Expressions

1 Typing Automata and Rational Expressions

2 A Calculus on Types

3 Use in Vaucanson

3 / 22

Page 7: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧> ∨ > ∧> = >

bb

→ >

a

b

b

〈2〉a

〈2〉b

1× 1 + 2× 1 = 3

bb

→ 3

4 / 22

Page 8: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧>

∨ > ∧> = >

bb

→ >

a

b

b

〈2〉a

〈2〉b

1× 1 + 2× 1 = 3

bb

→ 3

4 / 22

Page 9: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧>

> ∧>

= >

bb

→ >

a

b

b

〈2〉a

〈2〉b

1× 1 + 2× 1 = 3

bb

→ 3

4 / 22

Page 10: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧> ∨ > ∧> = > bb → >

a

b

b

〈2〉a

〈2〉b

1× 1 + 2× 1 = 3

bb

→ 3

4 / 22

Page 11: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧> ∨ > ∧> = > bb → >

a

b

b

〈2〉a

〈2〉b

1× 1 + 2× 1 = 3

bb

→ 3

4 / 22

Page 12: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧> ∨ > ∧> = > bb → >

a

b

b

〈2〉a

〈2〉b

1× 1

+ 2× 1 = 3

bb

→ 3

4 / 22

Page 13: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧> ∨ > ∧> = > bb → >

a

b

b

〈2〉a

〈2〉b

1× 1 + 2× 1

= 3

bb

→ 3

4 / 22

Page 14: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

From Recognizers to Weighted Automata

a

b

b

a

b

> ∧> ∨ > ∧> = > bb → >

a

b

b

〈2〉a

〈2〉b

1× 1 + 2× 1 = 3 bb → 3

4 / 22

Page 15: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Many Different Kinds of Weights

〈B,∨,∧〉〈Z,+,×〉〈Q,+,×〉〈R,+,×〉〈Z,min,+〉Rational expressions

Tuples

. . .

5 / 22

Page 16: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Many Different Kinds of Labels

lettersa, b

nullablesε, a

wordsε, a, bb

tuples(a, x), (b, y)

(a, x , u), (b, yy , ε)

6 / 22

Page 17: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Many Different Kinds of Labels

lettersa, b

nullablesε, a

wordsε, a, bb

tuples(a, x), (b, y)

(a, x , u), (b, yy , ε)

6 / 22

Page 18: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Many Different Kinds of Labels

lettersa, b

nullablesε, a

wordsε, a, bb

tuples(a, x), (b, y)

(a, x , u), (b, yy , ε)

6 / 22

Page 19: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Many Different Kinds of Labels

lettersa, b

nullablesε, a

wordsε, a, bb

tuples(a, x), (b, y)

(a, x , u), (b, yy , ε)

6 / 22

Page 20: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Contexts

context ::= labelset → weightset

{a, b} → Ba, b (ε + a + b)∗

{a, b, c}? → Z〈2〉 〈4〉ε, 〈2〉b 〈2〉(〈−2〉a + b)∗

{a, b, c} × {x , y , z}∗ → Q〈5

7〉 (a, xx), 〈23〉(b, y) 〈1

2〉(a, x) + 〈13〉(b, y)∗

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

〈x〉 〈〈23〉x

∗〉b (〈x〉a + 〈〈1

3〉(x + y)∗〉b)∗

7 / 22

Page 21: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Contexts

context ::= labelset → weightset

{a, b} → Ba, b (ε + a + b)∗

{a, b, c}? → Z〈2〉 〈4〉ε, 〈2〉b 〈2〉(〈−2〉a + b)∗

{a, b, c} × {x , y , z}∗ → Q〈5

7〉 (a, xx), 〈23〉(b, y) 〈1

2〉(a, x) + 〈13〉(b, y)∗

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

〈x〉 〈〈23〉x

∗〉b (〈x〉a + 〈〈1

3〉(x + y)∗〉b)∗

7 / 22

Page 22: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Contexts

context ::= labelset → weightset

{a, b} → Ba, b (ε + a + b)∗

{a, b, c}? → Z〈2〉 〈4〉ε, 〈2〉b 〈2〉(〈−2〉a + b)∗

{a, b, c} × {x , y , z}∗ → Q〈5

7〉 (a, xx), 〈23〉(b, y) 〈1

2〉(a, x) + 〈13〉(b, y)∗

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

〈x〉 〈〈23〉x

∗〉b (〈x〉a + 〈〈1

3〉(x + y)∗〉b)∗

7 / 22

Page 23: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Contexts

context ::= labelset → weightset

{a, b} → Ba, b (ε + a + b)∗

{a, b, c}? → Z〈2〉 〈4〉ε, 〈2〉b 〈2〉(〈−2〉a + b)∗

{a, b, c} × {x , y , z}∗ → Q〈5

7〉 (a, xx), 〈23〉(b, y) 〈1

2〉(a, x) + 〈13〉(b, y)∗

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

〈x〉 〈〈23〉x

∗〉b (〈x〉a + 〈〈1

3〉(x + y)∗〉b)∗

7 / 22

Page 24: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

A Calculus on Types

1 Typing Automata and Rational Expressions

2 A Calculus on Types

3 Use in Vaucanson

8 / 22

Page 25: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Subtyping

A <: B

All values of type A are also values of type B

roughly, “A ⊆ B”

9 / 22

Page 26: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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 <: RB <: Zmin

L <: RatE[L→W ] W <: RatE[L→W ]

10 / 22

Page 27: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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 <: RB <: Zmin

L <: RatE[L→W ] W <: RatE[L→W ]

10 / 22

Page 28: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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 <: RB <: Zmin

L <: RatE[L→W ] W <: RatE[L→W ]

10 / 22

Page 29: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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 <: RB <: Zmin

L <: RatE[L→W ] W <: RatE[L→W ]

10 / 22

Page 30: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 31: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 32: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 33: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 34: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 35: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 36: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 37: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 38: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 39: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 40: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 41: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 42: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 43: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 44: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Synchronized Product in Vaucanson

p

q

〈12〉a, c

〈13〉b

〈12〉a, c

A1

r s

〈y〉b, d

〈x∗〉a

〈z〉b, dA2

p, r

q, r

p, s

q, s

〈〈13〉y〉b

〈〈12〉x

∗〉a

〈〈12〉x

∗〉a

〈〈13〉z〉b

A1 &A2

16 / 22

Page 45: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Synchronized Product in Vaucanson

p

q

〈12〉a, c

〈13〉b

〈12〉a, c

A1

r s

〈y〉b, d

〈x∗〉a

〈z〉b, dA2

p, r

q, r

p, s

q, s

〈〈13〉y〉b

〈〈12〉x

∗〉a

〈〈12〉x

∗〉a

〈〈13〉z〉b

A1 &A2

16 / 22

Page 46: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Synchronized Product in Vaucanson

p

q

〈12〉a, c

〈13〉b

〈12〉a, c

A1

r s

〈y〉b, d

〈x∗〉a

〈z〉b, dA2

p, r

q, r

p, s

q, s

〈〈13〉y〉b

〈〈12〉x

∗〉a

〈〈12〉x

∗〉a

〈〈13〉z〉b

A1 &A2

16 / 22

Page 47: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Use in Vaucanson

1 Typing Automata and Rational Expressions

2 A Calculus on Types

3 Use in Vaucanson

17 / 22

Page 48: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 49: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 50: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 51: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

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

Page 52: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Operations on Automata

A1 : L1 →W1 A2 : L2 →W2� ∈ {·,+}

A1 �A2 : L1 ∨ L2 →W1 ∨W2

A1 : A1 →W1 A2 : A2 →W2� ∈ {G, ↑}

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

Page 53: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Conclusion

“State” Acceptors, transducersEfficient static APIFlexible dynamic API with runtime compilationUser[/student]-friendly IPython interface

“Transition” Better transducer supportImproved type-checking errorsRicher expressionsMetadata on states2

. . .

2After publication: now largely done. 21 / 22

Page 54: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Conclusion

“State” Acceptors, transducersEfficient static APIFlexible dynamic API with runtime compilationUser[/student]-friendly IPython interface

“Transition” Better transducer supportImproved type-checking errorsRicher expressionsMetadata on states2

. . .

2After publication: now largely done. 21 / 22

Page 55: A Type System for Weighted Automata and Rational Expressionsageinghacker.net/talks/ciaa-2014--demaille-duretlutz-lombardy-saiu... · 1 Typing Automata and Rational Expressions 2 A

Questions?

22 / 22