Computing Critical Pairs in 2-Dimensional Rewriting Systems

Rewriting systems on words are very useful in the study of monoids. In good cases, they give finite presentations of the monoids, allowing their manipulation by a computer. Even better, when the presentation is confluent and terminating, they provide…

Authors: Samuel Mimram (LIST)

Computing Critical P airs in 2-Dimensional Rewriting Systems Sam uel Mimram ∗ Octob er 30, 2018 Abstract Rewriting systems on words are v ery useful in the study of monoids. In goo d cases, they giv e finite presentatio ns of the monoids, allowing their manipulation by a computer. Even b etter, when the presentatio n is confluent and terminating, they provide one with a n otion of canonical representa tive for th e elements of the p resen ted monoid. P olygraphs are a higher- dimensional generalization of t his notion of presentation, from the setting of monoids to th e muc h more general setting of n -categories. Here, w e are interested in pro ving confluence for p olygraphs p resen ting 2-categories, whic h can b e seen as a generalization of term rewriting systems. F or this pu rpose, we p ropose an adaptation of the usual algo rithm for computing critical p airs. Interestingly , this framew ork is much richer than term rewriting systems and requires the elab oration of a new theoretical framew ork for representing critical pairs, based on contexts in compact 2-categories. 1 T erm rewriting systems hav e prov en very useful to reaso n ab out terms modulo equa tions. In some cases, the equa tions c a n be oriented and co mpleted in a w ay giving r ise to a conv er ging (i.e. confluent and terminating) rewriting system, thus providing a notion of ca nonical represen- tative of equiv alence cla sses of terms. Usually , terms a re freely gener ated by a s ignatu r e (Σ n ) n ∈ N , which consists of a family of sets Σ n of generators of a rit y n , and one considers e quational the ories on such a sig nature, which a re formaliz ed by sets of pairs of ter ms ca lled e quations . F or example, the equationa l theory of mono ids contains t wo genera to rs m and e , whose arities are resp ectively 2 and 0, a nd thre e equations m ( m ( x, y ) , z ) = m ( x, m ( y , z )) m ( e, x ) = x and m ( x, e ) = x These equations, when or ien ted from left to righ t, form a rewriting system whic h is converging. The termination o f this system can b e shown by g iv ing a n interpretation of the terms in a well-founded po set, such that the rewriting rules are strictly decr easing. Since the system is terminating, the confluence ca n be deduced from the lo cal confluence, which can itself b e shown by verifying that the five critica l pair s m ( m ( m ( x, y ) , z ) , t ) m ( m ( e, x ) , y ) m ( m ( x, e ) , y ) m ( m ( x, y ) , e ) m ( e, e ) are joinable a nd these cr itical pairs can b e computed using a unification a lg orithm. A more detailed presentation of term rewriting systems along with the classic techniques to prov e their conv er g ence can b e found in [ 1 ]. As a particular ca se, when the genera tors o f an equational theory are o f arity one, the categor y of terms mo dulo the congruence g enerated by the equations is a mo noid, with addition giv en by comp osition and neutral elemen t b eing the identit y . A pr esent ation of a monoid ( M , × , 1) is such an equational theory , which is genera ting a monoid iso morphic to M . F or example the ∗ CEA, LIST, Poin t Courrier 94, 91191 Gif-sur-Yvette, F rance. 1 This work was started while I was in the PPS team (CNRS – Univ. P ari s Diderot) and has been supp orted by the C HOCO (“Curry How ard p our la Concurrence”, ANR-07-BLAN- 0324 ) F r enc h ANR pro ject. 1 monoid N / 2 N is pr esen ted by the equatio nal theory with only one gener ator a , of a r it y one, and the equation a ( a ( x )) = x . Pres en tatio ns o f monoids are particular ly use ful since they can provide finite description of monoids which may b e infinite, thus allowing their ma nipula tion with a computer. More gener ally , with gener a tors of any arity , equational theor ies give rise to presentations of Lawv er e theories [ 9 ], which ar e cartes ia n categor ies whose o b jects are the na tural in tegers a nd such that pro duct is given on ob jects by addition: a s ignature namely g enerates s uc h a categ ory , whose mo r phisms f : m → n a re n -uples of terms with m free v ariables , co mpositio n being given by substitution. T erm rewriting systems hav e b een generalized by p olygr aphs , in or de r to provide a formal framework in which one can g iv e presentations of any (strict) n -catego r y . W e are interested here in a dapting the classical technique to study c onfluence of 3-p olygraphs, which give rise to presentations of 2-catego ries, by computing their critical pairs. These p olygraphs can be seen as term rewr iting systems improved on the fo llo wing p oints: – the v ar ia bles o f terms a re s imply typed (this can be thought as ge ne r alizing from a Lawv er e theory of terms to any car tesian catego ry of terms ), – v ariables in terms ca nnot neces sarily b e duplicated, eras ed or swapped (the categories of terms are not neces sarily c a rtesian but only monoida l), – and the terms ca n have mult iple outputs as well as multiple inputs. Many examples of pre sen ta tions o f monoidal categ ories whe r e studied by Lafont [ 8 ], Guiraud [ 4 , 3 ] and the a utho r [ 12 , 1 4 ]. A fundament al example is the 3-p olygra ph S , presentin g the monoidal category Bij (the c a tegory of finite or dinals and bijections). This p olygraph has one generator for o b jects 1, one generator for morphisms γ : 2 → 2 (where 2 is a notation for 1 ⊗ 1) and t wo equations ( γ ⊗ 1) ◦ (1 ⊗ γ ) ◦ ( γ ⊗ 1) = (1 ⊗ γ ) ◦ ( γ ⊗ 1) ◦ (1 ⊗ γ ) and γ ◦ γ = 1 ⊗ 1 (1) where the morphism 1 is a short notation for id 1 . That this p olygraph is a presentation of the category Bij means that this catego ry is isomorphic to the free monoida l categor y cont aining an ob ject 1 and a generator γ , quotiented by the smalles t congr uence genera ted b y the equa tions ( 1 ). This result c a n b e see n as a generaliza tion of the presentation of the symmetric groups by transp o- sitions. These equatio ns can b e b etter understo o d with the gra phical notation pr o vided by string diagr ams , which is a diagrammatic nota tio n for mor phisms in mo noidal categories , introduced formally in [ 6 ]. The mor phism γ should b e thoug h t as a device with tw o inputs and tw o outputs of type 1, and the tw o equa tions ( 1 ) can thus b e r epresent ed graphica lly by γ γ γ = γ γ γ and γ γ = (2) In this notation, wires represe n t identities (on the ob ject 1), horizontal juxtapo sition o f diag rams corres p onds to tensoring, and v er tical linking of diagr ams corr esponds to comp osition of mor- phisms. Mor eo ver, these diagrams sho uld be cons idered mo dulo planar contin uous de fo rmations, so that the axioms of mono idal c a tegories are verified. These diagra ms are conceptually impor tan t bec ause they allow us to see morphisms in monoidal categor ies either as alg ebraic ob jects or as geometric ob jects (some so rt o f planar graphs). If we orient b oth equations from left to right, we get a rew r iting system which can be shown to b e convergen t. It ha s the three following critical 2 pairs [ 8 ]: γ γ γ γ γ γ γ γ γ γ γ (3) Moreov er, for every morphism φ : 1 ⊗ m → 1 ⊗ n , the morphism on the left of ( 4 ) . . . γ γ γ φ γ γ . . . γ γ γ γ γ γ γ γ γ γ (4) can be rewritten in tw o different ways, thus giving rise to an infinite num ber o f c r itical pa ir s for the rewriting system. This phenomenon was first observed by Lafont [ 8 ] and la ter o n studied by Guiraud a nd Ma lbos [ 5 ]. In teresting ly , we can nev ertheless consider that there is a finite num ber of critical pa ir s if we a llo w o urselves to cons ider the “diagram” on the cen ter of ( 4 ) as a cr itical pair. Of cours e, this diagram do es not ma ke sense at firs t. How e ver, we ca n give a precise mea ning to it if we embed our ter ms in a la rger catego ry , which is compact: in such a categ ory every ob ject has a dual, which corr e sponds gr a phically to having the ability to bend wires (see the figure o n the right). This obser v a tio n was the starting p oin t of this paper which is devoted to for malizing these intuitions in order to pro pose an algorithm for computing critical pairs in p olygra phs. W e be lie v e that this is a ma jor area of highe r -dimensional algebra where computer scientists should step in: typical presentations o f catego r ies can give r ise to a very lar ge n um be r o f critical pairs and having a utomated to ols to compute them seems to b e necessar y in order to push further the s tudy of those systems. The present pa per constitutes a first step in this dir ection, by defining the str uctures necessa ry to manipulate algorithmically the morphisms in categories gener a ted by po lygraphs and b y prop osing a n algorithm to compute the critical pairs in po lygraphic rewriting systems. Conv ersely , algebra provides strong indications abo ut technical choices that should be made in order to g eneralize rewr iting theory in higher dimensions. W e hav e done our p ossible to provide an ov erview of the theoretical to ols used here, as well as in tuitions ab out them. A preliminary detailed version of this w ork is av ailable in [ 13 ]. W e b egin by recalling the definition o f p olygr aphs, describ e the categories they generate, and formulate the unification problem in this framework us ing the notion o f context in a 2-categ o ry . Then, we sho w that 2-ca tegories can b e fully and faithfully embedded in to the free compact 2-catego ry they ge ne r ate, which allows us to describ e a unificatio n alg o rithm for p olygraphic rewriting sys tems. 1 Presen tations of 2-categories Because of space limitatio ns, we hav e to omit the basic definitions in category theory a nd refer the reader to MacLane’s reference b oo k [ 11 ]. W e only recall that a 2-c ate gory is a generalization in 3 dimension 2 o f the concept o f category . It consists es sen tia lly of a class of 0 - c el ls A , a class of 1 - c el ls f : A → B (with 0- cells A and B as source and target) and a class of 2 -c el ls α : f ⇒ g : A → B (with parallel 1-cells f : A → B and g : A → B as source and target), together with a vertic al c omp osition , which to every pair of 2-cells α : f ⇒ g and β : g ⇒ h a sso ciates a 2-ce ll β ◦ α : f ⇒ h , and a horizontal c omp osition , which to every pair of 2-cells α : f ⇒ g and β : h ⇒ i asso ciates a 2-cell α ⊗ β : ( f ⊗ h ) ⇒ ( g ⊗ i ), such that v ertical and horiz o n ta l comp osition ar e ass ocia tiv e, admit neutral elements (the identities) and the exchange law is satisfied: for every four 2 -cells α : f ⇒ f ′ : A → B , α ′ : f ′ ⇒ f ′′ : A → B , β : g ⇒ g ′ : B → C , β ′ : g ′ ⇒ g ′′ : B → C the following equality holds ( α ′ ◦ α ) ⊗ ( β ′ ◦ β ) = ( α ′ ⊗ β ′ ) ◦ ( α ⊗ β ) (5) as well a s a nullary version of this law: id A ⊗ B = id A ⊗ id B for every ob jects A and B . In a 2-catego ry , tw o n - cells ar e p ar al lel w hen they have the sa me source and the same ta r get. W e a lso recall that tw o 0 -cells A and B of a 2-ca tegory C , induce a category C ( A, B ), called hom-c ate gory , whose ob jects are the 1-cells f : A → B of C and who se morphisms α : f ⇒ g ar e 2- cells of C , comp osition b e ing g iv e n by vertical co mpositio n. A (strict) monoidal c ate gory is a 2 - category with exactly one 0- cell. Polygraphs are algebr a ic structures which were in tro duced in their 2-dimensional version by Street [ 16 ] under the na me c omputads , gener alized to higher dimensions by Pow er [ 15 ], a nd inde- pendently rediscovered by Burroni [ 2 ]. W e are specific a lly interested in 3- p olygr aphs, which give rise to pr e s en ta tio ns of 2 -categories , and briefly r ecall their definition here. This definition is a bit technical but conceptually clea r: it consists of sets o f 0-, 1-, 2- generators for “terms” , ea c h 2-genera tor having a list of 1-gener ators as source and as target, each 1-gener a tor having itself a 0 -generator as source a nd as target, together with a set of eq ua tions which are pairs of terms (generated by the 2-genera tors). Suppo se that we are given a set E 0 of 0-gener ators , such a set will b e called a 0-p olygr aph . W e wr ite E ∗ 0 = E 0 and i 0 : E 0 → E ∗ 0 the identit y function. A 1-p olygraph on these generator s is a graph, that is a diagram E ∗ 0 E 1 s 0 o o t 0 o o in Set , with E ∗ 0 as vertices, the elements of E 1 being called 1-gener ators . W e can constr uct a fre e category o n this g raph: its set E ∗ 1 of mor phisms is the set of pa ths in the graph (iden tities are the empty pa ths), the s ource s ∗ 0 ( f ) (resp. targe t t ∗ 0 ( f )) of a morphism f ∈ E ∗ 1 being the so urce (resp. tar get) o f the pa th. If we write i 1 : E 1 → E ∗ 1 for the injectio n of the 1 -generators in to morphisms of this categor y , which to every 1-genera tor asso ciates the corr espo nding path of leng th one, we thus g e t a diag ram E 0 i 0   E 1 s 0 ~ ~ | | | | | | | | t 0 ~ ~ | | | | | | | | i 1   E ∗ 0 E ∗ 1 s ∗ 0 o o t ∗ 0 o o (6) in Set , which is commutativ e in the sens e that s ∗ 0 ◦ i 1 = s 0 and t ∗ 0 ◦ i 1 = t 0 . A 2-p olygr aph on this 1-p olygraph c o nsists of a diag ram E 0 i 0   E 1 s 0 ~ ~ | | | | | | | | t 0 ~ ~ | | | | | | | | i 1   E 2 s 1 ~ ~ | | | | | | | | t 1 ~ ~ | | | | | | | | E ∗ 0 E ∗ 1 s ∗ 0 o o t ∗ 0 o o (7) in Set , such that s ∗ 0 ◦ s 1 = s ∗ 0 ◦ t 1 and t ∗ 0 ◦ s 1 = t ∗ 0 ◦ t 1 . The element s of E 2 are called 2-gener ators . Again we can generate a fr ee 2-categor y on this data, who se underlying catego ry is the categor y 4 generated in ( 6 ) and which has the 2 -generators a s morphisms. If w e write E ∗ 2 for its set of morphisms and i 2 : E 2 → E ∗ 2 for the injection of the 2 -generator s in to mor phisms, w e thus get a diagram E 0 i 0   E 1 s 0 ~ ~ | | | | | | | | t 0 ~ ~ | | | | | | | | i 1   E 2 s 1 ~ ~ | | | | | | | | t 1 ~ ~ | | | | | | | | i 2   E ∗ 0 E ∗ 1 s ∗ 0 o o t ∗ 0 o o E ∗ 2 s ∗ 1 o o t ∗ 1 o o (8) W e can now fo r m ula te the de finitio n of 3-p olygr aphs as follows. Definition 1 A 3-p olygr aph consists of a diagram E 0 i 0   E 1 s 0 ~ ~ | | | | | | | | t 0 ~ ~ | | | | | | | | i 1   E 2 s 1 ~ ~ | | | | | | | | t 1 ~ ~ | | | | | | | | i 2   E 3 s 2 ~ ~ | | | | | | | | t 2 ~ ~ | | | | | | | | E ∗ 0 E ∗ 1 s ∗ 0 o o t ∗ 0 o o E ∗ 2 s ∗ 1 o o t ∗ 1 o o (9) (where E ∗ i , s ∗ i and t ∗ i are freely g enerated as previous ly explained), suc h that s ∗ i ◦ s i +1 = s ∗ i ◦ t i +1 and t ∗ i ◦ s i +1 = t ∗ i ◦ t i +1 for i = 0 and i = 1, together w ith a structur e of 2 - category o n the 2-graph E ∗ 0 E ∗ 1 s ∗ 0 o o t ∗ 0 o o E ∗ 2 s ∗ 1 o o t ∗ 1 o o Again, a 3 - polyg raph freely g e nerates a 3 -category C who se underlying 2- category is the underly ing 2-catego ry of the p olygr a ph and whose 3-ce lls ar e gener ated by the 3-gener ators of the p olygra ph. A quotient 2-c a tegory ˜ C can be constructed from this 2- category: it is defined a s the underlying 2-catego ry of C q uotien ted b y the co ngruence iden tifying tw o 2- cells whenever there e x ists a 3-cell betw een them in C . A 3-p olygraph P pr esents a 2-categ ory D when D is isomor phic to the 2-ca- tegory ˜ C induced b y the poly graph P . In this sense, the underlying 2-p olygraph of a 3-p olygr aph is a signatur e g enerating ter ms which are to b e consider ed mo dulo the e quations describ ed by the 3-gener a tors; these equations r ∈ E 3 being oriented, they will b e called r ewriting rules , the source s 2 ( r ) (resp. the target t 2 ( r )) b eing the left memb er (res p. right memb er ) of the r ule. A po lygraph is finite when all the sets E i are; in the following, we o nly co nsider such p olygraphs. A morphism of p olygr aphs F = ( F 0 , F 1 , F 2 , F 3 ) b et ween tw o 3-p olygraphs P and Q c onsists of functions F i : E P i → E Q i , such that the o bvious diagr ams c o mm ute (for exa mple, for ev ery i , s Q i ◦ F i +1 = F ∗ i ◦ s P i , wher e F ∗ i : E P i ∗ → E Q i ∗ is the monoid morphism induced by F i ). W e write n - P o l for the c ategory of n -p olygr aphs (t his co nstruction can b e ca rried on to any dimension n ∈ N but we will only consider cases with n 6 3). These categ ories have many nice pr o perties , amongst which b eing coc omplete. The free n -catego ry g enerated b y an n -p olygr aph P is denoted C n ( P ). Given a n integer k 6 n , we write U k : n - P o l → k - Pol for the forg etful functor which simply forgets ab out the sets of generato rs of dimension higher than k . This functor admits a left ad- joint F n : k - P ol → n - Pol whic h adds empty sets o f generators of dimension higher than k . W e sometimes leav e implicit the inclusion of k - P ol in to n - P ol induce d by F n . Example 1 The theory of symmetries mentioned in the introduction is the p olygraph S who s e generator s are E 0 = {∗} E 1 = { 1 : ∗ → ∗} E 2 = { γ : 1 ⊗ 1 ⇒ 1 ⊗ 1 } E 3 = { y : ( γ ⊗ 1) ◦ (1 ⊗ γ ) ◦ ( γ ⊗ 1) ⇛ (1 ⊗ γ ) ◦ ( γ ⊗ 1) ◦ (1 ⊗ γ ) , s : γ ◦ γ ⇛ 1 ⊗ 1 } 5 Example 2 The theory of monoids is the po lygraph M defined by E 0 = {∗ } E 1 = { 1 : ∗ → ∗} E 2 = { µ : 1 ⊗ 1 ⇒ 1 , η : ∗ ⇒ 1 } E 3 = { a : µ ◦ ( µ ⊗ 1) ⇛ µ ◦ (1 ⊗ µ ) , l : µ ◦ ( η ⊗ 1) ⇛ 1 , r : (1 ⊗ η ) → 1 } This po lygraph prese nts the a ugmen ted simplicial categ ory (the categor y of finite ordinals and non-decreas ing functions). 2 F ormal represen tation of free 2-categories The definition of 3-p olygraphs in volves the construction of free categ o ries and free 2-ca tegories, which are a bstractly defined in categ ory theory by universal constructions. Here, we need a more concrete r epresentation of these mathematical o b jects. As alr eady men tio ned, the free category ( 6 ) on a g raph is easy to describ e: its ob jects are the vertices of the gr aph a nd morphisms ar e paths of the graph with c ompositio n given by conca tenation. Howev er, describing the free 2-catego r y on a 2-p olygraph in an effectiv e wa y (which ca n b e implemen ted) is muc h less straightforw ard. Of course, following the definition given in Section 1 , one co uld des cribe the 2-cells of this 2 -category as formal vertical and horizontal comp ositions of 2 -generator s up to a c o ngruence imp osing asso- ciativity and a bs orption of units for b oth co mpositions and the exchange law ( 5 ). How e ver, given an o b ject A in a 2-categ ory C and tw o 2-cells α, β : id A ⇒ id A : A → A of this category , the equality α ⊗ β = β ⊗ α ca n b e deduced fr om the following sequence of eq ualities: α ⊗ β = (id A ◦ α ) ⊗ ( β ◦ id A ) = (id A ⊗ β ) ◦ ( α ⊗ id A ) = ( β ⊗ id A ) ◦ (id A ⊗ α ) = ( β ◦ id A ) ⊗ (id A ◦ α ) = β ⊗ α It requires inserting and r emo ving identities, and using the exchange law in b oth directions. So, it se e ms to be very hard to find a g eneric wa y to handle fo r mal c omposites of genera tors mo dulo the congruence described ab o ve. W e will ther efore define an alternative constr uctio n of these morphisms which do esn’t r equire such a quotienting. Consider the morphis m γ ◦ γ : (1 ⊗ 1) ⇒ (1 ⊗ 1) : ∗ → ∗ in the theory S o f symmetries (Example 1 ), depicted o n the left of ( 10 ): 1 ∗ 1 ∗ γ ∗ 1 ∗ 1 γ 1 ∗ 1 1 0 ∗ 0 1 1 ∗ 1 γ 0 ∗ 2 1 2 ∗ 3 1 3 γ 1 1 4 ∗ 4 1 5 (10) Graphically , in this morphism, the tw o 2-cells ar e γ , wires are typed by the 1- cell 1 and reg io ns o f the plane are typed by the 0-ce ll ∗ . Now, if we g iv e a different name to ea c h instanc e of a generator used in this mor phism, for e x ample by n um ber ing them as in the right o f ( 10 ), the morphism itself can b e describ ed as the 2- polyg raph P defined by E 0 = {∗ 0 , . . . , ∗ 4 } E 1 = { 1 0 : ∗ 1 → ∗ 0 , 1 1 : ∗ 0 → ∗ 2 , . . . , 1 5 : ∗ 4 → ∗ 2 } and E 2 = { γ 0 : 1 0 ⊗ 1 1 ⇒ 1 2 ⊗ 1 3 , γ 1 : 1 2 ⊗ 1 3 ⇒ 1 4 ⊗ 1 5 } together with a function ℓ whic h to every i -gener a tor of this p olygraph asso ciates a labe l, whic h is an i -gener ator of S , so that ℓ : P → S is a morphism of p olygra phs ( ℓ is defined by ℓ ( ∗ i ) = ∗ , ℓ (1 i ) = 1 and ℓ ( γ i ) = γ ). F ormulated in categor ical terms, ( P, ℓ ) is a n ob ject in the slice cate- gory 2- P ol ↓ U 2 ( S ). Of course, the naming of the instances o f the gener ators o ccurring in nets is arbitrar y , so w e ha ve to co nsider these lab eled p olygra phs up to bijections, whic h corres p ond to injectiv e rena ming of instances . No tice that not every such labe led po lygraph is the repr esen tation of a mo rphism: we ne e d an inductive co nstruction of those (it seems to b e difficult to give a dir e ct characterization of the suitable p olygraphs). 6 Based on these ideas, we describ e the categor y generated by a p olygr aph S as a category whose cells are polyg raphs labe le d by S . W e suppose fixed a sig nature 2-p olygraph S and write S i for U i ( S ). This is a g eneralization of the constructions of lab eled transition systems, and is reminisc en t of pasting schemes [ 15 ] and of pro of-nets, which is why we call them p olygr aphic nets (or nets for short). The categ ory of 0 -nets 0- Net S 0 on the 0-p olygraph S 0 is the full sub categor y of 0- P ol ↓ S 0 whose o b jects a r e 0-p olygra phs with exactly one 0-cell, lab eled by S 0 . Concretely , its ob jects are pairs ( n, A ), often written A n , where n is the name o f the instance (an integer for example) and A an element of E S 0 0 , called its lab el , and there is a morphism b etw een tw o ob jects whenever they hav e the same la bel (all those mo r phisms a re in vertible). The ca teg ory o f 1 -n ets 1- Net S 1 is the smallest catego ry who se ob jects are the 0 - nets A i , whose morphisms ( s f , f , t f ) : A i → B j are triples co nsisting o f a 1-p olygraph f lab eled b y S 1 (i.e. an ob ject in 1- P ol ↓ S 1 ) and tw o morphisms of la beled polyg raphs s f : A i → f and t f : B j → f , called sour c e and tar get , which are either a 1-p olygra ph f suc h that E f 0 = { A i , B j } and E f 1 contains o nly one 1-cell n ∈ N with A i as sour c e and B j as target (and the obvious injectio ns for s f and t f ), or A i = B j , f = A i and s f = t f = id A i (this is the iden tit y on A i ), or a comp osite f ⊗ g : A i → B j of t wo morphisms f : A i → C k and g : C k → B j . Here, the co mposite of tw o such morphisms is defined as the pushout of the diagr am f C k t f o o s g / / g , that is the disjoint union of the po lygraphs f and g q uotien ted by a rela tion identifying the 0-cell in C k in the tw o comp onents of the union. Example 3 If S is the p o lygraph of symmetries, the co mposite of the tw o morphisms f : ∗ 0 → ∗ 1 and g : ∗ 1 → ∗ 2 defined b y E f 0 = {∗ 0 , ∗ 1 } E f 1 = { 1 0 : ∗ 0 → ∗ 1 } E g 0 = {∗ 0 , ∗ 1 , ∗ 2 } E g 1 = { 1 1 : ∗ 1 → ∗ 0 , 1 0 : ∗ 0 → ∗ 2 } is the morphism h = f ⊗ g such that E h 0 = {∗ 0 , . . . , ∗ 3 } and E h 1 = { 1 0 : ∗ 0 → ∗ 1 , 1 1 : ∗ 1 → ∗ 3 , 1 2 : ∗ 3 → ∗ 2 } Graphically , ∗ 0 1 0 / / ∗ 1 ⊗ ∗ 1 1 1 / / ∗ 0 1 0 / / ∗ 2 = ∗ 0 1 0 / / ∗ 1 1 1 / / ∗ 3 1 2 / / ∗ 2 Since c ompositio n is defined by a pushout construction, it inv olves a renaming of some instances (it is the case in the example ab ov e) and this rena ming is a r bitrary . So, comp osition is not strictly asso ciative but only a sso ciativ e up to iso morphism of poly graphs. Therefore, what we hav e built is not precisely a categor y but only a bicategory: this is a w ell-known fact, this construction being a particular insta nce of the gener al construction of cospa n bicatego ries. W e can iterate this co nstruction one step further and define the tricatego ry (that is a 2-category whose com- po sitions are asso ciative up to isomorphism) of 2 -nets 2- Net S as the smalles t tric a tegory who se 0-cells are 0 -nets A i , whose 1 -cells f : A i → B j contain 1 -nets, and whose 2 -cells α : f ⇒ g are triples ( s α , α, t α ), consis ting of a 2- polyg raph α lab e led by S and tw o morphisms o f lab eled po lygraphs s α : f → α a nd t α : g → α , containing all the 2 -polyg raphs with one 2- g enerator n ∈ N whose source f = s α 1 ( n ) and target g = t α 1 ( n ) are 1-nets which a r e “dis jo in t” in the sense they only have their own source and tar get as common gener ators, with the obvious injections for s α and t α . Mo reov er, w e requires this tric ategory to contain ident ities and to be c lo sed under bo th vertical and horizontal c o mpositio ns, which are defined b y pushout co nstructions in a way similar to 1-nets. If we quotient this tricategory and iden tify cells which are isomorphic lab eled po lygraphs, we get a prop er 2-catego ry , that we still wr ite 2- Net S . Prop osition 2 The 2 -c ate gory 2 - Net S describ e d ab ove is e quivalent to the fr e e c ate gory gener ate d by the 2 -p olygr aph S . This construction has the adv antage to b e s imple to implement a nd manipulate: we have for example given the data needed to des c r ibe the mo rphism ( 10 ). 7 3 Critical pairs in p olygraphs In order to formalize the notion of critical pair for a p olygra ph, we need to formalize first the notion of context of a mo r phism in the 2-ca tegory C 2 ( S ) gener ated by a 2-p olygra ph S , w hich may b e thought as a 2-cell with multiple t ype d “ holes”. These co n tex ts have multiples “inputs” (one for ea c h ho le) and will therefo re o rganize int o a multicategory , which is a notio n generalizing categorie s in the sense tha t morphis ms f : ( A 1 , . . . , A n ) → A have one output o f type A , and a list of inputs o f type A i instead of o nly o ne input. Comp osition is also generalized in the sense that we comp ose such a morphism f with n morphis ms f i with A i as targ e t, wha t we write f ◦ ( f 1 , . . . , f n ). Multicategories should moreover have ident ities Id A : ( A ) → A and satisfy coher ence axio ms [ 10 ]. . . . f i X i g i . . . Suppo se that we ar e given a signature 2-p olygr aph S . Suppose mor eo ver that we are given a lis t of n pair s of pa rallel 1-cells ( f i , g i ) in the categor y generated by the 1-p olygraph U 1 ( S ). W e wr ite S [ X 1 : f 1 ⇒ g 1 , . . . , X n : f n ⇒ g n ], for the p olygraph obtained from S by adding X 1 , . . . , X n as 2-genera tors, with f i as the source a nd g i as the ta r get of X i (w e suppo s e that the X i were not already pres e n t in the 2-genera tors of S ). The X i should b e thought as typed v ar ia bles fo r 2-cells and we can easily define a notion of subst itution o f a v ar iable X i : f i ⇒ g i by a 2-cell α : f i ⇒ g i in a 2-cell of the 2 -category generated by S [ X 1 : f 1 ⇒ g 1 , . . . , X n : f n ⇒ g n ]. Given a signature S , we build a m ultica tegory K ( S ) whose ob jects a re pair s ( f , g ) of pa rallel 1-cells in the 2-ca tegory generated b y S and whose morphisms K : (( f 1 , g 1 ) , . . . , ( f n , g n )) → ( f , g ), called c ontexts , are the 2-cells α : f ⇒ g in the 2 - category which is generated by the po lygraph S [ X 1 : f 1 ⇒ g 1 , . . . , X n : f n ⇒ g n ], w hich are line ar in the sense that each of the v a riables X i app ears exactly once in the morphism α . Compositio n in this mult icategory is induced by the substitution o pera tion. This m ulticategory ca n be canonically e quipped with a structure o f sym- metric m ulticategory , which essentially mea ns that, for every p ermutation σ on n elements, the sets o f morphisms of type (( f 1 , g 1 ) , . . . , ( f n , g n )) → ( f , g ) is is omorphic to the set of morphis ms of t yp e (( f σ (1) , g σ (1) ) , . . . , ( f σ ( n ) , g σ ( n ) )) → ( f , g ) in a coherent wa y . Any 2-cell α : f ⇒ g in the 2-catego ry generated by S , c an b e seen as a nullary context of type () → ( f , g ) that we still write α . A c oncrete and implementable definition of the multicategory K ( S ) of contexts of S can b e given by adapting the construction of p olygr aphic nets g iv en in the previous sec tion. This cons tr uction enables us to reformulate usual no tio ns of rewriting theory in our fr amew ork as follows. W e s uppose fixed a r ewriting system given by a 3-p olygra ph R . W e write S = U 2 ( R ) for the underlying signature of R and C for the 2 - category it generates. Definition 3 A unifier of t w o 2-cells α 1 : f 1 ⇒ g 1 and α 2 : f 2 ⇒ g 2 in C is a pa ir o f cofina l unar y co n texts K 1 : (( f 1 , g 1 )) → ( f , g ) a nd K 2 : (( f 2 , g 2 )) → ( f , g ) such that K 1 ◦ ( α 1 ) = K 2 ◦ ( α 2 ). A unifier is a most gener al un ifier when it is – non-t r ivial : there exists no binar y co n text K : (( f 1 , g 1 ) , ( f 2 , g 2 )) → ( f , g ) which sa tisfies K 1 = K ◦ (Id ( f 1 ,g 1 ) , α 2 ) a nd K 2 = K ◦ ( α 1 , Id ( f 2 ,g 2 ) ). Informally , the morphisms α 1 and α 2 should not app ear in disjoint p ositions in the morphism K 1 ◦ ( α 1 ) = K 2 ◦ ( α 2 ). – minimal : for every unifier K ′ 1 , K ′ 2 of α 1 and α 2 , such tha t K 1 = K ′′ 1 ◦ K ′ 1 and K 2 = K ′′ 2 ◦ K ′ 2 , for some contexts K ′′ 1 and K ′′ 2 , the co n texts K ′′ 1 and K ′′ 2 should b e inv ertible. Remark 1 If w e write α = K 1 ◦ ( α 1 ) = K 2 ◦ ( α 2 ) and represent the 2-cells α 1 , α 2 and α b y 2-nets, the fact that α is a unifier of the mo rphisms means that there e xist tw o injectiv e morphisms o f lab eled po ly graphs i 1 : α 1 → α and i 2 : α 2 → α , and the non-trivia lit y condition means that there exists at lea st o ne 2 -generator which is b oth in the image of i 1 and i 2 . 8 F or example, the last tw o morphisms of ( 3 ) ar e b oth unifiers of the left members of the rules ( 2 ). By ex tens ion, a unifier o f tw o 3-gener a tors r 1 : α 1 ⇛ β 1 and r 2 : α 2 ⇛ β 2 of R is a unifier of their sources α 1 and α 2 . A critic al p air ( K 1 , r 1 , K 2 , r 2 ) c onsists of a pair of 3-genera tors r 1 , r 2 and a most general unifier K 1 , K 2 of those. Remark 2 In Definition 3 , the 2- cell α 1 , can b e seen as a context α 1 : () → ( f 1 , g 1 ) in K ( C ), a nd similarly for α 2 . In fact, the notion of un ifier c an b e ge ne r alized to any pair of morphisms in the m ulticategory K ( C ). A 2-cell α : f ⇒ g r ewrites to a 2- cell β : f ⇒ g , by a 3-gener ator r : α ′ ⇛ β ′ : f ′ ⇒ g ′ , when ther e exists a context K : (( f ′ , g ′ )) → ( f , g ) suc h that α = K ◦ α ′ and β = K ◦ β ′ . In this case, we write α ⇛ K,r β . The rewriting system R is t erminating when there is no infinite sequence α 1 ⇛ K 1 ,r 1 α 2 ⇛ K 2 ,r 2 . . . . A p e ak is a triple ( α 1 , r 1 , α, r 2 , α 2 ), where α , α 1 and α 2 are 2-cells and r 1 and r 2 are 3-ge ner ators, such that α ⇛ K 1 ,r 1 and α ⇛ K 2 ,r 2 α 2 . In particular, with the notations of Definition 3 , every cr itical pair induces a p eak ( K 1 ◦ ( β 1 ) , r 1 , K 1 ◦ ( α 1 ) , r 2 , K 2 ◦ ( β 2 )). A p eak is joinable when there exist a 2-cell β a nd 3-cells ρ 1 : α 2 ⇛ β and ρ 2 : α 2 ⇛ β . A rewriting system is lo c al ly confluen t if e v er y pe a k is joinable. Newman’s Le mma is v a lid for 3- p olygr aphs [ 5 ]: Prop osition 4 A terminating r ewriting system is c onfluent if it is lo c al ly c onfluent. Moreov er, lo cal confluence ca n b e tested us ing critical pair s: Prop osition 5 A r ewriting syst em is lo c al ly c onflu ent if al l its critic al p airs ar e joi nable. So, in order to test whether a terminating p olygr aphic r ewriting system is confluent, it would b e tempting to compute all its cr itical pa ir s and test whether they are joinable, as in term rewr iting systems. How ever, as e x plained in the introduction, even a finite p o lygraphic rewr iting s y stem might a dmit an infinite num b er of critical pairs. In the next section, we in tro duce a theoretical setting which a llows us to compute a finite num b er of gene r ating families of critica l pair s. 4 An em b edd ing in compact 2-categories The notio n of adjunction in the 2-c ategory Cat of ca tegories, functor s and natural transfor mations can b e genera lized to any 2-catego r y a s follows. Supp ose that we are g iv e n a 2-ca tegory C . A 1-cell f : A → B is left adjoi nt to a 1-cell g : B → A (or g is right adjoint to f ) when there exist t w o 2-cells η : id A ⇒ f ⊗ g and ε : g ⊗ f ⇒ id B , ca lled resp ectively the unit and the c ounit of the adjunction and depicted resp ectively on the left o f ( 11 ), such that ( f ⊗ ε ) ◦ ( η ⊗ f ) = id f and ( ε ⊗ g ) ◦ ( g ⊗ η ) = id g . Thes e equations are called the zig-zag laws bec ause of their graphica l representation, given on the rig h t of ( 11 ): f g g f f f = f f g g = g g (11) A 2-ca tegory is c omp act (sometimes also called autonomous or rigid ) when every 1-cell admits bo th a left and a r igh t a djoin t. Given a 2-c ategory C , we write C for the free compact 2-categor y on C . An explicit description of this 2 - category ca n b e given [ 7 ]: – its 0-cells ar e the 0- cells o f C , – its 1 -cells ar e pairs f n : A → B co ns isting of an integer n ∈ Z , called winding n umb er , a nd a 1-cell f : A → B (resp. f : B → A ) of C if n is even (resp. o dd), 9 – a 2 -cell is either α 0 : f 0 ⇒ g 0 , where α : f ⇒ g is a 2-cell of C , or η n f : id B ⇒ f n ⊗ f n +1 or ε n f : f n +1 ⊗ f n ⇒ id A , where f n : A → B is a 1-cell, or a formal v er tical or horizontal comp osite of those, – 1- a nd 2-cells are quotiented by a suita ble congr uence imp osing the ax io ms of 2-catego ries, compatibility of vertical and ho r izont al comp ositions in C with tho se of C (for example ( β ◦ α ) 0 = β 0 ◦ α 0 and (id f ) 0 = id f 0 ) and the zig-zag laws ( 11 ). Given a 1-cell f in this category , we often w r ite f m for the 1-cell whic h is defined inductively by ( f ⊗ g ) m = f m ⊗ g m and ( f n ) m = f n + m (notice that f − 1 do es not denote the inv er se of f in this context). This algebraic construction is imp ortant in order to formally define the 2 -cate- gory C but this c o nstruction might b e b etter g rasp ed g r aphically , with the help of string diagr ams: the compact structure a dds to C the po ssibilit y to b end wires, without creating lo ops. F or ex- ample, consider a 2- cell α : f ⊗ g ⇒ h ⊗ i in a 2- category C . This 2-c e ll can be seen as a 2-cell α 0 : f 0 ⊗ g 0 ⇒ h 0 ⊗ i 0 of C , a s pictur ed in the center o f ( 12 ). f 0 g 0 i − 1 α 0 h 0 f 0 g 0 α 0 h 0 i 0 f 0 α 0 h 0 i 0 g 1 (12) F rom this morphis m, we ca n deduce a 2-cell ρ f 0 ,g 0 ,h 0 ⊗ i 0 ( α ) : f 0 ⇒ h 0 ⊗ i 0 ⊗ g 1 , pictured on the right o f ( 12 ), defined by ρ f 0 ,g 0 ,h 0 ⊗ i 0 ( α ) = ( α ⊗ id g 1 ) ◦ (id f 0 ⊗ η 0 g ): the wir e corresp onding to g 0 can b e b en t on the r igh t and the winding num b er is increas ed by one (the output is of type g 1 ) to “remember” that w e hav e bent the wire once on the rig h t. Similarly , one can define from α the morphism ρ ′ f 0 ⊗ g 0 ,i 0 ,h 0 ( α ) : f 0 ⊗ g 0 ⊗ i − 1 ⇒ h 0 , which corr espo nds to bending the wire of t ype i 0 on the left, so its winding n umber is decreased b y 1 (similar transforma tions can b e defined for bending the wires o f t yp e f 0 and h 0 in α ). In ter e s tingly , by the definition o f adjunctions, these t wo tr ansformations provide m utual inv erses: ρ − 1 f ,g,h = ρ ′ f ,g,h . W e call r otations these bijections betw een the ho m-categories of C . Remark 3 The notions of so ur ce a nd targ et of a 2-cell in a compa c t 2 -category is really artificia l since, given a pair of parallel 1-cells f , g : A → B , the r otations induce a bijection be tw een the hom-catego r ies C ( f , g ) and C (id B , f − 1 ⊗ g ). It can be s ho wn tha t the winding n um ber s on the 1-cells provide enoug h informa tion a bout the b ending of wires, s o that Prop osition 6 Given a 2-c ate gory C , t he emb e dding functor E : C → C define d as the identity on 0-c el ls, as f 7→ f 0 on 1-c el ls and as α 7→ α 0 on 2-c el ls is ful l and faithful. This means that given tw o 0-cells A and B of C , the hom-ca tegories C ( A, B ) and C ( A , B ) are isomorphic in a coherent wa y . The 2-ca tegory C th us provides a “larger world” in which we can embed the 2 - category C without losing information. The interest of this embedding is that there ar e “e x tra morphisms” in C that can b e used to represent “ partial comp ositions” in C . F or exa mple, consider t wo 2- cells α : f ⇒ f 1 ⊗ g ⊗ f 2 and β : h 1 ⊗ g ⊗ h 2 ⇒ h in C . These can b e seen as the morphisms o f C depicted on the left o f ( 13 ) b y 10 the previo us embedding. f 0 α 0 f 0 1 g 0 f 0 2 h 0 1 g 0 h 0 2 β 0 h 0 f 0 α 0 β 0 f 0 1 h − 1 1 h 0 h 1 2 f 0 2 f 0 α 0 f 0 1 f 0 2 h 0 1 h 0 2 β 0 h 0 (13) F rom these t wo morphisms, the mo r phism α ⊗ g β : f 0 ⇒ f 0 1 ⊗ h − 1 1 ⊗ h 0 ⊗ h 1 2 ⊗ f 0 2 , depicted in the center right of ( 13 ), can be constructed. This mor phism represe n ts the p artial c omp osition of the 2-cells α and β on the 1 -cell g : up to rotations, this 2-cell is fundamentally a wa y to give a pr ecise meaning to the diagram depicted on the right of ( 13 ). The notion of 2-p olygra ph can easily b e adapted to g enerate compact 2-categor ies instead of 2-catego ries. Instead o f generating a free categor y from the under lying 1-p olygr a ph, we gener a te a free categor y with winding num b ers: with the no ta tions o f Section 1 , its ob jects ar e the elements of E 0 and its mo rphisms f n 1 1 · f n 2 2 · · · f n k k : A → B are the pa ths e ( f n 1 1 ) · e ( f n 2 2 ) · · · e ( f n k k ) : A → B in the graph describ ed by the 1-p olygr aph, the edge e ( f n ) being f is n ∈ Z is even or f ta k e n backw ar ds if f is o dd. Similarly , ins tead of ge ne r ating a 2- category fr om the polygra ph, w e generate a fre e compact 2-categor y on the pr eviously genera ted category with winding n umber s with the 2-genera tors g iv e n by the 2 -po ly graph. Such “p olygraphs” ar e called c omp act p olygr aphs and we write 2- CPol for the category o f compact 2- polyg raphs. The embedding g iv en in Pr opo sition 6 can be extended into an embedding of 2- P ol into 2- CPol : every 2 -polyg raph can b e seen a s a compac t 2-p olygraph. Given a compact 2-p olygraph S , the definition given in Sectio n 3 ca n b e a da pted in order to define the multicategory of c omp act c ont exts K ( S ) of S . Finally , the construction o f nets given in Section 2 can also b e ada pted in or der to give a concrete and implementable de s cription of the multicategory K ( S ) – this e s sen tially amounts to suitably adding winding n um be r s to 1-cells in the p olygr a phs inv olved. f α g 1 h g 0 X Int erestingly , the setting of compact contexts provides a generalization o f par- tial comp osition by allowing a “partial comp osition of a morphism with itself ”. Namely , from a context α : ( . . . , ( f i , g i ) , . . . ) → ( f , g 1 ⊗ h ⊗ g 0 ) with f : A → A and h : B → B one ca n build the co ntext depicted o n the le ft ε 0 g ◦ ( g 1 ⊗ X ⊗ g 0 ) ◦ α : ( . . . , ( f i , g i ) , . . . , ( h, id B )) → ( f , id A ), wher e X : h → id B is a fresh v ar iable. This op eration a moun ts to mer ging the outputs of type g 1 and g 0 of α . 5 The unification algorithm Now that the theor etical setting ha s b een established, we c a n descr ibe our unificatio n algorithm. Suppo se that we a re given a po lygraphic rewriting sys tem R ∈ 3- P ol whose underlying signature is S = U 2 ( R ). By the pr evious re ma rks, S can b e seen as a co mpa ct 2-p olygr aph S . Now, s uppose that r 1 and r 2 are t wo rewr iting r ule s (i.e. 3 -generator s) in R whose le ft mem ber are resp ectively 2-cells α : f ⇒ g and β : h ⇒ i . The 2-ce ll α : f ⇒ g in the 2 - category ge nerated by S can be s een as a 2 -cell α 0 : f 0 ⇒ g 0 in the compact 2-categ o ry C gener ated by S , and ther e fo re a s a nullary context α : () → ( f 0 , g 0 ) in the multicategory of co n texts K ( C ). Similarly , β can b e see n as a context β : () → ( h 0 , i 0 ). In the mult icategory K ( C ), we can co mpute a most g eneral unifier of α and β (see Rema rk 2 ) from w hich we will b e able to genera te critical pairs of the rule s r 1 and r 2 . Because of space limitations, we don’t provide here a fully detailed a nd fo r mal pr esen tation of the algorithm: the purp ose of this paper was to in tro duce the forma l framework necessar y to define the algo rithm, whose in-depth description will b e given in subsequent works. W e first introduce s ome ter minology a nd notations on nets. Giv en a 2-net α , a n instance of a 2-genera tor y is the father (res p. son ) o f a n instance of a 1-gener ator x if x o ccurs in the target (resp. so urce) o f y . F or ex ample, in ( 10 ), γ 0 is a son of 1 0 and 1 1 and a father of 1 2 and 1 3 . It is 11 easy to show that a given instance of a 1-generato r admits at most one father a nd one s on. An instance of 1 - generator is dangling whe n it has no father or no son. An ins tance o f a generator is in the b or der of a net if it is in its so ur ce o r its ta rget. The a lgorithm pro ceeds as follows. W e supp ose that we hav e r epresented the 2- cells α and β as po lygraphic 2-nets. O ur go al is to co nstruct a 2-net ω together with tw o injective mor phisms of lab eled p olygraphs i 1 : α → ω a nd i 2 : β → ω satisfying the prop erties req uir ed for unifiers as reformulated in Rema rk 2 . The algor ithm is quite similar to the rule-based formulation of the unification algo rithm for terms [ 1 ]. It beg ins b y setting ω = α and i 1 = id α , and then iterates a pro cedure that will prog ressively propa gate the unification and make ω grow, by a dding cells to it, un til it is big enough so that ther e exists an injection i 2 : β → ω . The pr ocedur e whic h is iterated is non-deterministic and the critica l pairs will be o btained a s the collection of the results of the no n- failed branches of computatio n. During the iteration tw o sets a re maintained, T and U , which bo th contains pairs ( x, x ′ ) c o nsisting of a n n -cell x of β and a n n -cell x ′ of ω for s ome in teger n ∈ { 0 , 1 , 2 } . The set U (for Unified) contains the injection i 2 which is b eing constructed: if ( x, x ′ ) ∈ U and the branch succeeds then the resulting map i 2 : β → ω will b e s uch that i 2 ( x ) = x ′ . The set T (as in T o do) cont ains the pair s ( x, x ′ ) such that x is a cell o f β which is to b e unified with the cell x ′ of ω . Initially , ω = α , U = ∅ a nd T = { ( x, x ′ ) } , where x and x ′ are instances of 2-genera tors in β a nd in ω resp ectively , b oth chosen non-deterministically . Then the algo rithm iterates ov er the following rules, up dating the v a lues of ω , U and T by executing the first rule which applies (up da ting a v alue is denoted with the symbo l :=). – Duplic ate. If T = { ( x, x ′ ) } ⊎ T ′ with ( x, x ′ ) ∈ U then T := T ′ . – Clash. If ( x, x ′ ) ∈ T and ( x, x ′′ ) ∈ U and x ′ 6 = x ′′ then fail. – T yp e che ck. If ( x, x ′ ) ∈ T with ℓ ( x ) 6 = ℓ ( x ′ ) then fail. – Pr op agate-0. If T = { ( x, x ′ ) } ⊎ T ′ , where x and x ′ are 0-ce lls then T := T ′ and U := { ( x, x ′ ) } ∪ U . – Pr op agate-1. If T = { ( x, x ′ ) } ⊎ T ′ , where x and x ′ are 1-ce lls, then T := T ′ and if x has a father y then if x ′ has a father y ′ then T := { ( y , y ′ ) } ∪ T and U := { ( x, x ′ ) } ∪ U else either add a fresh gener ator y ′ of t yp e ℓ ( y ) in ω , T := { ( y , y ′ ) } ∪ T and U := { ( x, x ′ ) } ∪ U or merge x ′ with some other 1-cell x ′′ in the b order o f ω in ω , T := { ( x, x ′ ) } ∪ T if x has a son y then similar to the pr evious c ase . – Pr op agate-2. If T = { ( x, x ′ ) } ⊎ T ′ , where x and x ′ are 2-ce lls, then T := T ′ , U := { ( x, x ′ ) } ∪ U , we add in T that the 0- a nd 1-c e lls in the sour ce of x should be ma tc hed with the cor r espo nding cells in the so urce of x ′ , and the 0- a nd 1-cells of the target of x sho uld be matched with those in the targ et of x ′ . 12 The “either . . . or” co nstruction ab ov e denotes a non-deterministic c ho ice and the “mer g e” r efers to the merg ing op eration introduced in Sectio n 4 (this op eratio n migh t fail if the lab els or the winding num b ers of x ′ and x ′′ are not suitable). The w ay this a lgorithm works is maybe b e st understo o d with an exa mple. Consider the signature S with one 0-cell ∗ , one 1-cell 1 : ∗ → ∗ and three 2-cells δ : 1 → 4, µ : 4 → 1 and σ : 1 → 1 (where 4 denotes 1 ⊗ 1 ⊗ 1 ⊗ 1 ). W e w r ite ς = σ ⊗ σ ⊗ σ ⊗ σ . No w, consider a rewriting system on this signature con taining tw o rules r 1 and r 2 whose left mem b ers are resp ectively α = ς ◦ δ and β = µ ◦ ς , that we re pr esen t resp ectiv ely as the compact nets 1 0 δ 0 1 1 1 2 1 3 1 4 σ 0 σ 1 σ 2 σ 3 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 σ 4 σ 5 σ 6 σ 7 1 13 1 14 1 15 1 16 µ 0 1 17 (14) (for simplicity , we omitted the instances of 0-cells). W e describ e here a few possible non-determinis- tic br anc hes of the execution o f the a lgorithm. F or example, if we b egin with T = { ( σ 4 , δ 0 ) } , the algorithm will immediately fail by Typechec k beca us e the label σ of σ 4 differs from the lab el δ of δ 0 . Co ns ider a no ther execution b eginning with T = { ( σ 4 , σ 0 ) } , this time the la bel matches s o Propag ate-2 will propag ate the unification by setting T = { (1 9 , 1 1 ) , (1 13 , 1 5 ) } and U = { ( σ 4 , σ 0 ) } . Since 1 9 is dangling, Propa gate-1 will move the pa ir (1 9 , 1 1 ) from T to U . Then the pair (1 13 , 1 5 ) will b e handled by P ropagate-1 . Since 1 5 is dangling but 1 13 is not, a new generator µ 1 will be added to ω (now pictured on the left o f ( 15 )) and after a few pro pagations (1 13 , 1 5 ) will be mov ed fro m T to U , ( µ 0 , µ 1 ) w ill b e added to U and T will contain (1 11 , 1 19 ). By Propag ate-1, this unification pair can lea d to multiple non-deterministic exec utions: a new ge ne r ator σ 5 can b e added (in the middle of ( 15 )), or the 1- generator 1 19 can b e merged with another 1 -generator (1 7 for e x ample as pictur ed in the rig h t of ( 15 )). Notice that in this last case, the morphism contains a “hole” of type 1 6 ⇒ 1 18 , which is handled by a context v ariable. 1 0 δ 0 1 1 1 2 1 3 1 4 σ 0 σ 1 σ 2 σ 3 1 5 1 6 1 7 1 8 1 18 1 19 1 20 µ 1 1 21 1 0 δ 0 1 1 1 2 1 3 1 4 σ 0 σ 1 σ 2 σ 3 1 5 1 6 1 7 1 8 1 22 σ 5 1 18 1 19 1 20 µ 1 1 21 1 0 δ 0 1 1 1 2 1 3 1 4 σ 0 σ 1 σ 2 σ 3 1 5 1 6 1 7 1 8 1 18 1 20 µ 1 1 21 (15) By executing fully the algorithm, the thre e morphisms of ( 16 ) will b e obtained as unifier s (as well as many other s). δ σ σ σ σ σ σ σ δ δ σ σ σ σ σ σ δ δ σ σ σ σ σ σ δ (16) It can b e shown that the algo rithm terminates a nd generates a ll the cr itical pairs in c ompact contexts, and these ar e in finite num b er. It is imp ortant to notice that the algorithm ge ne r ates the 13 critical pair s of a r ewriting system R in the “bigger world” of compac t c on tex ts, from whic h we can ge nerate the critical pairs in the 2 -category gener ated by R (which ar e not necessarily in finite nu mber as ex plained in the introduction). If joinabilit y of the critical pairs in compact c o n texts implies that the rewriting sys tem is co nfluent, the conv ers e is unfortunately not true: a simila r situation is well known in the study of λ -calculus with explicit substitution, where a rewriting system might b e co nfluen t without being confluent o n terms with metav ariables . W e have realized a toy implementation of the algor ithm in less than 2 000 lines of OCaml, with which we hav e b een able to s uccessfully recov er the critical pa irs o f r ewriting systems in [ 8 ]. Even though we did not par ticularly fo cus on efficiency , the execution times a re go o d, typically les s than a second, bec ause the mo rphisms involv ed in p olygr aphic r ewriting systems ar e usually small (but they can ge ner ate a large num b er of critica l pair s) F uture w orks. This paper lays the theo r etical foundations for unification in po lygraphic 2 -di- mensional rewriting systems and leaves many rese a rch tracks o p en for future w o rks. W e plan to study the precise links betw e e n our algo rithm and the usual unifica tion for ter ms (every term rewriting system can be s een as a p olygra phic rewr iting system [ 2 ]) as w ell as algorithms for (planar) gr aph rewr iting. Concerning concr ete applica tions, since these rewriting systems es sen- tially transform circuits ma de o f o pera to rs (the 2-generato rs) linked b y a bunc h of wir es (the 1-genera tors), it would b e interesting to see if these metho ds ca n b e used to optimize elec tr onic circuits. Fina lly , we plan in vestigating the generalizatio n of these metho ds in dimensio n higher than 2, which seems to b e very challenging. Ac knowledgemen ts. The author is m uch indebted to Jo hn Bae z , Alb ert Burroni, Jona s F rey , Emmanuel Haucour t, Mar tin Hyla nd, Yves Lafont, Paul-Andr´ e Melli` es and F ran¸ cois M ´ etay er. References [1] F. Baa der a nd T. Nipkow. T erm R ewriting and Al l That . Cambridge University P ress, 1999 . [2] A. Burroni. Higher-dimensiona l word problems with applications to equatio nal logic. The or. Comput. Sci. , 115 (1):43–62, 199 3. [3] Y. Guiraud. The thr ee dimensio ns of pro ofs. Ann. pur e appl. lo gic , 141(1 -2):266–2 9 5, 200 6. [4] Y. Guiraud. Tw o p olygr a phic presentations o f Petri nets. TCS , 360 (1-3):124–1 46, 2006 . [5] Y. Guiraud and P . Ma lbos. Higher- dimensional categories with finite deriv a tion t y pe. The or. Appl. Cat. , 22(18):4 20–478, 2009 . [6] A. Joy al and R. Street. The Geometry of Te ns or Calculus , I. A dv. Math. , 88:55 –113, 1991 . [7] G.M. Kelly and M.L. Laplaza. Coherence for compact close d catego ries. Journal of Pur e and Applie d A lgebr a , 19:19 3–213, 198 0. [8] Y. Lafont. T ow ards an algebraic theory o f Bo olean circuits. J. Pure Appl. Alg. , 1 84:257– 3 10, 2003. [9] F. W. Lawv er e . F unctorial Semantics of Alg ebr aic The ories and S ome Alg ebr aic Pr oblems in the c ontext of F unctorial Semantics of Algebr aic The ories . PhD thesis, Columbia Universit y , 1963. [10] T. Leinster. Higher Op er ads, Higher Cate gories . Cam br idge Univ ersity Press, 200 4. [11] S. MacL a ne. Cate gories for t he Working Mathema tician . Springer V erlag, 197 1. [12] S. Mimra m. S ´ emantique des jeux asynchr ones et r´ e ´ ecritur e 2-dimensionnel le . P hD thesis, 2008. 14 [13] S. Mimra m. Computing Critical Pairs in Polygraphs. Preprint, 2 009. [14] S. Mimra m. The Structure of First-Order Causality. In LICS’09 , pa ges 212–2 21, 2009. [15] J. Pow er. An n -categ orical pasting theo rem. Pr o c. Int . Conf. Como , pages 326– 3 58, 199 0 . [16] R. Street. Limits indexed by category-v a lued 2-functor s. J . Pur e Appl. Alg. , 8(2):14 9–181, 1976. 15 γ γ γ γ γ n γ γ δ σ σ σ σ σ δ

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment