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

product rules and distributive laws
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Product rules and distributive laws

Joost Winter

University of Warsaw

April 2, 2016

slide-2
SLIDE 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 = xay + o(x)ya, or the familiar Leibniz rule from calculus (xy)a = xay + xya, 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.

slide-3
SLIDE 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, ǫ).

  • a. λ ◦ ηTS

= SηT

  • c. λ ◦ µTS

= SµT ◦ λT ◦ Tλ

  • b. λ ◦ TηS

= ηST

  • d. λ ◦ TµS

= µST ◦ 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.

slide-4
SLIDE 4

Product rules – three examples

(frequently featured in work by Rutten and many others as coinductive definitions)

◮ Brzozowski rule – convolution product:

  • (1)

= 1 1a =

  • (xy)

=

  • (x)o(y)

(xy)a = xay + o(x)ya

◮ Leibniz rule – shuffle product:

  • (1)

= 1 1a =

  • (x ⊗ y)

=

  • (x)o(y)

(x ⊗ y)a = xa ⊗ y + x ⊗ ya

◮ Pointwise rule – Hadamard product:

  • (1)

= 1 1a = 1

  • (x ⊙ y)

=

  • (x)o(y)

(x ⊙ y)a = xa ⊙ ya

slide-5
SLIDE 5

Deteriminizing a nondeterministic automaton, bialgebraically

X ηX ✲ Pω(X) − ✲ P(A∗) 2 × Pω(X)A (o, δ)

2 × −A

✲ ✛

  • , ˆ

δ) 2 × Pω(X ∗)A (O, ∆)

Categorically well-understood (see e.g. the work by Bartels, Jacobs/Silva/Sokolova and many others) via bialgebras and distributive laws. (ˆ

  • , ˆ

δ) can be obtained from (o, δ) using the distributive law.

slide-6
SLIDE 6

The general picture

X ηX ✲ TX − ✲ νF FTX δ

F−

✲ ✛

ˆ δ 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

  • n the final F-coalgebra.
slide-7
SLIDE 7

Determinization for context-free languages (one step)

X ηX✲ Pω(X ∗) − ✲ P(A∗) 2 × Pω(X ∗)A (o, δ)

2 × −A

✲ ✛

  • , ˆ

δ) 2 × Pω(X ∗)A (O, ∆)

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.

slide-8
SLIDE 8

Determinization for context-free languages (two steps)

X η0

X ✲ X ∗

η1

X ∗ ✲ Pω(X ∗) − ✲ P(A∗)

2 × Pω(X ∗)A (o, δ)

2 × −A

✲ ✛

  • , ˆ

δ)

(o♯, δ♯) 2 × Pω(X ∗)A (O, ∆)

This can again be generalized from languages to power series. But, can we understand this diagram categorically, too?

slide-9
SLIDE 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 = s × (x + y) = s × x + s × y s × 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).
slide-10
SLIDE 10

. . . via distributive laws (between monads)

Recall:

  • 1. Algebras for the monad −∗ are monoids.
  • 2. Algebras for the monad LinS defined by

