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)
Vaucanson General-purpose platform for weighted automata and transducers. Genericity Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε . . . Letters: char s, int s. . . 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
Vaucanson General-purpose platform for weighted automata and transducers. Genericity Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε . . . Letters: char s, int s. . . 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
Vaucanson General-purpose platform for weighted automata and transducers. Genericity Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε . . . Letters: char s, int s. . . 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
Vaucanson General-purpose platform for weighted automata and transducers. Genericity Acceptors and transducers Rational expressions Weights: Boolean, Usual, Tropical. . . Labels: letter, word, ε . . . Letters: char s, int s. . . 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
Typing Automata and Rational Expressions Typing Automata and Rational Expressions 1 A Calculus on Types 2 Use in Vaucanson 3 3 / 22
From Recognizers to Weighted Automata a a b bb b b 4 / 22
From Recognizers to Weighted Automata a a b ⊤ ∧ ⊤ bb b b 4 / 22
From Recognizers to Weighted Automata a a b ⊤ ∧ ⊤ ⊤ ∧ ⊤ bb b b 4 / 22
From Recognizers to Weighted Automata a a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ b b 4 / 22
From Recognizers to Weighted Automata a a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ b b � 2 � a a b bb b � 2 � b 4 / 22
From Recognizers to Weighted Automata a a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ b b � 2 � a a b 1 × 1 bb b � 2 � b 4 / 22
From Recognizers to Weighted Automata a a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ b b � 2 � a a b 1 × 1 + 2 × 1 bb b � 2 � b 4 / 22
From Recognizers to Weighted Automata a a b ⊤ ∧ ⊤ ∨ ⊤ ∧ ⊤ = ⊤ bb → ⊤ b b � 2 � a a b 1 × 1 + 2 × 1 = 3 bb → 3 b � 2 � b 4 / 22
Many Different Kinds of Weights � B , ∨ , ∧� � Z , + , ×� � Q , + , ×� � R , + , ×� � Z , min , + � Rational expressions Tuples . . . 5 / 22
Many Different Kinds of Labels a , b letters ε, a nullables ε, a , bb words ( a , x ) , ( b , y ) tuples ( a , x , u ) , ( b , yy , ε ) 6 / 22
Many Different Kinds of Labels a , b letters ε, a nullables ε, a , bb words ( a , x ) , ( b , y ) tuples ( a , x , u ) , ( b , yy , ε ) 6 / 22
Many Different Kinds of Labels a , b letters ε, a nullables ε, a , bb words ( a , x ) , ( b , y ) tuples ( a , x , u ) , ( b , yy , ε ) 6 / 22
Many Different Kinds of Labels a , b letters ε, a nullables ε, a , bb words ( a , x ) , ( b , y ) tuples ( a , x , u ) , ( b , yy , ε ) 6 / 22
Contexts context ::= labelset → weightset { a , b } → B a , b ( ε + a + b ) ∗ { a , b , c } ? → Z � 2 � � 4 � ε, � 2 � b � 2 � ( �− 2 � a + b ) ∗ { a , b , c } × { x , y , z } ∗ → Q � 5 ( a , xx ) , � 2 7 � 3 � ( b , y ) � 1 2 � ( a , x ) + � 1 3 � ( b , y ) ∗ { a , b } → RatE[ { x , y } → Q ] �� 2 3 � x ∗ � b � x � � x � a + �� 1 � ∗ � 3 � ( x + y ) ∗ � b 7 / 22
Contexts context ::= labelset → weightset { a , b } → B a , b ( ε + a + b ) ∗ { a , b , c } ? → Z � 2 � � 4 � ε, � 2 � b � 2 � ( �− 2 � a + b ) ∗ { a , b , c } × { x , y , z } ∗ → Q � 5 ( a , xx ) , � 2 7 � 3 � ( b , y ) � 1 2 � ( a , x ) + � 1 3 � ( b , y ) ∗ { a , b } → RatE[ { x , y } → Q ] �� 2 3 � x ∗ � b � x � � x � a + �� 1 � ∗ � 3 � ( x + y ) ∗ � b 7 / 22
Contexts context ::= labelset → weightset { a , b } → B a , b ( ε + a + b ) ∗ { a , b , c } ? → Z � 2 � � 4 � ε, � 2 � b � 2 � ( �− 2 � a + b ) ∗ { a , b , c } × { x , y , z } ∗ → Q � 5 ( a , xx ) , � 2 7 � 3 � ( b , y ) � 1 2 � ( a , x ) + � 1 3 � ( b , y ) ∗ { a , b } → RatE[ { x , y } → Q ] �� 2 3 � x ∗ � b � x � � x � a + �� 1 � ∗ � 3 � ( x + y ) ∗ � b 7 / 22
Contexts context ::= labelset → weightset { a , b } → B a , b ( ε + a + b ) ∗ { a , b , c } ? → Z � 2 � � 4 � ε, � 2 � b � 2 � ( �− 2 � a + b ) ∗ { a , b , c } × { x , y , z } ∗ → Q � 5 ( a , xx ) , � 2 7 � 3 � ( b , y ) � 1 2 � ( a , x ) + � 1 3 � ( b , y ) ∗ { a , b } → RatE[ { x , y } → Q ] �� 2 3 � x ∗ � b � x � � x � a + �� 1 � ∗ � 3 � ( x + y ) ∗ � b 7 / 22
A Calculus on Types Typing Automata and Rational Expressions 1 A Calculus on Types 2 Use in Vaucanson 3 8 / 22
Subtyping A < : B All values of type A are also values of type B roughly, “ A ⊆ B ” 9 / 22
Labelsets and Weightsets Subtypes { ε } < : A ? A < : A ? A ? < : A ∗ 10 / 22
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
Labelsets and Weightsets Subtypes { ε } < : A ? A < : A ? A ? < : A ∗ B < : N < : Z < : Q < : R B < : Z min With A , B alphabets such that A ⊆ B : A ? < : B ? A ∗ < : B ∗ A < : B 10 / 22
Labelsets and Weightsets Subtypes { ε } < : A ? A < : A ? A ? < : A ∗ B < : N < : Z < : Q < : R B < : Z min With A , B alphabets such that A ⊆ B : A ? < : B ? A ∗ < : B ∗ A < : B L < : RatE[ L → W ] W < : RatE[ L → W ] 10 / 22
Subtype On Contexts, Expressions and Automata L 1 < : L 2 W 1 < : W 2 ( L 1 → W 1 ) < : ( L 2 → W 2 ) C 1 < : C 2 RatE[ C 1 ] < : RatE[ C 2 ] C 1 < : C 2 Aut[ C 1 ] < : Aut[ C 2 ] 11 / 22
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
Meet and Join V 1 ∨ V 2 (join) The least upper bound between V 1 and V 2 . V 1 ∧ V 2 (meet) The greatest lower bound between V 1 and V 2 . ∨ RatE[ { x , y , z } → B ] = RatE[ { x , y , z } → Q ] Q { a , b , c } ∧ { a , b , d } = { a , b } 13 / 22
Meet and Join V 1 ∨ V 2 (join) The least upper bound between V 1 and V 2 . V 1 ∧ V 2 (meet) The greatest lower bound between V 1 and V 2 . ∨ RatE[ { x , y , z } → B ] = RatE[ { x , y , z } → Q ] Q { a , b , c } ∧ { a , b , d } = { a , b } 13 / 22
Meet and Join V 1 ∨ V 2 (join) The least upper bound between V 1 and V 2 . V 1 ∧ V 2 (meet) The greatest lower bound between V 1 and V 2 . ∨ RatE[ { x , y , z } → B ] = RatE[ { x , y , z } → Q ] Q { a , b , c } ∧ { a , b , d } = { a , b } 13 / 22
Union of Automata A 1 : L 1 → W 1 A 2 : L 2 → W 2 A 1 ∪ A 2 : L 1 ∨ L 2 → W 1 ∨ W 2 14 / 22
Union of Automata A 1 : L 1 → W 1 A 2 : L 2 → W 2 A 1 ∪ A 2 : L 1 ∨ L 2 → W 1 ∨ W 2 A 1 : { a , b , c } → Q A 2 : { a , b , d } → RatE[ { x , y , z } → B ] A 1 ∪ A 2 : → 14 / 22
Union of Automata A 1 : L 1 → W 1 A 2 : L 2 → W 2 A 1 ∪ A 2 : L 1 ∨ L 2 → W 1 ∨ W 2 A 1 : { a , b , c } → Q A 2 : { a , b , d } → RatE[ { x , y , z } → B ] A 1 ∪ A 2 : → 14 / 22
Union of Automata A 1 : L 1 → W 1 A 2 : L 2 → W 2 A 1 ∪ A 2 : L 1 ∨ L 2 → W 1 ∨ W 2 A 1 : { a , b , c } → Q A 2 : { a , b , d } → RatE[ { x , y , z } → B ] A 1 ∪ A 2 : { a , b , c , d } → { a , b , c } ∨ { a , b , d } = { a , b , c , d } because 14 / 22
Union of Automata A 1 : L 1 → W 1 A 2 : L 2 → W 2 A 1 ∪ A 2 : L 1 ∨ L 2 → W 1 ∨ W 2 A 1 : { a , b , c } → Q A 2 : { a , b , d } → RatE[ { x , y , z } → B ] A 1 ∪ A 2 : { a , b , c , d } → { a , b , c } ∨ { a , b , d } = { a , b , c , d } because 14 / 22
Recommend
More recommend