Incrementality as FunctorModeling 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: CategoricalGrammars
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 ofcharacters (an alphabet) or words (a vocabulary).
We have different classes of grammars, the basic trade-off beingcomplexity 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 orderingReplace 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 )
pl · p ≤ 1
p · pr ≤ 1
Pregroups (P, ·, 1,≤,−l ,−r )
pl · p ≤ 1 ≤ p · pl
p · pr ≤ 1 ≤ pr · 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 : nouns : declarative statement (sentence)j : infinitive of the verbσ : glueing type
Words in a vocabulary map can be assigned to parts of speech:
John likes Maryn (nr snl) 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 typesis ≤ the sentence type (s)
John likes Maryn (nr snl) n
nnr snln ≤ nnr 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.
pl ⊗ p → 1p ⊗ pr → 1
n ⊗ nr ⊗ s ⊗ nl ⊗ n→ s
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 8 / 34
Syntax Trees and Pregroup Reductions are String Diagrams
Complex houses students
n n
s
nl nr
Complex houses students
dot dot dot
dot
dot
s
n v ′
v n
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, anddom, cod : Σ1 → Σ?
0 are pairs of functions called domain and codomain.
Definition
Free monoidal categories are the objects in the image of the free functorfrom 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 ⊆
∐u,t∈Σ?
0CΣ(u, t)× CΣ(u, t) between parallel
arrows of the associated free monoidal category.
Definition
MonPres is the category of monoidal presentations and monoidalpresentation homomorphisms (monoidal signature homomorphisms thatcommute 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 finitevocabulary and (Σ,R) is a finite presentation with V ⊆ Σ0 and s ∈ Σ?
0.
Monoidal grammars form a subcategory of (V ∪ {s})∗/MonPres
(V ∪ {s})∗
(Σ0, Σ1, dom, cod ,R)
ff
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 andsentence token in the presentation P
Morphisms are presentation homomorphisms (functors in thegenerated categories) h : P → P ′ such that:
P
(V ∪ {s})∗ P ′
hf
f ′
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 14 / 34
Example: Pregroup Grammars
V = {w1,w2,w3, ...}Σ0 = V ∪ {s, n, j , ...} ∪ {sr , nr , j r , ...} ∪ {s l , nl , j l , ...}Σ1 =
{w1 → n, ...} ∪ {cupn : nl ⊗ n→ 1, ...} ∪ {capn : 1→ n ⊗ nl , ...} ∪ ...
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 thegenerated category of (V ,Σ,R, s) of the form w1 ⊗ w2 ⊗ ...⊗ wn → o
Definition
A parsing is a parse state w1 ⊗ w2 ⊗ ...⊗ wn → s
Definition
The language of a monoidal grammar is the set of all w1 ⊗ w2 ⊗ ...⊗ wn
that have at least one parsing.
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 16 / 34
Incremental Monoidal Grammar
Incremental MonoidalGrammar
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 17 / 34
Speech
Monoidal grammars operate on a fixed string of words. In speech, wordsare 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 w1 ⊗ w2 ⊗ ...⊗ wn → o represents the syntacticunderstanding of w1 ⊗ w2 ⊗ ...⊗ wn
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 newword w ∈ V defines an endofunctor over C :
Ww : (f ,C )→ (f ,C )
Ww (o) = o ⊗ w
Ww (a) = a⊗ idw
Hence, we get an action of the free monoid V ? on the category ofendofunctors.
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 20 / 34
New Word = New Parse States
Ww (a) = a⊗ idw is not enough. Ideally we can capture all of the waysunderstanding 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⊗ idw
Ww (a) = a⊗ idw
W ∗w (a) = {a′ ◦Ww (a) | a′ ∈ Ar(C ), dom(a′) = (cod(a)⊗ 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 asAutomata 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 deterministicautomaton 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 ofparse states that factor into a⊗ idw?
W ∗ : Ar(C )× V → P(Ar(C ))
W ∗ looks like a nondeterministic automata transition function! Can weformalize 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 dynamicalsystems
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 , {q0, q1, q2}) where f is defined below is a coalgebra of F :
q0 q1 q2
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 27 / 34
Coalgebra: Automata
Deterministic automata are coalgebras of FX = B× XV
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 rephraseour informal statement:
We can define a functor, IP , from the category of monoidal grammars tocoalgebras of B× P(Ar(C ))V
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 29 / 34
Incremental Functor
The functor IP :
Objects: Monoidal grammars are mapped to automata where thetransition function is defined by W ∗
Morphisms: Functors between monoidal grammars are mapped tocoalgebra homomorphisms
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 30 / 34
Bisimulation
A bisimulation between automata is a relation that describes how eachautomata can simulate the other. Bisimulations correspond to coalgebrahomomorphisms, so we can state the following:
If two monoidal grammar categories have functors between them, then thecorresponding automata are bisimulatable
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 31 / 34
Future Work
Future Work
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 32 / 34
Probabilistic Incremental Functor
A “weighted monoidal grammar” is a monoidal grammar equippedwith a functor to RThere is a functor between the category of weighted monoidalgrammars and coalgebras of the Set endofunctor R× V(X )V , whereV is the valuation monad
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 33 / 34
Incremental Semantics
Functor from syntax to semantics (e.g. vector spaces, booleans)
Apply semantics to parse states to study the evolution of semanticsover time
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 34 / 34
Steve Awodey.Category Theory.Ebsco Publishing, May 2006.
Antonin Delpeuch and Jamie Vicary.Normalization for planar string diagrams and a quadratic equivalencealgorithm.arXiv:1804.07832 [cs], April 2018.
Andre Joyal and Ross Street.Planar diagrams and tensor algebra.Unpublished manuscript, available from Ross Street’s website, 1988.
Andre Joyal and Ross Street.The geometry of tensor calculus, I.Advances in Mathematics, 88(1):55–112, July 1991.
A Markov.On certain insoluble problems concerning matrices.In Doklady Akad. Nauk SSSR, volume 57, pages 539–542, 1947.
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 34 / 34
R Oehrle.A parsing algorithm for pregroup grammars.Proceedings of Categorial Grammars 2004, pages 59–75, January2004.
Matthew Purver, Ronnie Cann, and Ruth Kempson.Grammars as Parsers: Meeting the Dialogue Challenge.Research on Language and Computation, 4(2):289–326, October 2006.
Emil L. Post.Recursive Unsolvability of a problem of Thue.Journal of Symbolic Logic, 12(1):1–11, March 1947.
James F. Power.Thue’s 1914 paper: A translation.arXiv:1308.5858 [cs], August 2013.
Anne Preller.Linear Processing with Pregroups.Studia Logica: An International Journal for Symbolic Logic,87(2/3):171–197, 2007.
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 34 / 34
Alexandra Silva, Filippo Bonchi, Marcello Bonsangue, and Jan Rutten.
Generalizing determinization from automata to coalgebras.Logical Methods in Computer Science, 9(1):9, March 2013.
P. Selinger.A Survey of Graphical Languages for Monoidal Categories.New Structures for Physics, pages 289–355, 2010.
Axel Thue.
Probleme Uber Veranderungen von Zeichenreihen Nach GegebenenRegeln.na, 1914.
Shiebler, Toumi (University of Oxford) Incrementality as Functor October 2019 34 / 34