LinS(X) = {f ∈ SX | 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 LinS, creating a monad structure on S− := LinS(−∗). Its algebras are the S-algebras as just defined.

slide-11
SLIDE 11

. . . via distributive laws (between monads) (2)

The distributive law λ : (LinS(−))∗ ⇒ LinK(−∗) can be given by: λX

  • n
  • i=1

mi

  • j=1

kij × xij

  • =

m1

  • j1=1

· · ·

mn

  • jn=1
  • n
  • i=1

kiji ×

n

  • i=1

xiji

  • (see e.g. Beck ’69 for the case S = Z)

S S-semimodules S-algebras B (join) semilattices idempotent semirings N commutative monoids semirings Z Abelian groups rings

slide-12
SLIDE 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

UTS Uλ2

✲ UST

λ1T✲ SUT TUS λ0S

Tλ1

✲ TSU

λ2U✲ STU Sλ0

(the Yang Baxter diagram) commutes.

  • 2. λ2U ◦ Tλ1 is a dist. law of the composite monad TU over S.
  • 3. Sλ0 ◦ λ1T is a dist. law of U over the composite monad ST.
slide-13
SLIDE 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

TSF Tλ2

✲ TFS

λ1S✲ FTS STF λ0F

Sλ1

✲ SFT

λ2T✲ FST Fλ0

(the Yang Baxter diagram) commutes.

  • 2. λ2T ◦ Sλ1 is a dist. law of the composite monad ST over F.

(also works for copointed)

slide-14
SLIDE 14

Instance: the Hadamard product

We can use the framework of the previous page with the following instances (assume S to be commutative):

◮ S = LinS(−), the monad for S-semimodules ◮ T = −∗, the list monad ◮ F = S × −A, the endofunctor for Moore machines with

  • utput 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(ǫ) = (1S, (a → ε)) λ1((o, a → da)w) = let (p, a → ea) = λ1(w) in (op, a → daea)

slide-15
SLIDE 15

How about convolution and shuffle product

◮ λ1 in the previous slide can be seen as defining, coinductively,

the product rule 1a = 1, (xy)a = xaya on the final coalgebra.

◮ How about other rules, such as (xy)a = xay + o(x)ya or

(xy)a = xay + xya?

slide-16
SLIDE 16

How about convolution and shuffle product

◮ λ1 in the previous slide can be seen as defining, coinductively,

the product rule 1a = 1, (xy)a = xaya on the final coalgebra.

◮ How about other rules, such as (xy)a = xay + o(x)ya or

(xy)a = xay + xya?

◮ 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

  • f the type

λ : TF ⇒ FST

slide-17
SLIDE 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

  • ver F into the composite monad ST whenever:

λ ◦ ηTF = FηST λ ◦ µTF = FµST ◦ λST ◦ Tλ If (F, ǫ) is a copointed endofunctor, additionally: ǫST ◦ λ = ηS ◦ Tǫ

slide-18
SLIDE 18

The other two product rules

Brzozowski/convolution rule: λX(1) = (1, 1, a → 0) λX(x, o, a → da)w = let (y, p, a → ea) = λX(w) in (xy, op, a → day + oea) Leibniz/shuffle rule: λX(1) = (1, 1, a → 0) λX(x, o, a → da)w = let (y, p, a → ea) = λX(w) in (xy, op, a → day + xea)

slide-19
SLIDE 19

Another coherence condition (1)

TSF Tλ2

✲ TFS

λ1S

✲ FSTS FSλ0 ✲ FSST

STF λ0F

Sλ1

✲ SFST λ2ST ✲ FSST FµST✲ FST

FµST

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.

slide-20
SLIDE 20

Another coherence condition (1)

TSF Tλ2

✲ TFS

λ1S

✲ FSTS FSλ0 ✲ FSST

STF λ0F

Sλ1

✲ SFST λ2ST ✲ FSST FµST✲ FST

FµST

Theorem

. . . ˆ λ : STF → FST, given by STF Sλ1

✲ SFST λ2ST ✲ FSST FµST ✲ FST

is a distributive law of the composite monad ST over F iff the coherence condition holds. (again works for copointed)

slide-21
SLIDE 21

Two-step determinization: general

X ηT

X ✲ TX

ηS

TX✲ STX

− ✲ νF FSTX δ

F−

✲ ✛

ˆ δ

δ

FνF ∆

δ♯ and ˆ δ can now be expressed in terms of the various distributive laws and δ: δ♯ = FµST

X

  • λ1

STX ◦ Tδ

ˆ δ = FµS

TX ◦ λ2 STX ◦ Sδ♯

δ♯ can also be obtained, equivalently, in terms of the distributive law ˆ λ of ST over F.

slide-22
SLIDE 22

Future work (maybe almost trivial?)

One possibly fascinating question is the following: can you use a similar generalization to the one given in this paper for distributive laws between monads into composite monads, so as to give a more general version of Cheng’s result in the original setting?