product rules and distributive laws
play

Product rules and distributive laws Joost Winter University of - PowerPoint PPT Presentation

Product rules and distributive laws Joost Winter University of Warsaw April 2, 2016 Overview Main goal of this paper: a categorical framework for a two-step determinization process in which product rules, such as Brzozowskis rule ( xy ) a


  1. Product rules and distributive laws Joost Winter University of Warsaw April 2, 2016

  2. Overview ◮ Main goal of this paper: a categorical framework for a two-step determinization process in which product rules, such as Brzozowski’s rule ( xy ) a = x a y + o ( x ) y a , or the familiar Leibniz rule from calculus ( xy ) a = x a y + xy a , can be understood. ◮ First step (transforming a FST -coalgebra into a FS -coalgebra) is given by the product rule. ◮ Second step (transforming a FS -coalgebra into a F -coalgebra) is the usual determinization/linearization for weighted automata. ◮ We provide a general perspective on this process, including a coherence condition giving a sufficient condition for the two-step determinization process to be possible.

  3. Distributive laws Given: 1. A monad ( T , η T , µ T ). 2. Either a monad ( S , η S , µ S ), an endofunctor S or a copointed endofunctor ( S , ǫ ). S µ T ◦ λ T ◦ T λ a. λ ◦ η T S S η T c. λ ◦ µ T S = = b. λ ◦ T η S η S T d. λ ◦ T µ S µ S T ◦ S λ ◦ λ S = = e. ǫ T ◦ λ = T ǫ ◮ A distributive law between monads satisfies a. , b. , c. , and d. ◮ A distributive law of a monad over an endofunctor satisfies a. and c. ◮ A distributive law of a monad over a copointed endofunctor satisfies a. , c. , and e.

  4. Product rules – three examples (frequently featured in work by Rutten and many others as coinductive definitions) ◮ Brzozowski rule – convolution product: o (1) = 1 1 a = 0 o ( xy ) = o ( x ) o ( y ) ( xy ) a = x a y + o ( x ) y a ◮ Leibniz rule – shuffle product: o (1) = 1 1 a = 0 o ( x ⊗ y ) = o ( x ) o ( y ) ( x ⊗ y ) a = x a ⊗ y + x ⊗ y a ◮ Pointwise rule – Hadamard product: o ( 1 ) = 1 1 a = 1 o ( x ⊙ y ) = o ( x ) o ( y ) ( x ⊙ y ) a = x a ⊙ y a

  5. Deteriminizing a nondeterministic automaton, bialgebraically η X ✲ P ω ( X ) � − � ✲ P ( A ∗ ) X o , ˆ δ ) (ˆ ( o , δ ) ( O , ∆) ✛ ❄ ❄ 2 × � − � A 2 × P ω ( X ) A 2 × P ω ( X ∗ ) A ✲ Categorically well-understood (see e.g. the work by Bartels, Jacobs/Silva/Sokolova and many others) via bialgebras and distributive laws. o , ˆ (ˆ δ ) can be obtained from ( o , δ ) using the distributive law.

  6. The general picture η X ✲ TX � − � ✲ ν F X ˆ δ δ ∆ ✛ ❄ F � − � ❄ FTX F ν F ✲ Given a distributive law λ : TF ⇒ FT (monad over endofunctor) the extension ˆ δ is obtained by: ˆ δ = F µ X ◦ λ TX ◦ T δ The distributive law can be seen as defining a T -algebra structure on the final F -coalgebra.

  7. Determinization for context-free languages (one step) η X ✲ P ω ( X ∗ ) � − � ✲ P ( A ∗ ) X o , ˆ δ ) (ˆ ( o , δ ) ( O , ∆) ✛ ❄ ❄ 2 × � − � A 2 × P ω ( X ∗ ) A 2 × P ω ( X ∗ ) A ✲ Various variants, most involving a distributive law of a monad over a (cofree) copointed functor. See e.g. Winter/Bonsangue/Rutten, and Bonsangue/Hansen/Kurz/Rot. Can also be generalized from (context-free) languages to (constructively) algebraic power series. When we regard the distributive law as defining an algebra structure on the final coalgebra, we can see it also as defining the convolution product on power series (together with linearity of derivative). Similarly, there are laws for the shuffle and Hadamard products/product rules.

  8. Determinization for context-free languages (two steps) η 0 η 1 X ∗ ✲ P ω ( X ∗ ) � − � ✲ P ( A ∗ ) X ✲ X ∗ X ( o ♯ , δ ♯ ) o , ˆ δ ) (ˆ ( o , δ ) ( O , ∆) ✛ ✛ ❄ ❄ 2 × � − � A 2 × P ω ( X ∗ ) A 2 × P ω ( X ∗ ) A ✲ This can again be generalized from languages to power series. But, can we understand this diagram categorically, too?

  9. Semimodules and algebras for a semiring Given a semiring ( S , ¯ 0 , ¯ 1 , ⊕ , · ), a (left) S -semimodule is a tuple ( X , 0 , + , × ): 1. ( X , 0 , +) is a commutative monoid, 2. × : S × X → X (left-scalar product) satisfies: ¯ ( s ⊕ t ) × x = s × x + t × x 0 × x = 0 s × ( x + y ) = s × x + s × y s × 0 = 0 ¯ s × ( t × x ) = ( st ) × x 1 × x = x Given a commutative semiring S , a (unital, associative) S -algebra (see e.g. Eilenberg 1974) is a tuple ( X , 0 , 1 , + , · , × ): 1. ( X , 0 , 1 , + , · ) is a semiring. 2. ( X , 0 , + , × ) is a S -semimodule. 3. Satisfying: s × ( xy ) = ( s × x ) y = x ( s × y ).

  10. . . . via distributive laws (between monads) Recall: 1. Algebras for the monad − ∗ are monoids . 2. Algebras for the monad Lin S defined by Lin S ( X ) = { f ∈ S X | supp( f ) is finite } with the ‘expected’ (see e.g. Jacobs/Silva/Sokolova 2012) multiplication (on the left/right) are left/right S -semimodules. If S is commutative, there is a distributive law of − ∗ over Lin S , creating a monad structure on S �−� := Lin S ( − ∗ ). Its algebras are the S -algebras as just defined.

  11. . . . via distributive laws (between monads) (2) The distributive law λ : (Lin S ( − )) ∗ ⇒ Lin K ( − ∗ ) can be given by: m i m 1 � n � m n � n n � � � � � � � λ X k ij × x ij = · · · k ij i × x ij i i =1 j =1 j 1 =1 j n =1 i =1 i =1 (see e.g. Beck ’69 for the case S = Z ) S S -semimodules S -algebras (join) semilattices idempotent semirings B commutative monoids semirings N Abelian groups rings Z

  12. Combining distributive laws (acc. to Cheng) Let S , T , and U be monads, and let λ 0 : UT ⇒ TU , λ 1 : US ⇒ SU , and λ 2 : TS ⇒ ST be distributive laws. Theorem T.f.a.e.: 1. The diagram of natural transformations U λ 2 λ 1 T ✲ SUT ✲ UST UTS λ 0 S S λ 0 T λ 1 λ 2 U ✲ STU ❄ ❄ ✲ TSU TUS (the Yang Baxter diagram) commutes. 2. λ 2 U ◦ T λ 1 is a dist. law of the composite monad TU over S. 3. S λ 0 ◦ λ 1 T is a dist. law of U over the composite monad ST.

  13. Same result for dist. laws over endofunctors Now, let S and T be monads, and F and endofunctor... λ 0 dist. law between monads, λ 1 and λ 2 dist. law of monad over endofunctor Theorem T.f.a.e.: 1. The diagram of natural transformations T λ 2 λ 1 S ✲ FTS ✲ TFS TSF λ 0 F F λ 0 S λ 1 λ 2 T ✲ FST ❄ ❄ ✲ SFT STF (the Yang Baxter diagram) commutes. 2. λ 2 T ◦ S λ 1 is a dist. law of the composite monad ST over F. (also works for copointed)

  14. Instance: the Hadamard product We can use the framework of the previous page with the following instances (assume S to be commutative): ◮ S = Lin S ( − ), the monad for S -semimodules ◮ T = − ∗ , the list monad ◮ F = S × − A , the endofunctor for Moore machines with output in S . Take λ 0 : TS ⇒ ST as defined before (making ST the monad for S -algebras), make λ 2 the pointwise distributive law for S -weighted automata, and define λ 1 : ( S × − A ) ∗ ⇒ ( S × ( − ∗ ) A ) again pointwise, as follows: λ 1 ( ǫ ) = (1 S , ( a �→ ε )) λ 1 (( o , a �→ d a ) w ) let ( p , a �→ e a ) = λ 1 ( w ) in = ( op , a �→ d a e a )

  15. How about convolution and shuffle product ◮ λ 1 in the previous slide can be seen as defining , coinductively, the product rule 1 a = 1, ( xy ) a = x a y a on the final coalgebra. ◮ How about other rules, such as ( xy ) a = x a y + o ( x ) y a or ( xy ) a = xa y + xy a ?

  16. How about convolution and shuffle product ◮ λ 1 in the previous slide can be seen as defining , coinductively, the product rule 1 a = 1, ( xy ) a = x a y a on the final coalgebra. ◮ How about other rules, such as ( xy ) a = x a y + o ( x ) y a or ( xy ) a = xa y + xy a ? ◮ Because of the presence of addition on the right hand side of the equations, it seems this will not work, and we need a law of the type λ : TF ⇒ FST

  17. Distributive laws into a composite monad Given: 1. A monad ( T , η T , µ T ), a monad ( S , η S , µ S ), a distributive law between monads λ 0 : TS ⇒ ST , and an endofunctor F , A natural transformation λ : TF ⇒ FST is a distributive law of T over F into the composite monad ST whenever: λ ◦ η T F F η ST = F µ ST ◦ λ ST ◦ T λ λ ◦ µ T F = If ( F , ǫ ) is a copointed endofunctor, additionally: ǫ ST ◦ λ = η S ◦ T ǫ

  18. The other two product rules Brzozowski/convolution rule: λ X (1) = (1 , 1 , a �→ 0) λ X ( x , o , a �→ d a ) w = let ( y , p , a �→ e a ) = λ X ( w ) in ( xy , op , a �→ d a y + oe a ) Leibniz/shuffle rule: λ X (1) = (1 , 1 , a �→ 0) λ X ( x , o , a �→ d a ) w = let ( y , p , a �→ e a ) = λ X ( w ) in ( xy , op , a �→ d a y + xe a )

  19. Another coherence condition (1) T λ 2 λ 1 S ✲ FSTS FS λ 0 ✲ TFS ✲ FSST TSF λ 0 F F µ S T S λ 1 ✲ SFST λ 2 ST ✲ FSST F µ S T ✲ FST ❄ ❄ STF Theorem Given monads ( T , η T , µ T ) and ( S , η S , µ S ) , and an endofunctor F such that: ◮ λ 0 is a distributive law of the monad T over the monad S. ◮ λ 1 is a distributive law of the monad T over the endofunctor F into the composite monad ST. . . ◮ λ 2 is a distributive law of the monad S over the endofunctor F.

  20. Another coherence condition (1) T λ 2 λ 1 S ✲ FSTS FS λ 0 ✲ TFS ✲ FSST TSF λ 0 F F µ S T S λ 1 ✲ SFST λ 2 ST ✲ FSST F µ S T ✲ FST ❄ ❄ STF Theorem . . . ˆ λ : STF → FST, given by STF S λ 1 ✲ SFST λ 2 ST ✲ FSST F µ S T ✲ FST is a distributive law of the composite monad ST over F iff the coherence condition holds. (again works for copointed)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend