Incrementality as Functor Modeling Incremental Processes with Monoidal Categories Dan Shiebler Alexis Toumi University of Oxford Category Theory Octoberfest, October 2019 Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 1 / 34
Background: Categorical Grammars Background: Categorical Grammars Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 2 / 34
Parsing Sentences with Formal Grammars Q: What is a grammatical sentence? A: Specify a grammar: i.e. a subset L ⊆ Σ ⋆ , where Σ is a finite set of characters (an alphabet) or words (a vocabulary). We have different classes of grammars, the basic trade-off being complexity vs expressivity . Example Chomsky hierarchy: 1 recursively enumerable (Turing machines) 2 context-sensitive (linear-bounded automaton) 3 context-free (push-down automaton) 4 regular (finite-state automaton) Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 3 / 34
Pregroups/Protogroups as Algebraic Structures Monoid Closure, Associativity, Identity Group Closure, Associativity, Identity, Invertibility Pregroups and Protogroup Sort of “in-between” Apply a partial ordering Replace invertibility with a left/right adjoint Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 4 / 34
Pregroups/Protogroups as Algebraic Structures Protogroups ( P , · , 1 , ≤ , − l , − r ) p l · p ≤ 1 p · p r ≤ 1 Pregroups ( P , · , 1 , ≤ , − l , − r ) p l · p ≤ 1 ≤ p · p l p · p r ≤ 1 ≤ p r · p Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 5 / 34
Pregroups/Protogroups for Language Parts of speech (types) are elements in the pregroup/protogroup: n : noun s : declarative statement (sentence) j : infinitive of the verb σ : glueing type Words in a vocabulary map can be assigned to parts of speech: John likes Mary ( n r sn l ) n n Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 6 / 34
Pregroups/Protogroups for Language We call a string of words grammatical if the corresponding string of types is ≤ the sentence type ( s ) John likes Mary ( n r sn l ) n n nn r sn l n ≤ nn r s ≤ s Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 7 / 34
Pregroups/Protogroups as Monoidal Categories Types are objects Strings of types are tensor products of objects Arrows s → t are proofs that s ≤ t in the free pregroup. p l ⊗ p → 1 p ⊗ p r → 1 n ⊗ n r ⊗ s ⊗ n l ⊗ n → s Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 8 / 34
Syntax Trees and Pregroup Reductions are String Diagrams Complex dot s houses students v ′ n n n r n n l dot v n s dot dot dot Complex houses students Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 9 / 34
Monoidal Grammars Monoidal Grammars Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 10 / 34
Monoidal Signatures Definition A Monoidal Signature is a tuple Σ = (Σ 0 , Σ 1 , dom , cod ) where Σ 0 and Σ 1 are sets of generating objects and arrows respectively, and dom , cod : Σ 1 → Σ ⋆ 0 are pairs of functions called domain and codomain . Definition Free monoidal categories are the objects in the image of the free functor from MonSig to MonCat Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 11 / 34
Monoidal Presentations Definition A presentation for a monoidal category is given by a monoidal signature Σ and a set of relations R ⊆ � 0 C Σ ( u , t ) × C Σ ( u , t ) between parallel u , t ∈ Σ ⋆ arrows of the associated free monoidal category. Definition MonPres is the category of monoidal presentations and monoidal presentation homomorphisms (monoidal signature homomorphisms that commute nicely with the relations in R ) Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 12 / 34
Monoidal Grammar Definition A monoidal grammar is a tuple G = ( V , Σ , R , s ) where V is a finite vocabulary and (Σ , R ) is a finite presentation with V ⊆ Σ 0 and s ∈ Σ ⋆ 0 . Monoidal grammars form a subcategory of ( V ∪ { s } ) ∗ / MonPres ( V ∪ { s } ) ∗ f (Σ 0 , Σ 1 , dom , cod , R ) Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 13 / 34
Monoidal Grammar Objects are pairs ( f , P ) where f picks out the word objects and sentence token in the presentation P Morphisms are presentation homomorphisms (functors in the generated categories) h : P → P ′ such that: P h f f ′ ( V ∪ { s } ) ∗ P ′ Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 14 / 34
Example: Pregroup Grammars V = { w 1 , w 2 , w 3 , ... } Σ 0 = V ∪ { s , n , j , ... } ∪ { s r , n r , j r , ... } ∪ { s l , n l , j l , ... } Σ 1 = { w 1 → n , ... } ∪ { cup n : n l ⊗ n → 1 , ... } ∪ { cap n : 1 → n ⊗ n l , ... } ∪ ... R = Snake equations Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 15 / 34
Parse States and Parsings Definition A parse state for the monoidal grammar ( V , Σ , R , s ) is an arrow in the generated category of ( V , Σ , R , s ) of the form w 1 ⊗ w 2 ⊗ ... ⊗ w n → o Definition A parsing is a parse state w 1 ⊗ w 2 ⊗ ... ⊗ w n → s Definition The language of a monoidal grammar is the set of all w 1 ⊗ w 2 ⊗ ... ⊗ w n that have at least one parsing. Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 16 / 34
Incremental Monoidal Grammar Incremental Monoidal Grammar Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 17 / 34
Speech Monoidal grammars operate on a fixed string of words. In speech, words are introduced one at a time. How can we reconcile this? Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 18 / 34
Parse States are Understanding A parse state w 1 ⊗ w 2 ⊗ ... ⊗ w n → o represents the syntactic understanding of w 1 ⊗ w 2 ⊗ ... ⊗ w n A new word w should evolve this understanding Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 19 / 34
New Word = New Parse States Given ( f , C ) generated by the monoidal grammar G = ( V , Σ , R , s ), a new word w ∈ V defines an endofunctor over C : W w : ( f , C ) → ( f , C ) W w ( o ) = o ⊗ w W w ( a ) = a ⊗ id w Hence, we get an action of the free monoid V ⋆ on the category of endofunctors. Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 20 / 34
New Word = New Parse States W w ( a ) = a ⊗ id w is not enough. Ideally we can capture all of the ways understanding can evolve in the face of a new word. Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 21 / 34
New Word = New Parse States W ∗ w maps the parse state a to all of parse states that factor into a ⊗ id w W w ( a ) = a ⊗ id w w ( a ) = { a ′ ◦ W w ( a ) | a ′ ∈ Ar ( C ) , dom ( a ′ ) = ( cod ( a ) ⊗ w ) } W ∗ W ∗ w captures how the parsing system evolves when a new word is introduced. Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 22 / 34
Monoidal Grammars as Automata Coalgebraically Monoidal Grammars as Automata Coalgebraically Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 23 / 34
Transition Function Over the vocabulary V , set of states X , and start state ””, a deterministic automaton is: ∆ : X × V → X accept : X → B A nondeterministic automaton is: ∆ : X × V → P ( X ) accept : X → B Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 24 / 34
W ∗ is a Transition Function Remember W ∗ , which maps the word w and the parse state a to all of parse states that factor into a ⊗ id w ? W ∗ : Ar ( C ) × V → P ( Ar ( C )) W ∗ looks like a nondeterministic automata transition function! Can we formalize this? Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 25 / 34
Coalgebra A coalgebra of a functor F is a pair ( f , X ) where f : X → FX . Coalgebras over Set endofunctors can model an array of dynamical systems Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 26 / 34
Coalgebra: Example Say we define: F : Set → Set FX = X Then the pair ( f , { q 0 , q 1 , q 2 } ) where f is defined below is a coalgebra of F : q 0 q 1 q 2 Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 27 / 34
Coalgebra: Automata Deterministic automata are coalgebras of FX = B × X V Non-deterministic automata are coalgebras of FX = B × P ( X ) V Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 28 / 34
Incremental Functor W ∗ is uniquely defined by a monoidal grammar, so we can now rephrase our informal statement: We can define a functor, I P , from the category of monoidal grammars to coalgebras of B × P ( Ar ( C )) V Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 29 / 34
Recommend
More recommend